CVE-2024-28246: Katex KaTeX Missing Normalization Of The Vulnerability
MODERATECVE-2024-28246 is a MODERATE (CVSS 5.5) katex missing normalization of the vulnerability (CWE-184: Incomplete List of Disallowed Inputs) affecting Katex libraries in the npm ecosystem. The issue involves katex missing normalization of the protocol in urls allows bypassing forbidden protocols. Remediation is available by upgrading affected packages to version 0.16.10.
CVE-2024-28246 at a Glance
Security Impact
CVSS: 5.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:L/A:L).
How to Fix CVE-2024-28246
To remediate this vulnerability, upgrade all affected Katex dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install katex@0.16.10
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls katex
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2024-28246, inspect your project dependencies using npm:
npm ls katex
Analyze the terminal output to locate any version of Katex in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.16.10), your application is affected.
Note: The npm ls katex command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-184: Incomplete List of Disallowed Inputs, where the product implements a protection mechanism that relies on a list of inputs (or properties of inputs) that are not allowed by policy or otherwise require other action to neutralize before additional processing takes place, but the list is incomplete. In Katex, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2024-28246 Affected Katex Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
katex
|
npm |
≥ 0.11.0
< 0.16.10
|
0.16.10
|
References
Frequently Asked Questions
What is CVE-2024-28246?
Which Katex versions are affected?
What version fixes CVE-2024-28246?
Is katex affected?
What is the CVSS score of CVE-2024-28246?
What CWE is associated with CVE-2024-28246?
How can I check npm dependencies for CVE-2024-28246?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}