Skip to content

KaTeX \htmlData does not validate attribute names

Moderate severity GitHub Reviewed Published Jan 17, 2025 in KaTeX/KaTeX • Updated Jan 17, 2025

Package

npm katex (npm)

Affected versions

>= 0.12.0, <= 0.16.20

Patched versions

0.16.21

Description

Impact

KaTeX users who render untrusted mathematical expressions with renderToString could encounter malicious input using \htmlData that runs arbitrary JavaScript, or generate invalid HTML.

Patches

Upgrade to KaTeX v0.16.21 to remove this vulnerability.

Workarounds

  • Avoid use of or turn off the trust option, or set it to forbid \htmlData commands.
  • Forbid inputs containing the substring "\\htmlData".
  • Sanitize HTML output from KaTeX.

Details

\htmlData did not validate its attribute name argument, allowing it to generate invalid or malicious HTML that runs scripts.

For more information

If you have any questions or comments about this advisory:

References

@edemaine edemaine published to KaTeX/KaTeX Jan 17, 2025
Published to the GitHub Advisory Database Jan 17, 2025
Reviewed Jan 17, 2025
Last updated Jan 17, 2025

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
Low
Availability
Low

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L

Weaknesses

CVE ID

CVE-2025-23207

GHSA ID

GHSA-cg87-wmx4-v546

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.