CVE-2025-52561
JSON

6.9medium

HTMLSanitizer.jl Possible XSS

Severity
6.9medium CVSS:4.0 by GitHub_M
Exploit likelihood
0.92% (higher than 61% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
JLSEC-2025-39GHSA-3mj7-qxh9-6q4p

Description

HTMLSanitizer.jl is a Whitelist-based HTML sanitizer. Prior to version 0.2.1, when adding the style tag to the whitelist, content inside the tag is incorrectly unescaped, and closing tags injected as content are interpreted as real HTML, enabling tag injection and JavaScript execution. This could result in possible cross-site scripting (XSS) in any HTML that is sanitized with this library. This issue has been patched in version 0.2.1. A workaround involves adding the math and svg elements to the whitelist manually.

Affected

Product or packageVersionsReported by
JuliaComputing HTMLSanitizer.jl< 0.2.1CVE List
HTMLSanitizer (Julia)before 0.2.1Julia Security Advisories

All scores

GitHub_M6.9medium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:N/SI:L/SA:N
Julia Security AdvisoriesNot scored CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:N/SI:L/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X

Classification

CWE-79

SSVC (CISA-ADP): exploitation none, automatable yes, technical impact partial.

What each source says

CVE List

HTMLSanitizer.jl is a Whitelist-based HTML sanitizer. Prior to version 0.2.1, when adding the style tag to the whitelist, content inside the tag is incorrectly unescaped, and closing tags injected as content are interpreted as real HTML, enabling tag injection and JavaScript execution. This could result in possible cross-site scripting (XSS) in any HTML that is sanitized with this library. This issue has been patched in version 0.2.1. A workaround involves adding the math and svg elements to the whitelist manually.

Julia Security Advisories
Description

When adding the style tag to the whitelist, content inside the tag is incorrectly unescaped, and closing tags injected as content are interpreted as real HTML, enabling tag injection and JavaScript execution.

This behavior is similar to the sanitization bypass described in CVE-2020-4054 (Sanitize for Ruby).

using HTMLSanitizer

user_input = "<svg><style>&lt;/style>&lt;img src onerror=alert(1)>"

whitelist = deepcopy(HTMLSanitizer.WHITELIST)
append!(whitelist[:elements], ["style"])
result = sanitize(user_input, whitelist=whitelist)
print(result) # <style></style><img src onerror=alert(1)></style>
Impact

Possible XSS in any HTML that is sanitized with this library.

Patches

Users should upgrade to v0.2.1 as soon as possible. In this version, svg and math tags are removed by default.

Workarounds

Add the math and svg elements to your whitelist manually via e.g.

whitelist = deepcopy(HTMLSanitizer.WHITELIST)
append!(whitelist[:removed_elements], ["math", "svg"])

and pass this modified whitelist to sanitize:

sanitize(user_input, whitelist=whitelist)
References

PR for fix

Credits

Thanks to Chen T for finding and reporting this issue.

NVD (es)

HTMLSanitizer.jl es un depurador de HTML basado en listas blancas. Antes de la versión 0.2.1, al añadir la etiqueta de estilo a la lista blanca, el contenido dentro de la etiqueta se eliminaba incorrectamente del escape, y las etiquetas de cierre inyectadas como contenido se interpretaban como HTML real, lo que permitía la inyección de etiquetas y la ejecución de JavaScript. Esto podía provocar cross-site scripting (XSS) en cualquier HTML depurado con esta librería. Este problema se ha corregido en la versión 0.2.1. Una solución alternativa consiste en añadir manualmente los elementos math y SVG a la lista blanca.

References

Sources

SourceRecordLicence
CVE ListCVE-2025-52561 changed 2025-06-24CVE Terms of Use
Julia Security AdvisoriesJLSEC-2025-39 changed 2026-07-18CC-BY-4.0
NVDCVE-2025-52561 changed 2026-06-17Public domain