GitHub Advisoryadvisory · RubyGems
GHSA-fw3g-2h3j-qmm7 Improper neutralization of `noscript` element content may allow XSS in Sanitize
MEDIUM
Official page ↗
- Aliases
- CVE-2023-23627
- Ecosystem
- RubyGems
- Packages
- sanitize
- Severity
- Moderate
- CVSS vector
- CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
- Weaknesses
- CWE-79
- Reviewed
- 2023-01-28
Affected packages
• RubyGems sanitize: >= 5.0.0, < 6.0.1 → fixed in 6.0.1
Description
Impact
Using carefully crafted input, an attacker may be able to sneak arbitrary HTML through Sanitize `>= 5.0.0, = 6.0.1` always removes `noscript` elements and their contents, even when `noscript` is in the allowlist.
Workarounds
Users who are unable to upgrade can prevent this issue by using one of Sanitize's default configs or by ensuring that their custom config does not include `noscript` in the element allowlist.
Details
The root cause of this issue is that HTML parsing rules treat the contents of a `noscript` element differently depending on whether scripting is enabled in the user agent. Nokogiri (the HTML parser Sanitize uses) doesn't support scripting so it follows the "scripting disabled" rules, but a web browser with scripting enabled will follow the "scripting enabled" rules. This means that Sanitize can't reliably make the contents of a `noscript` element safe for scripting enabled browsers. The safest thing to do is to remove the element and its contents entirely, which is now what Sanitize does in version 6.0.1 and later.
References
• Release Notes
Credit
Thanks to David Klein from TU Braunschweig (@leeN) for reporting this issue.
Related
Alias · CVE (1)
- CVE-2023-23627 Sanitize is an allowlist-based HTML and CSS sanitizer. vulnerability
Weakness · CWE (1)
- CWE-79 Improper Neutralization of Input During Web Page Generation weakness
References
- https://github.com/rgrove/sanitize/security/advisories/GHSA-fw3g-2h3j-qmm7 web
- https://nvd.nist.gov/vuln/detail/CVE-2023-23627 advisory
- https://github.com/rgrove/sanitize/commit/ec14265e530dc3fe31ce2ef773594d3a97778d22 web
- https://github.com/rgrove/sanitize package
- https://github.com/rubysec/ruby-advisory-db/blob/master/gems/sanitize/CVE-2023-23627.yml web