-
Notifications
You must be signed in to change notification settings - Fork 4
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
Scan for JS code also in CSS comments #19
Conversation
The `Cleaner()` now scans for hidden JavaScript code embedded within CSS comments. In certain contexts, such as within `<svg>` or `<math>` tags, `<style>` tags may lose their intended function, allowing comments like `/* foo */` to potentially be executed by the browser.
The current solution is too strict and I have to rework it a bit. |
02de1e4
to
60c0cb2
Compare
@hrnciar PTAL |
The security researcher who reported this vulnerability confirmed that the fix is good and covers many payloads from the same category of attacks. |
I also like your solution. Thank you. +1 |
""" | ||
for match in self._find_comments(style): | ||
comment = match.group(0) | ||
print("f", comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a leftover debug print.
EDIT: #20
print("f", comment) | ||
if _has_javascript_scheme(comment) or _looks_like_tag_content(comment): | ||
style = style.replace(comment, "/* deleted */") | ||
print("f", style) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another one is here.
The
Cleaner()
now scans for hidden JavaScript code embeddedwithin CSS comments. In certain contexts, such as within
<svg>
or
<math>
tags,<style>
tags may lose their intended function,allowing comments like
/* foo */
to potentially be executed bythe browser.