Skip to content
XSS Disclosed report Advanced

#2931639 ActionView sanitize helper bypass with math-related tags

The Rails HTML sanitizer failed to properly sanitise input when the style tag was among the allowed tags, so crafted markup could slip through. An attacker could then get script to run in a victim's browser in applications using that configuration.

mokusou Follow with taise

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-cfjx-w229-hgx5

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: ["math", "mtext", "table", "style", "mglyph"] %>
<%# or %>
<%= sanitize @comment.body, tags: ["math", "mtext", "table", "style", "malignmark"] %>

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

Root cause

Likely the sanitiser's handling of certain math-related tags combined with an allowed style tag let markup through that should have been removed.

Impact

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

What the attacker needed

Sanitiser allows the style tag; app uses affected version 1.6.0; attacker can submit content

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 meant to strip dangerous markup from user content before a page shows it. Here it let some through when a particular tag was allowed, so an attacker could get their own code to run in someone else's browser, which is called cross-site scripting. This only matters if the site allows that tag in its sanitiser settings.

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.