forwardemail / forwardemail/superagent

[Security] Authorization Header Leak on Cross-Origin 307/308 Redirects

Open
#1,844 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
16.6k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

## Summary

superagent leaks Authorization headers to attacker-controlled servers when following cross-origin 307/308 redirects. The existing credential-stripping logic only applies to 301/302/303 redirects.

## Details

In lib/node/index.js, the _redirect() method calls cleanHeader() for 301/302/303 (strips auth on cross-origin) but for 307/308 only deletes host header. Auth headers leak.

## PoC

1. Legitimate server returns 307 to evil.com
2. Client sends request with Authorization header
3. evil.com receives the full Authorization header

## Impact

- Credential theft via 307/308 redirects
- ~5M weekly npm downloads
- CVSS 6.5, CWE-522

## Fix

Call cleanHeader() in the 307/308 path when origin changes.

References: CVE-2023-45143 (undici), CVE-2023-46136 (got)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.