Skip to content
XSS Disclosed report Intermediate

ActionView sanitize helper bypass with style and math

The Rails HTML sanitizer fails to properly sanitize input when the 'math' and 'style' tags are explicitly allowed, allowing an attacker to inject malicious content that bypasses the sanitizer and leads to cross-site scripting (XSS).

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-638j-pmjw-jq48

The report

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

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

You could see other patterns/places where this is used in the security advisory.

View #2519941 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 sanitizer's allowlist logic does not correctly handle the combination of 'math' and 'style' tags, permitting dangerous content to pass through.

Impact

This sanitizer bypass could lead to XSS on applications that use the affected configuration.

What the attacker needed

Application uses Rails >= 7.1.0; Application uses rails-html-sanitizer 1.6.0; Sanitizer allows 'math' and 'style' tags

The fix

The vulnerability was fixed in version 1.6.1.

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 cleans user-supplied HTML to remove dangerous code. Here, when a developer allowed the 'math' and 'style' tags, the sanitizer made a mistake and let harmful code through, so an attacker could run scripts in other users' browsers.

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.