{ "schema_version": "1.4.0", "id": "GHSA-3wc5-fcw2-2329", "modified": "2024-03-25T22:32:09Z", "published": "2024-03-25T19:38:37Z", "aliases": [ "CVE-2024-28246" ], "summary": "KaTeX missing normalization of the protocol in URLs allows bypassing forbidden protocols", "details": "### Impact\n\nCode that uses KaTeX's `trust` option, specifically that provides a function to block-list certain URL protocols, can be fooled by URLs in malicious inputs that use uppercase characters in the protocol. In particular, this can allow for malicious input to generate `javascript:` links in the output, even if the `trust` function tries to forbid this protocol via `trust: (context) => context.protocol !== 'javascript'`.\n\n### Patches\nUpgrade to KaTeX v0.16.10 to remove this vulnerability.\n\n### Workarounds\n* Allow-list instead of block protocols in your `trust` function.\n* Manually lowercase `context.protocol` via `context.protocol.toLowerCase()` before attempting to check for certain protocols.\n* Avoid use of or turn off the `trust` option.\n\n\n### Details\nKaTeX did not normalize the `protocol` entry of the `context` object provided to a user-specified `trust`-function, so it could be a mix of lowercase and/or uppercase letters.\n\nIt is generally better to allow-list by protocol, in which case this would normally not be an issue. But in some cases, you might want to block-list, and the [KaTeX documentation](https://katex.org/docs/options.html) even provides such an example:\n\n> Allow all commands but forbid specific protocol: `trust: (context) => context.protocol !== 'file'`\n\nCurrently KaTeX internally sees `file:` and `File:` URLs as different protocols, so `context.protocol` can be `file` or `File`, so the above check does not suffice. A simple workaround would be:\n\n> `trust: (context) => context.protocol.toLowerCase() !== 'file'`\n\nMost URL parsers normalize the scheme to lowercase. For example, [RFC3986](https://datatracker.ietf.org/doc/html/rfc3986#section-3.1) says:\n\n> Although schemes are case-insensitive, the canonical form is lowercase and documents that specify schemes must do so with lowercase letters. An implementation should accept uppercase letters as equivalent to lowercase in scheme names (e.g., allow \"HTTP\" as well as \"http\") for the sake of robustness but should only produce lowercase scheme names for consistency.\n", "severity": [ { "type": "CVSS_V3", "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:L/A:L" } ], "affected": [ { "package": { "ecosystem": "npm", "name": "katex" }, "ranges": [ { "type": "ECOSYSTEM", "events": [ { "introduced": "0.11.0" }, { "fixed": "0.16.10" } ] } ] } ], "references": [ { "type": "WEB", "url": "https://github.com/KaTeX/KaTeX/security/advisories/GHSA-3wc5-fcw2-2329" }, { "type": "ADVISORY", "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-28246" }, { "type": "WEB", "url": "https://github.com/KaTeX/KaTeX/commit/fc5af64183a3ceb9be9d1c23a275999a728593de" }, { "type": "PACKAGE", "url": "https://github.com/KaTeX/KaTeX" } ], "database_specific": { "cwe_ids": [ "CWE-184" ], "severity": "MODERATE", "github_reviewed": true, "github_reviewed_at": "2024-03-25T19:38:37Z", "nvd_published_at": "2024-03-25T20:15:08Z" } }