Potential XSS on sanitize/Rails::Html::WhiteListSanitizer
The white list sanitizer in rails-html-sanitizer could be bypassed by carefully crafted strings, allowing user input to bypass sanitization and potentially lead to an XSS attack.
- Triaged in 2 days
- Fixed in 6 months
- Paid in 6 months
- Disclosed after 7 months
Summary by the program
Possible XSS vulnerability in rails-html-sanitizer
There is a possible XSS vulnerability in the white list sanitizer in the rails-html-sanitizer gem. This vulnerability has been assigned the CVE identifier CVE-2015-7580.
Versions Affected: All. Not affected: None. Fixed Versions: v1.0.3
Impact
Carefully crafted strings can cause user input to bypass the sanitization in the white list sanitizer which will can lead to an XSS attack.
Vulnerable code will look something like this:
<%= sanitize user_input, tags: %w(em) %>
All users running an affected release should either upgrade or use one of the workarounds immediately.
Releases
The FIXED releases are available at the normal locations.
Workarounds
Putting the following monkey patch in an initializer can help to mitigate the issue:
class Rails::Html::PermitScrubber
alias :old_scrub :scrub
alias :old_skip_node? :skip_node?
def scrub(node)
if node.cdata?
text = node.document.create_text_node node.text
node.replace text
return CONTINUE
end
old_scrub node
end
def skip_node?(node); node.text?; end
end
Patches
To aid users who aren't able to upgrade immediately we have provided patches for the two supported release series. They are in git-am format and consist of a single changeset.
- 1-0-whitelist_sanitizer_xss.patch - Patch for 1.0 series
Credits
Thanks to Arnaud Germis, Nate Clark, John Colvin and Yassine ABOUKIR for reporting this issue.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the sanitizer did not properly handle certain HTML nodes such as CDATA sections, allowing malicious content to bypass filtering.
Impact
An attacker could execute scripts in a victim's browser, potentially leading to an XSS attack.
What the attacker needed
Application uses rails-html-sanitizer; user input is sanitized with white list sanitizer
The fix
The vulnerability was fixed in version 1.0.3, and a monkey patch workaround was provided for those unable to upgrade immediately.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A sanitizer is a tool that removes dangerous parts from user input before showing it on a web page. Here, the sanitizer could be tricked so that malicious code slipped through, which could let an attacker run scripts in a victim's browser.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.