GHSA-238p-pmpm-9mq7: Npm/katex vulnerability

Published Oct 5, 2026
·
Updated

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

Affected Software

1 affected componentFixes available
npm/katex>=0.11.0<0.18.2
0.18.2

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade npm/katex to a version that resolves this vulnerability.

    Fixed in 0.18.2
  2. Upgrade

    Upgrade KaTeX to a version that resolves this vulnerability.

    Fixed in 0.18.2
  3. Compensating control

    Do not allow untrusted input to control the renderer options object or its prototype.

  4. Compensating control

    Sanitize KaTeX-generated HTML before inserting it into a document.

  5. Compensating control

    Before calling KaTeX, delete Object.prototype.trust, Object.prototype.default, and Object.prototype.processor.

Event History

Oct 5, 2026
Advisory Published
via GitHub·11:41 PM
Data Sourced
via GitHub·11:41 PM
DescriptionWeaknessAffected Software

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203