The vulnerability is a stored Cross-Site Scripting (XSS) issue in the module title, which corresponds to the module's 'Header' and 'Footer' in the codebase. An authenticated user with permissions to edit module settings could inject malicious JavaScript into these fields.
The analysis of the patch commit 4a4bcbcdf3cedbf702816f8168c4d51bf688f7f6 reveals two key areas where the vulnerability existed and was subsequently fixed:
-
Input Storage: The DotNetNuke.Modules.Admin.Modules.ModuleSettings.OnUpdateClick method in Modulesettings.ascx.cs is responsible for saving the module settings. Prior to the patch, this method directly saved the content of the header and footer text boxes (txtHeader.Text, txtFooter.Text) into the database without sanitization. This is the entry point for the malicious script.
-
Data Retrieval and Display: The DotNetNuke.Entities.Tabs.TabModulesController.GetTabModules method in TabModulesController.cs retrieves module information to be displayed on a page. Before the patch, this method did not sanitize the header and footer content retrieved from the database. This unsanitized data would then be rendered on the client-side, leading to the execution of the stored script.
The patch addresses the vulnerability by introducing sanitization at both points. It adds server-side validation in OnUpdateClick to check for and reject JavaScript if it's disallowed. It also adds a sanitization step in GetTabModules to clean the data before it's sent to the client for rendering, using the newly added HtmlUtils.SanitizeHtmlIfNeeded function. The frontend code was also updated to use a sanitized HTML rendering component instead of the dangerous dangerouslySetInnerHTML React property, providing defense-in-depth.