rails-html-sanitizer: Possible XSS via shared scrubber state in concurrent calls
Published 13 Nov 2026 · Updated 13 Nov 2026
Is your project on an affected rails-html-sanitizer?
Look after several Rails or Ruby apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected package
- Affected
- <1.7.2
- Fixed in
- 1.7.2
bundle update --conservative rails-html-sanitizer # Gemfile: '>= 1.7.2'Details
Summary
Rails::HTML::SafeListSanitizer (both the HTML4 and HTML5 variants) shares one Rails::HTML::PermitScrubber across every sanitize call on the same instance, assigning its tags and attributes on each call without synchronization. Two concurrent sanitize calls with different tags: or attributes: options can interleave, so one call is scrubbed with the other call's allowlist.
- Versions affected:
< 1.7.2 - Not affected: none
- Fixed versions:
1.7.2
Impact
Action View memoizes a single SafeListSanitizer per helper module and uses it for every sanitize call in the process, so in a multi-threaded server (for example Puma) all requests share the same PermitScrubber. If any code path calls sanitize with a more permissive allowlist, an attacker who can trigger that path concurrently with another request can cause the other request to be sanitized with the permissive allowlist. If the permissive allowlist admits script or an event-handler attribute, the strict call emits it unchanged, which is a cross-site scripting vector when the strict output is stored or rendered to other users.
Applications are affected only if they run more than one thread per process and some sanitize call passes tags: or attributes: options that differ from another call's, including a call that passes no options and so uses the defaults. Applications that use a single configuration everywhere, pass their own scrubber:, or run single-threaded are not affected.
Workarounds
Use the same allowlist for every sanitize call, or pass a scrubber: built per call (Rails::HTML::PermitScrubber.new with tags= and attributes= set) instead of tags: and attributes: options.
Credit
Reported by hiumee via HackerOne.
Is GHSA-h7wh-q2qr-458c in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected rails-html-sanitizer, and gives you the command that fixes it.
More advisories for rails-html-sanitizer
- MediumCVE-2026-128068rails-html-sanitizer: Possible regular expression denial of service with certain configurations · 13 Nov 2026
- MediumCVE-2026-73648Rails HTML Sanitizers: Possible XSS vulnerability with certain configurations · 21 Jul 2026
- LowCVE-2024-53989rails-html-sanitizer has XSS vulnerability with certain configurations · 2 Dec 2024
- LowCVE-2024-53987rails-html-sanitizer has XSS vulnerability with certain configurations · 2 Dec 2024
- LowCVE-2024-53988rails-html-sanitizer has XSS vulnerability with certain configurations · 2 Dec 2024
- LowCVE-2024-53986rails-html-sanitizer has XSS vulnerability with certain configurations · 2 Dec 2024
References
- Linkgithub.com/rails/rails-html-sanitizer/security/advisories/GHSA-h7wh-q2qr-458c
- Linkgithub.com/rails/rails-html-sanitizer/issues/228
- Linkgithub.com/rails/rails-html-sanitizer/commit/15f764c3563d5dd9b97ad32eaa7454577ccec4b9
- Packagegithub.com/rails/rails-html-sanitizer
- Linkgithub.com/rails/rails-html-sanitizer/releases/tag/v1.7.2
- Linkgithub.com/rubysec/ruby-advisory-db/blob/master/gems/rails-html-sanitizer/GHSA-h7wh-q2qr-458c.yml
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.