Skip to content

lib/fetch: don't forward credentials on cross-host redirects - #710

Open
safa-rk wants to merge 1 commit into
void-linux:masterfrom
safa-rk:fetch-redirect-credentials
Open

safa-rk wants to merge 1 commit into
void-linux:masterfrom
safa-rk:fetch-redirect-credentials

Conversation

@safa-rk

@safa-rk safa-rk commented Nov 19, 2026

Copy link
Copy Markdown

http_request copies the user and password of the current url into the redirect target whenever the Location url has no credentials of its own, without looking at the host. with a repository like https://user:pass@repo.example.org/, a redirect to any other host makes libfetch send Authorization: Basic with those credentials there, and a redirect to ftp://other/ hands them to that ftp server as USER/PASS in cleartext. only copy them when the host matches, which is the guard FreeBSD's libfetch has. same-host and absolute-path redirects keep their credentials. checked with two local servers (127.0.0.1 redirecting to 127.0.0.2): before the change the second one receives the Basic header (or USER/PASS for ftp://), after it gets none, and make check passes with gcc and clang.

http_request copied the user and password of the current URL into any
redirect target without credentials of its own, so a redirect to another
host received them, and a redirect to ftp:// sent them as USER/PASS.

Only copy them if the host matches, like FreeBSD's libfetch does.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant