{"id":"CVE-2020-4054","aliases":["CVE-2020-4054","GHSA-p4x4-rw2p-8j8m"],"related":[],"kind":"vulnerability","state":"published","title":"Cross-site Scripting in Sanitize","summary":"In Sanitize (RubyGem sanitize) greater than or equal to 3.0.0 and less than 5.2.1, there is a cross-site scripting vulnerability. 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. 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. This has been fixed in 5.2.1.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In Sanitize (RubyGem sanitize) greater than or equal to 3.0.0 and less than 5.2.1, there is a cross-site scripting vulnerability. 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. 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. This has been fixed in 5.2.1.","source":"cvelist"},{"lang":"en","text":"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.\n\nYou 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:\n\n- `iframe`\n- `math`\n- `noembed`\n- `noframes`\n- `noscript`\n- `plaintext`\n- `script`\n- `style`\n- `svg`\n- `xmp`\n\n### Impact\n\nUsing 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.\n\n### Releases\n\nThis problem has been fixed in Sanitize 5.2.1.\n\n### Workarounds\n\nIf 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:\n\n```ruby\n%w[iframe math noembed noframes noscript plaintext script style svg xmp]\n```\n\nFor 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:\n\n```ruby\ncustom_config = Sanitize::Config.merge(\n  Sanitize::Config::RELAXED,\n  :remove_contents => %w[iframe math noembed noframes noscript plaintext script style svg xmp]\n)\n```\n\nYou would then pass this custom config to Sanitize when sanitizing HTML.\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n- Open an issue in the [Sanitize repo](https://github.com/rgrove/sanitize).\n- See Sanitize's [security policy](https://github.com/rgrove/sanitize/security/policy).\n\n### Credits\n\nMany thanks to Michal Bentkowski of Securitum for reporting this bug and helping to verify the fix.\n\n### References\n\n- [GHSA-p4x4-rw2p-8j8m](https://github.com/rgrove/sanitize/security/advisories/GHSA-p4x4-rw2p-8j8m)\n- [CVE-2020-4054](https://nvd.nist.gov/vuln/detail/CVE-2020-4054)\n- https://github.com/rgrove/sanitize/releases/tag/v5.2.1","format":"markdown","source":"ghsa"},{"lang":"es","text":"En Sanitize (RubyGem sanitize) versiones mayor o igual a 3.0.0 y menor a 5.2.1, se presenta una vulnerabilidad de tipo cross-site scripting. Cuando se sanea HTML usando la configuración \"relaxed\" de Sanitize, o una configuración personalizada que permite determinados elementos, algún contenido en un elemento math o svg puede no ser saneado correctamente incluso si math y svg no están en la lista de permitidos. Es probable que sea vulnerable a este problema si usa la configuración relaxed de Sanitize o una configuración personalizada que permite uno o más de los siguientes elementos HTML: iframe, math, noembed, noframes, noscript, plaintext, script, style, svg, xmp. Usando entradas cuidadosamente diseñada, un atacante puede infiltrar HTML arbitrario por medio de Sanitize, resultando potencialmente en un ataque de tipo XSS (cross-site scripting) u otro comportamiento no deseado cuando ese HTML es renderizado en un navegador. Esto se ha corregido en la versión 5.2.1","source":"nvd"}],"published":"2020-06-16T22:08:06.000Z","modified":"2026-07-08T06:29:13.144Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L","score":7.3,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L","score":7.3,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L","score":7.3,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L","score":7.3,"rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:M/Au:N/C:P/I:P/A:P","score":6.8,"rating":"MEDIUM"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":">= 3.0.0, < 5.2.1","status":"affected"}],"vendor":"rgrove","product":"Sanitize","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"3.0.0","status":"affected","fixed":"5.2.1"}],"ecosystem":"RubyGems","package":"sanitize","purl":"pkg:gem/sanitize","source":"ghsa"},{"ranges":[{"status":"affected","introduced":"3.0.0","fixed":"5.2.1"}],"vendor":"sanitize_project","product":"sanitize","cpe":"cpe:2.3:a:sanitize_project:sanitize:*:*:*:*:*:ruby:*:*","source":"nvd"}],"references":[{"url":"https://github.com/rgrove/sanitize/security/advisories/GHSA-p4x4-rw2p-8j8m","tags":["third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/rgrove/sanitize/commit/a11498de9e283cd457b35ee252983662f7452aa9","tags":["patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/rgrove/sanitize/releases/tag/v5.2.1","tags":["release-notes","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://www.debian.org/security/2020/dsa-4730","tags":["vendor-advisory","web","x-refsource-debian","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://usn.ubuntu.com/4543-1/","tags":["vendor-advisory","x-refsource-ubuntu","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2020-4054","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/rgrove/sanitize","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/rubysec/ruby-advisory-db/blob/master/gems/sanitize/CVE-2020-4054.yml","tags":["web"],"sources":["ghsa"]},{"url":"https://usn.ubuntu.com/4543-1","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2020-4054","url":"https://www.cve.org/CVERecord?id=CVE-2020-4054","licence":"CVE Terms of Use","modified":"2024-08-04T07:52:20.925Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-p4x4-rw2p-8j8m","url":"https://github.com/advisories/GHSA-p4x4-rw2p-8j8m","licence":"CC-BY-4.0","modified":"2026-07-08T06:29:13.144Z"},{"source":"nvd","name":"NVD","id":"CVE-2020-4054","url":"https://nvd.nist.gov/vuln/detail/CVE-2020-4054","licence":"Public domain","modified":"2026-06-17T03:19:30.063Z"}],"updatedAt":"2026-11-25T22:57:52.990Z","epss":{"score":0.01917,"percentile":0.80476,"date":"2026-12-01T12:00:22.000Z"}}