CVE-2022-31151: Vulnerability in undici package - uncleared cookies on cross-host / cross-origin redirect
Summary
CVE-2022-31151: undici before v5.8.0 vulnerable to uncleared cookies on cross-host / cross-origin redirect. Affects undici versions < 5.8.0. Fixed in 5.8.0. How to fix ↓
Also tracked for
- node-undici · Debian:12
The same CVE-2022-31151 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
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
The undici package is an HTTP/1.1 client for Node.js that provides a high-performance, low-memory footprint, and scalable solution for making HTTP requests. It is widely used in various applications and frameworks. However, prior to version 5.8.0, undici was vulnerable to uncleared cookies on cross-host / cross-origin redirects.
Vulnerability Detail
The vulnerability in undici allowed for the leakage of sensitive cookie headers during cross-origin redirects. While authorization headers were already cleared on cross-origin redirects, cookie headers remained uncleared. This could lead to accidental leakage of cookies to a third-party site or a malicious attacker who can control the redirection target. The issue was reported and patched in undici version 5.8.0.
How To Fix
Latest published version: 8.12.3 as of 22 Oct 2026
npm install undici@8.12.3
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
5.8.0
This is the first release that contains the fix.
npm install undici@5.8.0
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If updating the undici package is not immediately feasible, a workaround is to disable redirections by setting maxRedirections: 0 in the undici configuration. This will prevent the vulnerability from being exploitable.
Conclusion
The vulnerability in undici package (CVE-2022-31151) allowed for the leakage of sensitive cookie headers during cross-origin redirects. It has been patched in undici version 5.8.0. To fix the vulnerability, it is recommended to update the undici package to the latest version. A workaround is also available by disabling redirections. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for undici →
FAQ
Undici is an HTTP/1.1 client for Node.js that provides a high-performance solution for making HTTP requests.
The vulnerability could lead to the accidental leakage of sensitive cookie headers to a third-party site or a malicious attacker.
Yes, this vulnerability has been patched in undici version 5.8.0.
To fix this vulnerability, update the undici package to version 5.8.0 or later.
Yes, a workaround is to disable redirections by setting maxRedirections: 0 in the undici configuration.
References
Related vulnerabilities
Recent vulnerabilities recorded for undici.