GHSA-fw3g-2h3j-qmm7

Suggest an improvement
Source
https://github.com/advisories/GHSA-fw3g-2h3j-qmm7
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2023/01/GHSA-fw3g-2h3j-qmm7/GHSA-fw3g-2h3j-qmm7.json
JSON Data
https://api.test.osv.dev/v1/vulns/GHSA-fw3g-2h3j-qmm7
Aliases
Published
2023-01-28T01:17:44Z
Modified
2023-11-01T05:01:12.630839Z
Severity
  • 6.1 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N CVSS Calculator
Summary
Improper neutralization of `noscript` element content may allow XSS in Sanitize
Details

Impact

Using carefully crafted input, an attacker may be able to sneak arbitrary HTML through Sanitize >= 5.0.0, < 6.0.1 when Sanitize is configured with a custom allowlist that allows noscript elements. This could result in XSS (cross-site scripting) or other undesired behavior when that HTML is rendered in a browser.

Sanitize's default configs don't allow noscript elements and are not vulnerable. This issue only affects users who are using a custom config that adds noscript to the element allowlist.

Patches

Sanitize >= 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

Credit

Thanks to David Klein from TU Braunschweig (@leeN) for reporting this issue.

Database specific
{
    "nvd_published_at": "2023-01-28T00:15:00Z",
    "github_reviewed_at": "2023-01-28T01:17:44Z",
    "severity": "MODERATE",
    "github_reviewed": true,
    "cwe_ids": [
        "CWE-79"
    ]
}
References

Affected packages

RubyGems / sanitize

Package

Name
sanitize
Purl
pkg:gem/sanitize

Affected ranges

Type
ECOSYSTEM
Events
Introduced
5.0.0
Fixed
6.0.1

Affected versions

5.*

5.0.0
5.1.0
5.2.0
5.2.1
5.2.2
5.2.3

6.*

6.0.0