Repository navigation
fix(service): never bake Claude first-party's own intercept proxy - #7327
Conversation
With Claude Code CLI first-party on, ~/.claude/settings.json sets HTTPS_PROXY to OpenCodex's own intercept listener (http://opencodex:<token>@127.0.0.1:<port>), and every process Claude Code starts inherits it. Installing or restarting the service from such a shell baked that URL into the service definition, so the proxy sent its own outbound traffic back through its intercept listener and the per-install token ended up in the wrapper script. resolvedProxyEnv now skips the token-bearing intercept URL and falls through to the lower-case spelling when it holds a real proxy. A tokenless loopback proxy such as a local Clash or v2rayN port is still baked.
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 3
✨ Finishing Touches
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. Comment |
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. Automatic draft conversion failed. Please convert this pull request to a draft manually until every box above is ticked. |
|
Intake/scoped review at Linked bug #7326 has a concrete inherited-proxy reproduction. The patch skips only the generated token-bearing loopback intercept URL, preserves a real tokenless local proxy and falls through to lowercase env where appropriate. The shared definition input covers systemd/launchd/Windows rendering, but the fixture is not a real service-reinstall receipt. Retain Draft and the service/proxy review gate. Current-head functional workflows are awaiting fork approval; that is pending execution, not a passing test result. No local suite was run for this branch in this intake. No workflow approval, new scan, live configuration change or merge was performed. Required review/readiness gates remain in force. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 74e056e12a
ℹ️ 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".
| * proxy's own outbound traffic back through its intercept listener. Only the token-bearing form | ||
| * is matched: a plain `http://127.0.0.1:<port>` is a user's local proxy client and is kept. | ||
| */ | ||
| const OWN_CLAUDE_INTERCEPT_PROXY = /^http:\/\/opencodex:[^@/]+@127\.0\.0\.1:\d{1,5}\/?$/i; |
There was a problem hiding this comment.
Preserve proxies that merely use the opencodex username
When a user's real authenticated local proxy uses the username opencodex (for example, http://opencodex:pw@127.0.0.1:7897), this regex classifies it as the Claude intercept URL even though any nonempty password matches, so resolvedProxyEnv drops the user's configured proxy and the installed service can lose outbound connectivity. Match the generated credential's actual fixed 43-character base64url shape (or the known token) rather than every password for that username.
AGENTS.md reference: src/AGENTS.md:L10-L10
Useful? React with 👍 / 👎.
Summary
Closes #7326.
resolvedProxyEnv()now skips one URL shape when it bakes proxy env into the service:http://opencodex:<token>@127.0.0.1:<port>, the URLclaudeInterceptProxyUrl()writes for first-party. IfHTTPS_PROXYholds it andhttps_proxyholds a real proxy, the real one gets baked.A plain
http://127.0.0.1:<port>still gets baked, since local proxy clients like Clash and v2rayN use that form. That's why I didn't reuseisClaudeInterceptProxyUrl(). It also matches the loopback URL without a token, so it would drop those.The Windows wrapper, the systemd unit and the launchd plist all take their proxy env from this function, so one change covers all three.
Changed:
src/service/definition.ts: the skip, with a comment on why it only matches the URL with the tokentests/service/service.test.ts: one test. The intercept URL is dropped, the lowercase fallback works, and plain loopback anduser:passproxies are keptstructure/runtime.md: one sentence in the intercept paragraphVerification
I ran these on Windows 11 with Bun 1.4.3, on this branch at
dev8640c2f, on 2026-10-19:bun test tests/service/service.test.ts: 209 pass, 0 failbun test tests/service/launchd-repair.test.ts: 61 pass, 0 failtests/ci-workflows/file-size-ratchet.test.tsandtests/ci-workflows/import-cycle-ratchet.test.ts: passbun x tsc --noEmit: no errorsbun run structure:checkandbun run privacy:scan: pass.github/scripts/pr-hygiene.cjsover the branch diff: no findingsThe first time I ran those four files together, one test failed. The same command passed on the next run (295 pass, 0 fail), and each file passes alone. I didn't run the full
bun run test. The change is one function with its own test, so I'm leaving the rest to CI.Checklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
Required local validation passed; commands, results, and any full-suite exception are documented.
I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.