Categories
CVE-2020-4054

Cross-Site Scripting (XSS) in sanitize (CVE-2020-4054)

Summary

Cross-site scripting in sanitize (CVE-2020-4054). Risk of unauthorized operations or information disclosure. Exploitable via math. Mitigation: upgrade to 5.2.1 or later.

Original description

The description as published by the source.

When HTML is sanitized using Sanitize's "relaxed" config or a custom config that allows certain elements, some content in a or 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:

%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:

custom_config = Sanitize::Config.merge(
  Sanitize::Config::RELAXED,
  :remove_contents => %w[iframe math noembed noframes noscript plaintext sc…

Source: OSV.dev (Open Source Vulnerabilities) NVD GitHub Advisory OSV

Auto-generated summary

Assembled by SecPulse from the source data (CVSS, CWE, affected versions) using templates — no AI involved. Check the original description and references below for exact details.

A vulnerability tracked as CVE-2020-4054 has been found in sanitize.
Attackers can target a specific entry point like math over the network to misuse the product.
Risk of unauthorized operations or information disclosure.
What to do: upgrade sanitize to 5.2.1 or later.
If unsure, ask your IT team or search "sanitize CVE-2020-4054" on the vendor's site.

CVE-2020-4054 (sanitize) — CWE-79
Attack vector: remote (network-reachable) / unauthenticated / no user interaction
Attack surface: math / svg / iframe / noembed
Patched: 5.2.1 — apply immediately
Plan: 1) Audit SBOM/dependencies, 2) Stage→prod upgrade, 3) Add WAF/proxy monitoring on affected endpoints, 4) Hunt IOCs in logs.
Refs: see the GHSA / vendor advisory / patched release linked on this page.

❓ What is the problem

Cross-site scripting (XSS) (CWE-79) exists in sanitize. Attackers reach the vulnerable code path via math without authentication.

📍 Affected scope

Check the vendor advisory for the affected versions of sanitize. Attack surface: math / svg / iframe / noembed.

🔥 Severity

Severity: ?. Risk of unauthorized operations or information disclosure.

🔧 How to fix

Update to 5.2.1.

🛡️ Workaround

Until the patch is applied: disable the affected feature, apply WAF rules, or restrict access via network ACLs.

🔍 Detection

Search webserver/proxy logs for unusual request patterns matching this CVE's known IOCs. Run grep -r 'sanitize' . against your dependency files (package-lock.json, requirements.txt, go.sum) to find affected services.

Response actions

Concrete steps and command examples for SOC/SRE teams to execute in order

  1. 1
    Identify exposure identify
    grep -r 'sanitize' . | grep -v node_modules

    リポジトリと本番環境の依存ファイル (package-lock.json / requirements.txt / go.sum / Gemfile.lock 等) で sanitize を grep し、稼働しているサービス・バージョンを把握する。

  2. 2
    Apply patch patch
    Upgrade sanitize to 5.2.1

    ステージング環境で 5.2.1 に上げて回帰テスト → 本番反映。回帰テストはアプリの主要ハッピーパスを含めること。

  3. 3
    Post-deployment verification verify
    Confirm patched version is live in production

    パッチ適用後、ステージングで PoC または同等の悪用パターンを再現して脆弱性が閉じたことを確認。本番ではアクセスログ・WAF でアラート再発が無いか継続監視。

Affected packages

RubyGems sanitize
[{"type":"ECOSYSTEM","events":[{"introduced":"3.0.0"},{"fixed":"5.2.1"}]}]

References

We use cookies for analytics and ad measurement. This setting applies to all Game co., Ltd. sites. Details