Skip to content

Commit 85bed8d

Browse files
authored
Build: Fix an XSS in the test server HTML serving logic
The test server has a rule for `/tests/unit/*/*.html` paths that serves a proper local file. However, the parameters after `/unit/` so far accepted many characters that have special meaning, leading to possibly reading a file from outside of the Git repository. Fix that by only accepting alphanumeric characters, `-` or `_`. This should resolve one CodeQL alert. Closes gh-2309
1 parent af8adca commit 85bed8d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tests/runner/createTestServer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export async function createTestServer( report ) {
2222
} );
2323

2424
// Add a script tag to HTML pages to load the QUnit listeners
25-
app.use( /\/tests\/unit\/([^/]+)\/\1\.html$/, async( req, res ) => {
25+
app.use( /\/tests\/unit\/([a-zA-Z0-9_-]+)\/\1\.html$/, async( req, res ) => {
2626
const html = await readFile(
2727
`tests/unit/${ req.params[ 0 ] }/${ req.params[ 0 ] }.html`,
2828
"utf8"

0 commit comments

Comments
 (0)