GHSA-FFMJ-5CGG-P842
Stored XSS: JSX templates insert string props into Nunjucks blocks unescaped
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-FFMJ-5CGG-P842 divulgada · CVSS 5.4 (GitHub) | |
| Divulgación | Modificada | Última actualización del registro | |
| Remediación | Parche 4.34.1 | apostrophe · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
When a JSX template extends a Nunjucks template with `<Extend>`, each prop overrides the Nunjucks block of the same name. A prop that is a plain string is inserted into the block without escaping. Everywhere else in JSX, and in a Nunjucks block that outputs `{{ value }}`, the same string would be escaped.
The pattern documented for JSX projects passes the page title this way:
<Extend templateName={outerLayout} title={page.title} main={...} />Core's `outerLayout.html` is Nunjucks, so every JSX project's layout extends a Nunjucks template. Anyone who can edit a page or piece title can therefore set a title such as `</title><script>...</script>`, and the script runs for every visitor to that page, including administrators. The `bodyClass` block sits inside the `class` attribute of `<body>`, so a string with a quote there escapes the attribute too.
Affected
- `apostrophe` 4.31.0 and later, when JSX templates are used.
- Only string props passed through `<Extend>` to a Nunjucks template. JSX elements and fragments (`title={<>{page.title}</>}`) were always escaped, as were JSX-to-JSX templates.
- Exploitation needs an account that can edit content which reaches such a prop, such as a page or piece title.
Fix
String props are now escaped, as Nunjucks escapes `{{ value }}`, including quotes, since some blocks sit in attribute values. Markup is passed as a JSX element or fragment, or as a string marked with `apos.template.safe()`, which already passed through unescaped. A plain object passed to a block is written as HTML attributes with escaped values, for blocks such as `extraHtml` inside the `<html>` tag: `extraHtml={{ 'data-theme': 'dark' }}`.
A project that deliberately passes HTML elements to a block should use the `{<element>...</.element>}` or `{<>...</>}` syntax. A project that deliberately passes raw HTML attributes and not complete elements must now wrap it with `apos.template.safe()` or use the object form.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npmapostrophe |
Corregida | 4.34.1 | 0 d | 4.34.1 no afectada |
4.34.1Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/apostrophecms/apostrophe/security/advisories/GHSA-ffmj-5cgg-p842Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
