Skip to content
XSS Disclosed report Intermediate

ActionView sanitize helper bypass with noscript

The Rails HTML sanitizer failed to properly sanitise input when the noscript element was on the allowlist, allowing crafted markup to slip through. An attacker could use this to inject script and achieve cross-site scripting in applications relying on the sanitize helper.

taise Follow

Originally disclosed on HackerOne

Medium 6.1 View original
  • Fixed in 26 days
  • Paid in 26 days
  • Disclosed after 26 days

Summary by the program

###Summary

There is a possible XSS vulnerability with certain configurations of Rails::HTML::Sanitizer 1.6.0 when used with Rails >= 7.1.0.

Versions affected: 1.6.0 Not affected: < 1.6.0 Fixed versions: 1.6.1

Advisory: https://github.com/rails/rails-html-sanitizer/security/advisories/GHSA-rxv5-gxqc-xx8g

The report

Rails-html-sanitizer, which Rails AtionView also uses fails to sanitize input when noscript are allowed. An example would be as follows;

Ruby
<%= sanitize '<noscript><p id="</noscript><script>alert(1)</script>"></noscript>' %>

You could see other patterns/places where this is used in the security advisory. View #250964 for details.

Impact

Sanitizer bypass that leads to XSS on applications built with it. It also affects applications using Rails Action View's sanitize helper: https://api.rubyonrails.org/v7.2/classes/ActionView/Helpers/SanitizeHelper.html

The original report as published on HackerOne, by taise. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 sanitiser's handling of the noscript element allowed crafted nesting to break out of the allowed context and leave script markup in the output.

Impact

A sanitiser bypass could lead to XSS on applications built with it, including those using the Action View sanitize helper.

What the attacker needed

Noscript allowed in sanitiser config; Rails >= 7.1.0 with sanitiser 1.6.0

The fix

It was fixed in version 1.6.1 of the sanitiser.

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 sanitiser is a filter that strips dangerous markup from user input before a page shows it. Here the filter was told to permit the noscript tag, and that permission let specially crafted input pass through with a script tag intact. When a victim viewed the page, that script would run in their browser, which is cross-site scripting.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by taise

View all

3 more disclosed reports, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.