# NukeViet CMS: Stored XSS via internal DTD entities in SVG uploads

NukeViet's SVG sanitizer parses without LIBXML_NOENT, so a <script> hidden in an internal DTD entity survives validation and executes in the site origin when the stored SVG is opened.

- Payout: Research
- Severity: critical
- Program: NukeViet
- Found by: hoanggxyuuki, NguyenHuyTrung
- Disclosed: 2026-11-30
- CVE: CVE-2026-94567
- Write-up quality: 8/10
- Original: https://github.com/advisories/GHSA-cp55-wmv6-wxpp
- Library page: https://bugbountylibrary.com/r/ghsa%3AGHSA-cp55-wmv6-wxpp
- Tags: area:web domain:web impact:ato impact:privesc kind:research platform:ghsa sev:critical tech:php technique:parser-differential technique:source-review vuln:file-upload vuln:xss

**Target:** SVG file upload / sanitizer (Files/Upload.php)
**Root cause:** check_svg_tmpfile() loads the SVG with DOMDocument::load(..., LIBXML_NONET) without LIBXML_NOENT, so internal DTD entities stay as DOMEntityReference nodes that the //* allow-list walk never inspects; the file is stored byte-for-byte and served as image/svg+xml, where browsers do expand the entity into a live <script>.
**Steps:**
1. Craft `poc.svg` with `<!DOCTYPE svg [ <!ENTITY payload "<script>alert('XSS on '+document.domain)</script>"> ]>` and `&payload;` inside the `<svg>` body.
2. Upload via `POST /admin/index.php?nv=upload&op=upload` with `type=image` as any module admin, or via a front-end comment/banner attachment where `allowattachcomm` and guest comment groups are enabled.
3. Sanitizer's `//*` walk sees only `<svg>`/`<rect>`; `verify_image()` raw-byte grep is dead code for SVG (`$svg` defaults false), so the file is accepted and stored unchanged.
4. Open `/uploads/<name>.svg` in a browser: the internal entity expands to a real `<script>` and executes in the site origin.
**How found:** Noticed the sanitizer enumerates elements via DOMXPath `//*` and hypothesized that a node type not returned by `//*` (an entity reference) would evade the allow-list; confirmed by comparing a plain `<script>` SVG (rejected) against the same script declared as an internal DTD entity (accepted), then verified browser-side expansion.
**Exploitation:** Attacker uploads the entity-smuggled SVG through an unauthenticated comment attachment (guest group + allowattachcomm) or as a module admin via the file manager, then sends the /uploads/...svg link to a victim (e.g. site admin); the script runs with the victim's session in the site origin, yielding account takeover / privilege escalation from module admin to site admin. No CSP or Content-Disposition on uploads to contain it.
**Escalation:** Module-admin upload path escalates to site-admin by targeting an administrator with the stored link; unauthenticated guest comment attachment widens reach to any visitor.
**Insight:** When an upload sanitizer walks a parsed DOM with `//*`, check whether the parser expands entities/CDATA/comments — anything not materialized as an element node (DOMEntityReference, type 5) is invisible to the allow-list but visible to the browser; also check whether a raw-byte fallback is actually reachable from the SVG code path.

## Proof of concept (copied exactly from the original report)

**SVG with script hidden in DTD entity**

```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg [
  <!ENTITY payload "<script>alert('XSS on '+document.domain)</script>">
]>
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200">
  <rect width="200" height="200" fill="#eee"/>
  &payload;
</svg>
```

**Upload request to admin file manager**

```
Upload the file through the admin file manager (`POST /admin/index.php?nv=upload&op=upload`, `type=image`) as any module admin, or via a front-end comment/banner attachment where enabled. It is accepted and stored unchanged.
```

