GeezerVison is showing github.com — fix(lab-ops-hub): fetch userinfo URLs with Basic auth in the container crawler by dezren39 · Pull Request #634 · developing-today/code
Conversation
dezren39
commented
Oct 23, 2026
•
edited by blacksmith-sh
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Fixes #622
Problem
_fetch_crawl handed validated URLs straight to urllib.request. urllib never strips userinfo: Request.host keeps user@host / user:pass@host whole, http.client is built with it as the hostname, and getaddrinfo fails — so every userinfo target both validators accept (plain http://[email protected]/, password-bearing, and the percent-encoded forms #616/#619 polished) 502'd in the container before any request was sent, while the Worker fallback fetched it and recorded the wrong source.
Reproduced on main 00bb59d5 with the app's own _fetch_crawl against a local server: control URL → 200; user@, user:pa%3Ass@, caf%C3%A9@, @, user:@ → all URLError: [Errno -2] Name or service not known, no request received.
Solution
- New
_split_userinfo(url) / _apply_userinfo_auth(req) in container/app.py: strip the userinfo from the URL handed to urllib and send its credentials the way WHATWG fetch does — an Authorization: Basic header built from the percent-decoded username/password (UTF-8). A URL only "includes credentials" when username or password is non-empty, so bare @ / :@ sends no header (which also makes user:@ fetch exactly as user@).
_fetch_crawl applies it to the start request.
_ValidatingRedirectHandler.redirect_request applies it to every followed request, re-deriving the header from the target's own userinfo: urllib copies the previous request's headers onto redirects, so without this a credentialed start URL's Authorization would leak to a plain redirect target, and a credentialed target would be fetched with the previous hop's credentials (or none). Per-hop SSRF re-validation is unchanged.
Tests
- Python: 3 new tests — a 10-spelling fetcher battery end-to-end against a local recording server (plain, password,
%3A password, non-ASCII credentials, empty-password, :pass, bare @, :@, no userinfo), a redirect integration test (userinfo target gets its own auth; credentialed start does not leak to a plain target), and a redirect-handler unit pin. 50/50 pass (was 47).
- TS: 1 new pin that the Worker helper fetches userinfo start/redirect URLs in their validated form. 36/36 pass (was 35).
- Ablation: with only
app.py reverted, exactly the 3 new Python tests fail.
ruff format clean; biome format (treefmt's TS formatter) reports no fixes.
- Local differential note: Bun's own
fetch is not the reference here (it silently drops password-bearing userinfo with no Authorization header and fails username-only URLs); the implementation follows the WHATWG fetch rule the issue's acceptance criteria specify, which is what the Cloudflare Workers fallback implements.
Single-repo: no validate_crawl_url / _fetch_crawl copy exists in the opencode, openchamber or nix clones (grep-verified).
![Autofix with [code]smith](/api/image?u=https%3A%2F%2Fcamo.githubusercontent.com%2F33b6f70f3541c4e93f4503d29cbfec051fa1b040d8e0ae9313a51c4ece44a627%2F68747470733a2f2f70722d636f6d6d656e74732d6173736574732e626c61636b736d6974682e73682f636f6465736d6974682f6175746f6669782d776974682d636f6465736d6974682d6461726b2d33782e706e67)
Need help on this PR? Tag @codesmith-bot with what you need.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…r crawler (#622)
_fetch_crawl handed validated URLs straight to urllib, which keeps
'user@host' as the hostname: getaddrinfo failed before any request
was sent, so every userinfo target both validators accept 502'd in
the container while the Worker fallback fetched it.
Split the userinfo off before fetching and send its credentials the
way WHATWG fetch does: Authorization: Basic built from the
percent-decoded username/password (UTF-8). A userinfo with empty
username and password ('@', ':@') sends no header. The redirect
handler re-derives the header from each target's own userinfo, so a
credentialed target fetches with its credentials and a plain target
never inherits the previous hop's Authorization.
Tests: 3 new Python tests (10-spelling fetcher battery end-to-end
against a local server, redirect-to-userinfo integration, redirect
handler unit pin) + 1 TS pin that the Worker fetches userinfo URLs
in validated form. Python 50/50, TS 36/36; ablation with app.py
reverted fails exactly the 3 new Python tests.
Codex Review Summary
This comment shows the latest Codex review activity on this pull request.
| Review |
Status |
Commit |
Review trigger |
| 📝 Code Review |
✅ Completed 2026-10-23T02:11:11.837386Z |
22bdbe7 |
PR opened |
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review" or "@codex security review".
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|

Note Currently processing new changes in this PR. This may take a few minutes, please wait...
⚙️ Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
728914cf-4f33-45b2-afe9-dc6671d4716b
📥 Commits
-
Reviewing files that changed from the base of the PR and between 00bb59d and 22bdbe7.
📒 Files selected for processing: 3
-
pkgs/lab-ops-hub/container/app.py
pkgs/lab-ops-hub/test/lib.test.ts
pkgs/lab-ops-hub/test/test_container_validate.py
+---------------------+
| Git gud or git out. |
+---------------------+
\
\ /)/)
( '')
/ |
o(___)
✨ Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
-
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 22bdbe74e9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+848
to
+849
|
|
if req.has_header("Authorization"):
|
|
|
req.remove_header("Authorization")
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preserve credentials across relative redirects
When a credentialed URL responds with a relative Location such as /landing, the initial _apply_userinfo_auth has already removed the userinfo from req.full_url, so urllib resolves the target without credentials; this second call then removes the copied Authorization header because _split_userinfo finds no @. The authenticated first hop therefore becomes an unauthenticated second hop, breaking common canonical/login redirects and diverging from the Worker path in src/lib.ts, where new URL(location, current) inherits the credentials from current. Retain the URL credentials as redirect metadata or preserve the header for relative same-origin redirects while still clearing it when an explicit target omits credentials.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+827
to
+828
|
|
username = unquote(username)
|
|
|
password = unquote(password)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preserve non-UTF-8 credential bytes
For accepted userinfo containing percent-encoded bytes that are not valid UTF-8, unquote silently replaces those bytes with U+FFFD before the value is re-encoded. For example, http://%[email protected]/ is accepted, but this produces credentials b'\xef\xbf\xbd:' (Basic 77+9Og==) rather than the percent-decoded bytes b'\xff:' (Basic /zo=), so such targets receive the wrong password material and distinct credential spellings can collapse to the same header. Decode the userinfo with unquote_to_bytes and construct the Basic payload from the username and password byte sequences directly.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|