CVE-2022-31151: Vulnerability in undici package - uncleared cookies on cross-host / cross-origin redirect

undici Updated 02 Oct 2025

Summary

21/07/2022
Yes i
Low
3.7

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

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.

Free scan

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.

Check my app free

No signup required · Results in about 60 seconds

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

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 →

Share this vulnerability

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.

Related vulnerabilities

Recent vulnerabilities recorded for undici.

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 →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback