Skip to content

Commit 839578c

Browse files
author
Jonathan Ginsburg
committedFeb 1, 2022
fix(security): remove XSS vulnerability in returnUrl query param
The `returnUrl` query parameter can be used to execute malicious code. For example, visiting `http://localhost:9876/?return_url=javascript:alert(document.domain)` will display an alert.
1 parent db53785 commit 839578c

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed
 

‎client/karma.js

+3
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ function Karma (updater, socket, iframe, opener, navigator, location, document)
239239
self.updater.updateTestStatus('complete')
240240
}
241241
if (returnUrl) {
242+
if (!/^https?:\/\//.test(returnUrl)) {
243+
throw new Error(`Security: Navigation to ${returnUrl} was blocked to prevent malicious exploits.`)
244+
}
242245
location.href = returnUrl
243246
}
244247
}

‎static/karma.js

+3
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ function Karma (updater, socket, iframe, opener, navigator, location, document)
249249
self.updater.updateTestStatus('complete')
250250
}
251251
if (returnUrl) {
252+
if (!/^https?:\/\//.test(returnUrl)) {
253+
throw new Error(`Security: Navigation to ${returnUrl} was blocked to prevent malicious exploits.`)
254+
}
252255
location.href = returnUrl
253256
}
254257
}

0 commit comments

Comments
 (0)
Please sign in to comment.