CVE-2026-5078: Morgan Package Vulnerable to Log Forging via Unneutralized Control Characters
Summary
CVE-2026-5078: morgan vulnerable to Log Forging via unneutralized control characters in :remote-user. Affects morgan versions >= 1.2.0, < 1.11.0. Fixed in 1.11.0. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
Morgan is a popular logging middleware for Node.js applications, designed to simplify the process of logging HTTP requests. It provides various logging formats and is widely used in web applications to maintain access logs. However, a vulnerability has been identified in Morgan that allows attackers to manipulate log entries through crafted HTTP headers, compromising the integrity of the logs.
Vulnerability Detail
The vulnerability arises from Morgan's handling of the ':remote-user' token, which extracts the Basic auth username from the 'Authorization' header. This token does not neutralize control characters, allowing an attacker to inject CR/LF characters into the logs. As a result, an attacker can forge log lines, disrupting the one-request-per-line structure of access logs. This could lead to confusion in log analysis and potential exploitation of the logs for malicious purposes.
How To Fix
Latest published version: 1.12.1 as of 23 Oct 2026
npm install morgan@1.12.1
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
1.11.0
This is the first release that contains the fix.
npm install morgan@1.11.0
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a temporary workaround, users can avoid using the ':remote-user' token in their custom log format. For example, you can define a custom format without ':remote-user' as follows: '
app.use(morgan(':method :url :status :res[content-length] - :response-time ms'));
'. This will prevent the injection of unneutralized control characters into the logs.
Conclusion
The CVE-2026-5078 vulnerability in the Morgan logging middleware poses a risk of log forgery due to unneutralized control characters in the ':remote-user' token. Users are advised to upgrade to version 1.11.0 or implement workarounds to mitigate the risk. Regular monitoring for vulnerabilities using tools like Vulert can help maintain application security.
See every vulnerability recorded for morgan →
FAQ
CVE-2026-5078 is a vulnerability in the Morgan logging middleware that allows attackers to forge log entries by injecting control characters into the logs.
If your application uses Morgan for logging and is vulnerable, attackers can manipulate log entries, potentially leading to misleading logs and security issues.
Versions of Morgan from 1.2.0 up to 1.10.1 are affected by this vulnerability.
You can use Vulert, which monitors and alerts for open-source vulnerabilities in your software. Check your application with the Vulert playground at Vulert Scanner without needing to sign up.
The CVSS score of this vulnerability is 5.3, indicating a moderate severity level.
Related vulnerabilities
Recent vulnerabilities recorded for morgan.