From 2411661bd1bedf1b2efc23c76d595c189425d39f Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Wed, 21 Aug 2024 15:47:34 +0300 Subject: [PATCH] security: fix DOM clobbering in auto public path --- lib/runtime/AutoPublicPathRuntimeModule.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/runtime/AutoPublicPathRuntimeModule.js b/lib/runtime/AutoPublicPathRuntimeModule.js index fcad7ea3a9a..74b40a1e883 100644 --- a/lib/runtime/AutoPublicPathRuntimeModule.js +++ b/lib/runtime/AutoPublicPathRuntimeModule.js @@ -50,7 +50,10 @@ class AutoPublicPathRuntimeModule extends RuntimeModule { `var document = ${RuntimeGlobals.global}.document;`, "if (!scriptUrl && document) {", Template.indent([ - "if (document.currentScript)", + // Technically we could use `document.currentScript instanceof window.HTMLScriptElement`, + // but an attacker could try to inject `` + // and use `` + "if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')", Template.indent("scriptUrl = document.currentScript.src;"), "if (!scriptUrl) {", Template.indent([