Loading...
Skip to main content

CVE-2020-4054 — Cross-site Scripting in sanitize — CVE Details

HIGH

Cross-site Scripting in Sanitize

Published June 16, 2020Updated July 8, 2026Source: osv

Summary

When HTML is sanitized using Sanitize's "relaxed" config or a custom config that allows certain elements, some content in a `<math>` or `<svg>` element may not be sanitized correctly even if `math` and `svg` are not in the allowlist. You are likely to be vulnerable to this issue if you use Sanitize's relaxed config or a custom config that allows one or more of the following HTML elements: - `iframe` - `math` - `noembed` - `noframes` - `noscript` - `plaintext` - `script` - `style` - `svg` - `xmp` ### Impact Using carefully crafted input, an attacker may be able to sneak arbitrary HTML through Sanitize, potentially resulting in XSS (cross-site scripting) or other undesired behavior when that HTML is rendered in a browser. ### Releases This problem has been fixed in Sanitize 5.2.1. ### Workarounds If upgrading is not possible, a workaround is to override the default value of Sanitize's `:remove_contents` config option with the following value, which ensures that the contents of `math` and `svg` elements (among others) are removed entirely when those elements are not in the allowlist: ```ruby %w[iframe math noembed noframes noscript plaintext script style svg xmp] ``` For example, if you currently use Sanitize's relaxed config, you can create a custom config object that overrides the default value of `:remove_contents` like this: ```ruby custom_config = Sanitize::Config.merge( Sanitize::Config::RELAXED, :remove_contents => %w[iframe math noembed noframes noscript plaintext script style svg xmp] ) ``` You would then pass this custom config to Sanitize when sanitizing HTML. ### For more information If you have any questions or comments about this advisory: - Open an issue in the [Sanitize repo](https://github.com/rgrove/sanitize). - See Sanitize's [security policy](https://github.com/rgrove/sanitize/security/policy). ### Credits Many thanks to Michal Bentkowski of Securitum for reporting this bug and helping to verify the fix. ### References - [GHSA-p4x4-rw2p-8j8m](https://github.com/rgrove/sanitize/security/advisories/GHSA-p4x4-rw2p-8j8m) - [CVE-2020-4054](https://nvd.nist.gov/vuln/detail/CVE-2020-4054) - https://github.com/rgrove/sanitize/releases/tag/v5.2.1

Advisory Timeline

  • First published June 16, 2020 (2309 days ago).
  • Last revised July 8, 2026 — 2212 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

Bundler
Update sanitize to 5.2.1 or later
gem install sanitize -v 5.2.1

After upgrading, run your dependency scanner again to confirm the vulnerability is resolved.

Affected Packages (1)

Affects 1 ecosystem: rubygems (1).

PackageEcosystemAffectedFixed In
sanitize
rubygems
3.0.0, 3.0.1, 3.0.2, 3.0.3 (+21 more)5.2.1

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

  • CWE-79
    Cross-site Scripting (XSS)MITRE

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 7.3 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
Low
Availability
Low

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L

Frequently Asked Questions

What is CVE-2020-4054?
Cross-site Scripting in Sanitize This vulnerability has been assigned a severity rating of HIGH (CVSS score: 7.3/10).
How do I check if my project is affected by CVE-2020-4054?
CVE-2020-4054 affects sanitize. Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2020-4054 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
7.3

High exploitability or significant impact. Prioritize remediation within days.

Also Known As

GHSA-p4x4-rw2p-8j8m

Related CVEs

  • CVE-2026-94462
    HIGH

    Spree: Broken Access Control in `PATCH /api/v3/store/carts/:id/associate` (IDOR)

  • CVE-2018-3740
    HIGH

    Sanitize vulnerable to Improper Input Validation and Cross-site Scripting

  • CVE-2023-36823
    HIGH

    Sanitize vulnerable to Cross-site Scripting via insufficient neutralization of `style` element content

  • CVE-2026-77601
    HIGH

    OpenC3 COSMOS: Authenticated OS command injection via the `pypi_url` setting

  • CVE-2023-23627
    MEDIUM

    Improper neutralization of `noscript` element content may allow XSS in Sanitize

Check if you're affected

Scan your dependencies to see if this vulnerability affects your projects.

Scan Your Dependencies