You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This will print 'http://google.com/foo.js' instead of printing whatever script file is currently being executed on the web server's domain.
If an attacker is able to inject DOM elements into a web page with custom name attributes of the attacker's choosing (due to some pre-existing security flaw on the site), then with this <img name='currentScript'> trick they can potentially escalate their attack power to a higher tier XSS security flaw.
Surely web browsers should just plug this threat vector altogether, and not allow any DOM element name='' attribute overwrite any element name (e.g. 'body', 'head', 'elements', 'URL', 'addEventListener', 'removeEventListener', etc...) on document that has a prereserved meaning in the DOM spec?
Also, in addition to the document.currentScript functionality, even if developers sanitize that hole, an attacker could cause denial of service style problems to web pages by injecting an element like <img name='addEventListener'> to cause site code to break.
Can the DOM spec enforce a guarantee that built-in attributes cannot be replaced in this manner? That way web developers would not need to think about this kind of threat vector elevation attacks downstream, and this whole class of CVEs like have been reported above would be impossible?
The text was updated successfully, but these errors were encountered:
What is the issue with the DOM Standard?
Consider the following page:
This will print
'http://google.com/foo.js'
instead of printing whatever script file is currently being executed on the web server's domain.If an attacker is able to inject DOM elements into a web page with custom name attributes of the attacker's choosing (due to some pre-existing security flaw on the site), then with this
<img name='currentScript'>
trick they can potentially escalate their attack power to a higher tier XSS security flaw.Searching the web, there are several CVE advisories about this trick being used to elevate an attacker's threat area in different projects:
https://vulert.com/vuln-db/CVE-2024-45389
GHSA-gcx4-mw62-g8wm
https://nvd.nist.gov/vuln/detail/CVE-2024-45812
GHSA-4vvj-4cpr-p986
Surely web browsers should just plug this threat vector altogether, and not allow any DOM element
name=''
attribute overwrite any element name (e.g.'body'
,'head'
,'elements'
,'URL'
,'addEventListener'
,'removeEventListener'
, etc...) on document that has a prereserved meaning in the DOM spec?For example, it was recently reported to Emscripten project that Emscripten should not be accessing document.currentScript.src "bare" since it could be attacked via this way, but instead always only access it on the condition that
document.currentScript.tagName == 'SCRIPT'
.It feels a bit nonsensical and misplaced to have to account for this problem in Emscripten since surely nobody should be allowed to have
<foo name='currentScript'>
replacedocument.currentScript
- there are no good legitimate uses of that for anyone?Also, in addition to the
document.currentScript
functionality, even if developers sanitize that hole, an attacker could cause denial of service style problems to web pages by injecting an element like<img name='addEventListener'>
to cause site code to break.Can the DOM spec enforce a guarantee that built-in attributes cannot be replaced in this manner? That way web developers would not need to think about this kind of threat vector elevation attacks downstream, and this whole class of CVEs like have been reported above would be impossible?
The text was updated successfully, but these errors were encountered: