GitHub advisory · Packagist
NukeViet CMS: Stored XSS via internal DTD entities in SVG uploads
Description
This is a stored cross-site scripting (XSS) vulnerability. An uploaded SVG can carry a <script> element hidden inside an internal DTD entity; the server-side sanitizer never sees it, stores the file byte-for-byte, and serves it as image/svg+xml, so the script executes in the site's own origin when the file URL is opened in a browser.
The SVG sanitizer sanitize_svg_dom() enumerates elements with DOMXPath::query('//*') and rejects any tag outside an allow-list, so a plain scripted SVG is correctly blocked. The check is bypassed by declaring the script inside an internal DTD entity, because DOMDocument is loaded without LIBXML_NOENT; libxml therefore keeps the reference as a DOMEntityReference node (node type 5, not an element), //* never returns the <script>, and the file passes validation. Browsers parsing image/svg+xml do expand internal entities, so a real <script> element materialises client-side.
A second defect turns the DOM walker into a single point of failure: for SVG uploads check_tmpfile() returns the result of check_svg_tmpfile() before ever calling verify_image(), so the raw-byte screen that greps for a literal <script> never runs on an SVG - its if ($svg and preg_match(...)) branch is unreachable because no caller passes $svg = true. Finally, the admin upload handler skips all image re-processing when the file is an SVG, so the attacker's exact bytes are what land on disk.
Who is impacted: any site running an affected version that accepts SVG uploads. The most severe entry point is unauthenticated: when a module's comment feature is opened to the "All" or "Guest" group (a standard, supported option for public sites) and comment attachments are enabled (allowattachcomm), a guest with no account can upload the SVG, because the default extension set includes the images group and the images group includes svg. The same applies to any front-end submission flow whose plan permits image…
Manual fix · Packagist
composer require "nukeviet/nukeviet:^4.5.12"Sources