CVE-2024-53985 Possible XSS vulnerability with certain configurations of rails-html-sanitizer 1.6.0

Low 2.3 Published Updated

Attackers can inject malicious scripts via XSS if developers override sanitizer tags to include math/svg and style elements.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
A user has to click or open something
Fix
Available

What is CVE-2024-53985?

CVE-2024-53985 is a low-severity cross-site scripting vulnerability in rails-html-sanitizer, published on 2 Dec 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

Official description

rails-html-sanitizer is responsible for sanitizing HTML fragments in Rails applications. There is a possible XSS vulnerability with certain configurations of Rails::HTML::Sanitizer 1.6.0 when used with Rails >= 7.1.0 and Nokogiri < 1.15.7, or 1.16.x < 1.16.8. The XSS vulnerability with certain configurations of Rails::HTML::Sanitizer may allow an attacker to inject content if HTML5 sanitization is enabled and the application developer has overridden the sanitizer's allowed tags with both "math" and "style" elements or both both "svg" and "style" elements. This vulnerability is fixed in 1.6.1.

Weakness: CWE-79

Which versions are affected by CVE-2024-53985?

2 open source packages ship an affected version, including rails-html-sanitizer. It affects 1 product.

PackageAffectedFixed in
rails-html-sanitizer RubyGemsFrom 1.6.01.6.1
rails-html-sanitizer RubyGemsFrom 1.6.01.6.1

Products include Rubyonrails Rails Html Sanitizers.

How do I fix CVE-2024-53985?

Upgrade rails-html-sanitizer to 1.6.1 or later.

Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.

Is CVE-2024-53985 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-53985 exists.

Sources

Also known as GHSA-w8gc-x259-rc7x, UBUNTU-CVE-2024-53985.

Is CVE-2024-53985 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free