8000 security: fix DOM clobbering in auto public path · webpack/webpack@2411661 · GitHub
[go: up one dir, main page]

10000 Skip to content

Commit 2411661

Browse files
security: fix DOM clobbering in auto public path
1 parent f46a03c commit 2411661

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/runtime/AutoPublicPathRuntimeModule.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ class AutoPublicPathRuntimeModule extends RuntimeModule {
5050
`var document = ${RuntimeGlobals.global}.document;`,
5151
"if (!scriptUrl && document) {",
5252
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')",
5457
Template.indent("scriptUrl = document.currentScript.src;"),
5558
"if (!scriptUrl) {",
5659
Template.indent([

0 commit comments

Comments
 (0)
0