-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allowed Schemas option broken by bad html entities in input #693
Comments
this looks like a weird bypass of |
This might not have anything to do with bad entities actually:
|
Actually, I'm not sure if this is really a bug after all 😅 When I said this:
I was mistaken; the browser treats it like a relative link to a file named Similarly, I think there might still be something worth fixing regarding broken html entities. Whether that is desired or not, I could kind of argue both ways... |
Interesting. You seem to be saying the browser completely ignores the |
To Reproduce
See also example script at bottom
a
tags, only allowinghref
attribute, and only allowinghttps
schemap
(decimal),p
(hex)<a href=http://example.com>ClickMe</a>
Expected behavior
Expected: The
href
attribute is stripped from the string. (<a>ClickMe</a>
)Actual: The
href
remains, with the ampersand in the attribute changed to&
. This results in a tag like:<a href="htt&#112://example.com">ClickMe</a>
Describe the bug
If the html entities are correctly formatted with trailing semicolon, we get the expected output. But the whole point of sanitization is to handle bad input. 😄
In any case, this is clearly not
https
schema, so the attribute should be stripped.Security Consideration
I don't think this constitutes a security vulnerability. When the browser sees
<a href="htt&#112://example.com">ClickMe</a>
, it treats that like<a href="file:///htt&#112://example.com">ClickMe</a>
, which is to say, a link to/htt&
with everything after the#
treated as the page hash. Maybe there's some vulnerability if you know the user happens to have a file in a specific spot on their local system with a name ending in ampersand?Details
Version of Node.js:
v22.13.1
Server Operating System: MacOS Version
15.3 (24D60)
(also reproducible on ubuntu, but i'm not sure the version)Additional context:
n/a
Screenshots
n/a
Example Script
The text was updated successfully, but these errors were encountered: