CVE-2026-103923: KaTeX: Existing prototype pollution can bypass trust restrictions
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:
- Open an issue or security advisory in the KaTeX repository - Email us at katex-security@mit.edu
Other sources
KaTeX is a fast, easy-to-use JavaScript library for TeX math rendering on the web. From 0.11.0 until 0.18.2, KaTeX uses ordinary JavaScript property access for the renderer options object, the trust setting, default and processor setting metadata, and namespace lookup and group restoration, allowing inherited properties to be treated as explicitly supplied values. When Object.prototype is already polluted or an attacker controls the options object's prototype, attacker-controlled mathematical expressions can use an inherited trust value to enable trusted rendering and produce links capable of user-interaction cross-site scripting or loading attacker-selected external resources in a consuming application that inserts unsanitized KaTeX output into a page. KaTeX does not itself create the prototype pollution, and rendering an expression alone does not execute script. This issue is fixed in version 0.18.2.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
npm/katexto a version that resolves this vulnerability.Fixed in 0.18.2 - Upgrade
Upgrade
KaTeXto a version that resolves this vulnerability.Fixed in 0.18.2 - Configuration
Delete Object.prototype.trust, Object.prototype.default, and Object.prototype.processor before calling KaTeX.
JavaScript Object.prototype trust, default, processor = deleted - Compensating control
Sanitize KaTeX-generated HTML before inserting it into a document.
- Compensating control
Do not allow untrusted input to control the renderer options object or its prototype.
Event History
Frequently Asked Questions
What conditions are required for exploitation?
Object.prototype must already be polluted, or the attacker must control the prototype of the KaTeX renderer options object. The attacker must also be able to supply mathematical expressions, and the consuming application must insert unsanitized KaTeX output into a page.
What is the practical impact of a successful bypass?
An inherited trust value can enable trusted rendering, allowing expressions to produce links that can lead to user-interaction cross-site scripting or cause the application to load attacker-selected external resources. Rendering an expression by itself does not execute script.
Are applications using default KaTeX behavior directly exposed?
The issue depends on inherited properties being treated as explicitly supplied values; KaTeX does not create the required prototype pollution itself. Applications are exposed when a polluted global prototype or attacker-controlled options-object prototype can influence rendering.
What should be done if upgrading cannot happen immediately?
Prevent and remediate prototype pollution in the application and ensure untrusted users cannot control the prototype of KaTeX options objects. Avoid inserting unsanitized KaTeX output into pages where attacker-controlled expressions are rendered.
Which versions require remediation?
KaTeX versions from 0.11.0 through 0.18.2 are identified as affected. The issue is fixed in version 0.18.2.