Skip to content
XSS Disclosed report Intermediate

ActionView sanitize helper bypass with style

The rails-html-sanitizer library failed to properly sanitise input when the style tag was explicitly allowed, so crafted markup could survive filtering. An attacker could then achieve cross-site scripting in applications using the affected version with that configuration.

mokusou 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-2x5m-9ch4-qgrr

The report

Rails-html-sanitizer, which Rails AtionView also uses, fails to sanitize input when the style tag is allowed, leading to XSS. A vulnerable example would have been as follows;

Ruby
<%= sanitize @comment.body, tags: ["style"] %>

You could see other patterns/places where this is used in the security advisory. View #2519936 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 mokusou. 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

Impact

A sanitiser bypass could lead to XSS on applications built with the affected version, but only where the style tag is explicitly allowed in the sanitiser configuration.

What the attacker needed

Rails-html-sanitizer 1.6.0; Rails 7.1.0 or later; style tag allowed in sanitiser config

The fix

It was fixed in version 1.6.1 of the library.

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 content before a page shows it. Here the filter was told to allow the style tag, and in that mode it let malicious content through, so an attacker's content could run script in a victim's browser. That is called cross-site scripting, or XSS.

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 mokusou

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.