The vulnerability is a stored Cross-Site Scripting (XSS) issue within the MoonShine admin panel, primarily affecting the 'Create Article' functionality via a malicious 'Link' parameter. The root cause is the failure to properly sanitize user-provided input before rendering it in HTML.
The investigation of the patch commit f108f4ea5c0d66e8172c2dc397c1d9a6f466d9c6 reveals several points where output escaping was missing. The most critical functions identified are:
-
MoonShine\UI\Components\Link::prepareBeforeRender: This is the core of the vulnerability. This function constructs a link but failed to escape the href attribute, allowing an attacker to inject a javascript: payload, which would be executed when a user clicks the link.
-
MoonShine\UI\Fields\Url::resolvePreview: This function is responsible for displaying the stored URL. It uses the Link component to render the output. An attacker could save a malicious script as a URL, and this function would render it on the page, leading to stored XSS.
The patch addresses these issues by consistently applying htmlspecialchars to values that are rendered in HTML attributes or as content. The fix also extends to other, similar vulnerabilities in related-data fields (BelongsTo, MorphTo) and select options, indicating a broader effort to harden the application against XSS. Any of these functions could appear in a runtime profile during an exploit, as they are all involved in processing and rendering potentially malicious data.