Skip to content

reject redirects to non-http(s) schemes in PipSession - #14171

Merged
ichard26 merged 4 commits into
pypa:mainfrom
Arawoof06:redirect-scheme-guard
Aug 6, 2026
Merged

reject redirects to non-http(s) schemes in PipSession#14171
ichard26 merged 4 commits into
pypa:mainfrom
Arawoof06:redirect-scheme-guard

Conversation

@Arawoof06

@Arawoof06 Arawoof06 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

pip mounts a LocalFSAdapter for file:// URLs on the same session it uses for the index and for downloads, and requests follows a 3xx Location into any scheme the session has an adapter for. A remote server can therefore redirect a request to a file:// URL and have pip read a local path through LocalFSAdapter.send (on Windows a UNC target reaches an SMB share). get_redirect_target now refuses a redirect whose scheme is not http/https; relative targets keep the current scheme and direct file:// requests are unaffected.

PR Checklist:

  • I agree to follow the PSF Code of Conduct.
  • I have read and have followed the CONTRIBUTING.md file.
  • I have added a news file fragment (or this PR does not need one).
  • I have read and followed the AI_POLICY.md file, and if any AI tools were used, I have disclosed it below.

I use an LLM lightly for research and to sanity-check things, but the code here is mine and I understand and take full responsibility for it.

@sepehr-rs

Copy link
Copy Markdown
Member

Hi @Arawoof06, thanks for your contribution.
I haven't looked closely at the changes yet, but I noticed the AI policy checkbox has been left unchecked on several of your PRs. Is that intentional?

@Arawoof06

Copy link
Copy Markdown
Contributor Author

Not intentional, just an oversight. Ticked it now, and updated the other PRs too. I use an LLM a little for research and sanity-checking, but the code is mine and I understand and stand behind it. Happy to walk through the redirect logic if you want to dig in.

@ichard26 ichard26 added the skip PR template check Silence the PR template check in CI label Aug 6, 2026
@ichard26
ichard26 merged commit e407d06 into pypa:main Aug 6, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided skip PR template check Silence the PR template check in CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants