Skip to content
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

Merged
merged 3 commits into from
Nov 14, 2024
Merged

Conversation

frenzymadness
Copy link
Member

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 `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.
@frenzymadness frenzymadness marked this pull request as draft November 12, 2024 12:56
@frenzymadness
Copy link
Member Author

The current solution is too strict and I have to rework it a bit.

@frenzymadness
Copy link
Member Author

@hrnciar PTAL

@frenzymadness frenzymadness marked this pull request as ready for review November 14, 2024 06:25
@frenzymadness
Copy link
Member Author

The security researcher who reported this vulnerability confirmed that the fix is good and covers many payloads from the same category of attacks.

@hrnciar
Copy link

hrnciar commented Nov 14, 2024

I also like your solution. Thank you. +1

@frenzymadness frenzymadness merged commit a074425 into main Nov 14, 2024
9 checks passed
@frenzymadness frenzymadness deleted the fix_js_css_comment branch November 14, 2024 10:55
"""
for match in self._find_comments(style):
comment = match.group(0)
print("f", comment)
Copy link
Member

@hroncok hroncok Nov 14, 2024

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another one is here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants