Skip to content

GHSA-238p-pmpm-9mq7 CVE-2026-103923

KaTeX: Existing prototype pollution can bypass trust restrictions

Low npm
Severity
2.1 / 10
Low · CVSS 4.0
Exploit chance (EPSS)
0.30%
Chance of exploitation in the next 30 days. Higher than 22.69% of scored vulnerabilities.
Known exploited
No
Not in CISA's catalog
Weakness
CWE-807 Reliance on Untrusted Inputs in a Security Decision
Fix
0.18.2
Upgrade katex to this version or later

Description

Impact

KaTeX can act as a read-side prototype pollution gadget in applications where Object.prototype has already been polluted, or where an attacker can influence the prototype of the renderer options object. (KaTeX does not enable said prototype pollution. This advisory applies when combining KaTeX with other vulnerable software that allows for prototype pollution.)

Affected versions may treat inherited properties from Object.prototype as renderer options, internal setting metadata, or namespace entries. In particular, an inherited trust value will be treated as though the application explicitly enabled trusted rendering, rather than using the documented default of false.

With attacker-controlled mathematical expressions, this can produce links capable of user-interaction cross-site scripting or load attacker-selected external resources. Exploitation requires the consuming application to insert KaTeX output into a web page without a separate sanitizer. (KaTeX does not execute scripts merely by rendering an expression.)

Other inherited settings can alter rendering behavior or resource limits. Inherited setting metadata can affect how defaults and supplied options are processed, while inherited namespace properties can be mistaken for defined macros or other internal values.

Patches

Upgrade to KaTeX v0.18.2 to remove this vulnerability.

Workarounds

  • Address any prototype-pollution vulnerability in the application or its dependencies.
  • delete Object.prototype.trust, delete Object.prototype.default, and delete Object.prototype.processor before calling KaTeX
  • Do not allow untrusted input to control the renderer options object or its prototype.
  • Sanitize KaTeX-generated HTML before inserting it into a document.

Details

KaTeX previously used ordinary JavaScript property access in the following contexts:

  • Renderer settings could be inherited from the prototype of the options object.
  • Internal default and processor setting metadata could be inherited from Object.prototype.
  • Namespace lookup could treat inherited properties as built-in definitions.
  • Namespace group restoration could preserve an inherited property as though it had been an explicitly defined value.

The fix adds own-property checks to each of these paths. Inherited properties are no longer accepted as renderer settings, setting metadata, namespace definitions, or values to be restored after a group ends.

For more information

If you have any questions or comments about this advisory:

Affected versions

npm

PackageVulnerableFixed in
katex
>= 0.11.0, < 0.18.2
0.18.2
katex
>= 0.11.0, < 0.18.2
0.18.2

How to fix

Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.

katex npm → 0.18.2

npm
npm install katex@0.18.2
yarn
yarn add katex@0.18.2
pnpm
pnpm add katex@0.18.2

Severity breakdown

CVSS 4.0 2.1

CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N

Attack vector
Network
Attack complexity
Low
Attack requirements
Present
Privileges required
None
User interaction
Active
Confidentiality (vulnerable system)
None
Integrity (vulnerable system)
None
Availability (vulnerable system)
None
Confidentiality (subsequent systems)
Low
Integrity (subsequent systems)
Low
Availability (subsequent systems)
None

Weakness

CWE-807: Reliance on Untrusted Inputs in a Security Decision

The product uses a protection mechanism that relies on the existence or values of an input, but the input can be modified by an untrusted actor in a way that bypasses the protection mechanism.

How to prevent it
  • Architecture and Design: Store state information and sensitive data on the server side only. Ensure that the system definitively and unambiguously keeps track of its own state and user state and has rules defined for legitimate state transitions. Do not allow any application user to affect state directly in any way other than through legitimate actions leading to state transitions. If information must be stored on the client, do not do so without encryption and integrity checking, or otherwise having a mechanism on the server side to catch tampering. Use a message authentication code (MAC) algorithm, such as Hash Message Authentication Code (HMAC) [REF-529]. Apply this against the state or sensitive data that has to be exposed, which can guarantee the integrity of the data - i.e., that the data has not been modified. Ensure that a strong hash function is used (CWE-328).
  • Architecture and Design: Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. With a stateless protocol such as HTTP, use a framework that maintains the state for you. Examples include ASP.NET View State [REF-756] and the OWASP ESAPI Session Management feature [REF-45]. Be careful of language features that provide state support, since these might be provided as a convenience to the programmer and may not be considering security.
  • Architecture and Design: For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
  • Operation, Implementation: When using PHP, configure the application so that it does not use register_globals. During implementation, develop the application so that it does not rely on this feature, but be wary of implementing a register_globals emulation that is subject to weaknesses such as CWE-95, CWE-621, and similar issues.
  • Architecture and Design, Implementation: Understand all the potential areas where untrusted inputs can enter your software: parameters or arguments, cookies, anything read from the network, environment variables, reverse DNS lookups, query results, request headers, URL components, e-mail, files, filenames, databases, and any external systems that provide data to the application. Remember that such inputs may be obtained indirectly through API calls. Identify all inputs that are used for security decisions and determine if you can modify the design so that you do not have to rely on submitted inputs at all. For example, you may be able to keep critical information about the user's session on the server side instead of recording it within external data.

References

Timeline

  1. Published
  2. Last updated by the source
  3. Latest EPSS score
AdvisorySeverityWhy it's related
GHSA-cg87-wmx4-v546
KaTeX \htmlData does not validate attribute names
High Also affects katex
GHSA-3wc5-fcw2-2329
KaTeX missing normalization of the protocol in URLs allows bypassing forbidden protocols
Medium Also affects katex
GHSA-f98w-7cxr-ff2h
KaTeX's `\includegraphics` does not escape filename
Medium Also affects katex
GHSA-cvr6-37gx-v8wc
KaTeX's maxExpand bypassed by Unicode sub/superscripts
Medium Also affects katex
GHSA-64fm-8hw2-v72w
KaTeX's maxExpand bypassed by `\edef`
Medium Also affects katex
GHSA-f9xw-jh8m-3mwq
AIOHTTP: Absolute-form request targets can spoof Request.scheme
Medium Same weakness, CWE-807
GHSA-32gc-64m7-hj7v
9Router has a Login Brute-Force Lockout Bypass via Spoofable X-9r-Real-Ip Header
Medium Same weakness, CWE-807
GHSA-5mj8-gf6m-fhw8
9Router has an Authentication Bypass in Public LLM API via Spoofable X-9r-Real-Ip Header
High Same weakness, CWE-807

Credits: edemaine, grigoriy-reshetniak, joostgrunwald

Is this in your code?

MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.

Check your repos with MergeHarbor