The vulnerability is a stored cross-site scripting (XSS) issue within HAX CMS, specifically in the saveManifest and saveNode operations. The core problem was the insufficient sanitization of user-supplied input before it was stored and subsequently rendered on the website.
The saveManifest function (located in system/backend/php/lib/Operations.php) handled various site configuration parameters, such as domain names, logo URLs, theme settings, and author information. The patch shows that many of these parameters were previously processed using FILTER_UNSAFE_RAW, which does not perform any sanitization, thus allowing malicious scripts to be embedded. The fix involved replacing FILTER_UNSAFE_RAW with more appropriate sanitization filters like FILTER_SANITIZE_URL for URLs, FILTER_SANITIZE_STRING for general strings, and FILTER_SANITIZE_EMAIL for email addresses.
The saveNode function (also in system/backend/php/lib/Operations.php) is responsible for saving page content. The vulnerability here stemmed from insufficiently sanitizing the description and developer-theme attributes of a page. The patch introduced strip_tags() for the description field to remove any HTML tags and changed FILTER_UNSAFE_RAW to FILTER_SANITIZE_STRING for the developer-theme field. This prevents attackers from injecting scripts through these inputs, for example, by using the 'View Source' feature in the editor or directly manipulating POST request parameters.
Additional changes in the commit, such as path validation in HAXCMSSite.php and JSONOutlineSchemaItem.php (e.g., validatePageLocation, readLocation, writeLocation), and sanitization in functions like jsonFeedFormat, lunrSearchIndex, getPageContent, and getSiteMetadata, serve as defense-in-depth measures. These changes help prevent path traversal and ensure that data retrieved or processed by these functions is also sanitized, mitigating the risk of XSS or other injection attacks that could arise from rendering previously stored malicious content or from direct manipulation of file paths. However, the primary entry points for the stored XSS, as described in the advisory and addressed by the most direct sanitization changes, are the and functions.