GHSA-WJPM-J8R9-F6WR
Stored XSS via SVG file upload
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-WJPM-J8R9-F6WR divulgada · CVSS 5.4 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
NukeViet CMS versions prior to 4.5 (patched commit `52a1cc4`) allow authenticated users with file upload permissions to upload SVG files containing embedded JavaScript. When the SVG is served as `image/svg+xml` and rendered inline in an article, the browser executes the script in the context of the CMS domain — a Stored Cross-Site Scripting (XSS) vulnerability.
Affected Component
`vendor/vinades/nukeviet/Files/Upload.php` — `check_svg_tmpfile()` and `verify_image()`
Vulnerability Details
The original implementation used `simplexml_load_file()` to parse uploaded SVGs and applied only a regex blacklist to block event handlers. This approach was bypassable via multiple vectors:
- Event handler attributes: `onload=`, `onmouseover=`, etc.
- `<script>` and `<foreignObject>` tags: embedding arbitrary HTML/JS
- Namespace injection: `<html:script xmlns:html="http://www.w3.org/1999/xhtml">`
- Processing instructions: `<?xml-stylesheet type="text/javascript" href="...">` to load external JS
- SMIL animation: `<animate attributeName="onload" to="alert(1)">` injecting event handlers
- XXE (PHP < 8.0): `<!ENTITY xxe SYSTEM "file:///etc/passwd">` — arbitrary local file read via external entity expansion
Attack Scenario
- An attacker with editor/contributor access crafts a malicious SVG:
- The file passes the original validation and is saved to the uploads directory.
- The attacker embeds the SVG in a published article.
- Any visitor (including administrators) who views the article triggers the payload, exfiltrating their session cookie.
Impact
- Session hijacking (including administrator accounts)
- Credential theft
- Defacement / malicious redirects
- On PHP 5.6–7.x without the fix: arbitrary local file read via XXE
Patches
Fixed in commit `52a1cc4e0`. The patch replaces the regex-blacklist approach with:
- DOMDocument whitelist validation (`sanitize_svg_dom()`) — rejects any element or attribute not on an explicit allowlist; blocks `on*` event handlers, dangerous tags (`<script>`, `<foreignObject>`, `<iframe>`), namespace-prefixed elements, and processing instructions.
- XXE protection — `libxml_disable_entity_loader(true)` for PHP < 8.0 combined with `LIBXML_NONET`, preventing both `file://` and network entity expansion.
- Defense-in-depth regex in `verify_image()` — catches raw `on*=` patterns before DOM parsing.
- CSS injection checks (`svg_css_is_dangerous()`) — blocks `@import`, `url(https?:...)`, `-moz-binding`, and `expression()` in `style` attributes and `<style>` elements.
- `X-Content-Type-Options: nosniff` header applied to `.svg` files via `.htaccess`.
Workaround
If upgrading is not immediately possible, disable SVG uploads by removing `svg` from the list of allowed file extensions in the NukeViet admin panel.
References
- CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
- CWE-611: Improper Restriction of XML External Entity Reference
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistnukeviet/nukeviet |
Sin parche | — | — | — |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/nukeviet/nukeviet/security/advisories/GHSA-wjpm-j8r9-f6wrLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
