CVE-2024-28246: Katex KaTeX Missing Normalization Of The Vulnerability

MODERATE
Advisory Identifier: GHSA-3wc5-fcw2-2329
CVSS 5.5
CWE-184
Published
Advisory Summary

CVE-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

CVE Identifier CVE-2024-28246
GHSA Identifier GHSA-3wc5-fcw2-2329
Severity MODERATE
CVSS v3.1 Base Score 5.5
CWE Classification CWE-184: Incomplete List of Disallowed Inputs
Affected Product Katex
Package Ecosystem npm
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability Low (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.

katex fixed: 0.16.10
npm install katex@0.16.10
Verify Direct and Transitive Dependencies

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

### Impact Code 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'`. ### Patches Upgrade to KaTeX v0.16.10 to remove this vulnerability. ### Workarounds * Allow-list instead of block protocols in your `trust` function. * Manually lowercase `context.protocol` via `context.protocol.toLowerCase()` before attempting to check for certain protocols. * Avoid use of or turn off the `trust` option. ### Details KaTeX 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. It 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: > Allow all commands but forbid specific protocol: `trust: (context) => context.protocol !== 'file'` Currently 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: > `trust: (context) => context.protocol.toLowerCase() !== 'file'` Most URL parsers normalize the scheme to lowercase. For example, [RFC3986](https://datatracker.ietf.org/doc/html/rfc3986#section-3.1) says: > 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.

CVE-2024-28246 Affected Katex Versions

1 component(s)
Fixed Versions:
0.16.10
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?
CVE-2024-28246 is a security vulnerability in Katex involving KaTeX missing normalization of the protocol in URLs allows bypassing forbidden protocols under CWE-184: Incomplete List of Disallowed Inputs.
Which Katex versions are affected?
Affected versions include releases prior to 0.16.10 across affected packages: katex.
What version fixes CVE-2024-28246?
Upgrading to 0.16.10 (or the latest patched release for your respective branch) resolves the vulnerability.
Is katex affected?
Yes, katex is affected in releases prior to 0.16.10. Upgrade your dependency to 0.16.10 or later.
What is the CVSS score of CVE-2024-28246?
CVE-2024-28246 has a CVSS v3.1 base score of 5.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:L/A:L.
What CWE is associated with CVE-2024-28246?
CVE-2024-28246 is classified under CWE-184: Incomplete List of Disallowed Inputs (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.).
How can I check npm dependencies for CVE-2024-28246?
Run the dependency tree command: 'npm ls katex'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}