Closed detournemint closed 6 years ago
I would be willing to try to work on this.
That would be great! If you submit a PR we'll merge it right away
I think this isn't a filtering issue exactly.
http://redcloth.org/try-redcloth/ is just not filtering HTML, you don't need to do <scrIpt>
with a capital I, a regular <script>alert(1)</script>
will work just as well. When filtering html, the obfuscated script doesn't pass:
[19] pry(main)> RedCloth.new("<script>alert(1)</script>").to_html
=> "<script>alert(1)</script>"
[20] pry(main)> RedCloth.new("<script>alert(1)</script>", [:filter_html]).to_html
=> "<script>alert(1)</script>"
[21] pry(main)> RedCloth.new("<scrIpt>alert(1)</scrIpt>", [:filter_html]).to_html
=> "<scrIpt>alert(1)</scrIpt>"
I do think the issue is that RedCloth doesn't mention filtering in the readme.
@mveytsman oh that makes way more sense. Thanks for pointing that out!
On the following example: http://redcloth.org/try-redcloth/
pasting the code:
<scrIpt>alert()</scrIpt>
results in an alert box being shown to the user.
Possible Fix: Instead of using blacklisting to escape Javascript HTML, use a whitelist of allowed tags.