CVE-2026-5078: morgan vulnerable to Log Forging via unneutralized control characters in :remote-user
Impact
Morgan's :remote-user token extracts the Basic auth username from the Authorization header and writes it to the log stream without neutralizing control characters. An attacker can send a crafted Authorization: Basic header containing CR/LF characters to inject forged log lines, corrupting the one-request-per-line structure of access logs.
The built-in combined, common, default, and short formats are affected, as well as any custom format that includes :remote-user.
Patches
Users should upgrade to version 1.11.0.
Workarounds
Use a custom format string that does not include :remote-user.
Other sources
Impact: The morgan logging middleware's :remote-user token extracts the Basic auth username from the Authorization request header and writes it to the log stream without neutralizing control characters. An unauthenticated attacker can send a crafted Authorization Basic header containing CR or LF bytes to inject forged log lines, breaking the one-request-per-line structure of access logs and enabling log forgery against downstream log consumers. The built-in combined, common, default, and short formats are affected, as well as any custom format that references :remote-user. Affected versions: morgan 1.2.0 through 1.10.1. Patches: upgrade to morgan 1.11.0, which neutralizes control characters in the :remote-user token output. Workarounds: use a custom format string that does not include :remote-user.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
npm/morganto a version that resolves this vulnerability.Fixed in 1.11.0 - Upgrade
Upgrade
morganto a version that resolves this vulnerability.Fixed in 1.11.0 - Configuration
Update the Morgan log format used for access logs (built-in combined/common/default/short or any custom format) to remove the :remote-user token, or replace it with fields that do not include :remote-user.
morgan logging middleware log format (avoid :remote-user) = custom format string without :remote-user
Event History
Frequently Asked Questions
What is the severity of CVE-2026-5078?
The severity of CVE-2026-5078 is medium with a score of 5.3.
How do I fix CVE-2026-5078?
To fix CVE-2026-5078, update the morgan logging middleware to the latest version where the vulnerability has been addressed.
What impact does CVE-2026-5078 have on my application?
CVE-2026-5078 allows an unauthenticated attacker to perform log forging by exploiting unneutralized control characters in the :remote-user token.
Can CVE-2026-5078 be exploited remotely?
Yes, CVE-2026-5078 can be exploited by unauthenticated attackers remotely through crafted Authorization Basic headers.
Is there a workaround for CVE-2026-5078 before applying a fix?
A potential workaround for CVE-2026-5078 is to validate and neutralize control characters in the header before logging.