Skip to content

Commit 97d6387

Browse files
committed
fix(static): prevent possible XSS by sanitizing output
1 parent 4247842 commit 97d6387

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
"progress": "2.0.1",
6767
"request": "2.87.0",
6868
"request-promise-native": "1.0.7",
69+
"sanitizer": "^0.1.3",
6970
"semver": "^6.0.0",
7071
"shelljs": "0.8.2",
7172
"snyk": "1.159.0",

src/openwhisk/static.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const postcssurl = require('postcss-url');
1818
const parser = require('postcss-value-parser');
1919
const babel = require('@babel/core');
2020
const ohash = require('object-hash');
21+
const sanitizer = require('sanitizer');
2122

2223
const { space } = postcss.list;
2324
const uri = require('uri-js');
@@ -46,7 +47,7 @@ function error(message, code = 500) {
4647
'X-Static': 'Raw/Static',
4748
'Cache-Control': 'max-age=300',
4849
},
49-
body: `${message}`,
50+
body: sanitizer.escape(message),
5051
};
5152
}
5253

0 commit comments

Comments
 (0)