Skip to content

fix(import): support opt-in loopback proxy for OpenAI host-file downloads - #1418

Merged
swjnxyf merged 4 commits into
yyjeqhc:mainfrom
mo-lin-yuan:fix/hostfile-loopback-proxy-20261110
Nov 11, 2026
Merged

swjnxyf merged 4 commits into
yyjeqhc:mainfrom
mo-lin-yuan:fix/hostfile-loopback-proxy-20261110

Conversation

@mo-lin-yuan

Copy link
Copy Markdown
Contributor

Problem

On Windows setups using a local HTTP proxy with fake-IP DNS (RFC 2544 198.18.0.0/15), an authenticated ChatGPT host-file import may pass the trusted loopback/hostname admission checks but still fail during download.

The existing downloader uses reqwest::Client::builder().no_proxy() and pins the DNS result. In the reproduced environment, the local resolver returned a synthetic IP for an OpenAI attachment host. Direct HTTPS failed TLS verification, whereas HTTPS via the trusted local HTTP proxy could reach the actual upstream endpoint. The user-facing import_host_files failure was failed to download.

This is separate from #1138, which addresses fake-IP admission, rather than the actual HTTPS download transport.

Change

  • Add an opt-in, default-off WEBCODEX_OPENAI_FILE_IMPORT_PROXY=http://127.0.0.1:PORT setting (also accepts http://[::1]:PORT) for LoopbackTrustedMcpHostFile on allowlisted OpenAI attachment hosts only.
  • Route those HTTPS requests through an explicit local HTTP CONNECT proxy. Keep TLS certificate verification and no-redirect behavior.
  • Reject remote/non-loopback proxy endpoints, proxy credentials, paths, queries, and fragments.
  • Preserve the existing direct, DNS-pinned behavior for non-OpenAI trusted URLs, remote authenticated MCP imports, and all imports when the setting is absent.
  • Add boundary tests and a mock-loopback CONNECT test; document the configuration and trust tradeoff in English and Chinese MCP guides.

Verification

On the updated upstream main baseline (f8228b6):

  • cargo fmt --all and git diff --check: passed.
  • cargo +stable-x86_64-pc-windows-gnu check --target x86_64-pc-windows-gnu -p webcodex --tests --offline: passed.
  • cargo +stable-x86_64-pc-windows-gnu test --target x86_64-pc-windows-gnu -p webcodex --lib tool_runtime::conversation_import::tests:: --offline: 15 passed, 0 failed.
  • A previous build of this patch was tested end-to-end on an authorized Windows Desktop v0.5.0 installation: a real ChatGPT import_host_files call imported an approximately 24.8 MB ZIP; contents were verified by SHA-256 on the destination. The latest rebase additionally preserves non-OpenAI trusted download behavior, which is covered by unit tests. No broad cross-platform E2E claim is made.

Security / tradeoff

An HTTP CONNECT proxy chooses the upstream address itself, so the proxy path cannot enforce WebCodex's direct-mode DNS pin on the eventual connection. The option therefore requires an operator-controlled, explicitly configured loopback proxy, and only applies to the already-authorized local OpenAI attachment import flow. TLS verification remains enabled. This behavior is not enabled automatically.

No authentication credentials, signed attachment URLs, private file contents, or local installation paths are included in this PR.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T06:04:16.784597Z c691475 Manual request
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

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: 3525086f10

ℹ️ 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".

Comment thread src/tool_runtime/conversation_import.rs Resolved
Comment thread src/tool_runtime/conversation_import.rs Resolved
@mo-lin-yuan

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: c691475d3b

ℹ️ 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".

@swjnxyf swjnxyf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed PR #1418 on the special primary checkout at c691475d3b7ba1b2453f302bc7b09067ece77ebb (no worktree). No remaining blocking issues; LGTM.

The change is opt-in and defaults off. The explicit HTTP proxy is constrained to IPv4/IPv6 loopback endpoints with a written port and no credentials/path/query/fragment, and it is selected only for LoopbackTrustedMcpHostFile with an allowlisted OpenAI download hostname. Unrelated trusted URLs and authenticated/remote MCP imports retain the existing direct, DNS-pinned path. TLS verification and redirect rejection remain enabled. The documentation accurately calls out the unavoidable DNS-pinning tradeoff when a trusted local CONNECT proxy selects the upstream address.

Both earlier Codex findings are addressed by c691475: explicitly configured :80 survives URL normalization while omitted ports remain rejected, and the real loopback CONNECT socket fixture has moved to src/mcp_tests/file_import.rs in accordance with AGENTS.md. I confirmed and resolved those two review threads.

Validation on special: the previous revision's conversation-import tests passed (15/15); on the latest revision, the conversation-import helper suite passed (14/14), the MCP file-import domain tests including the local CONNECT fixture passed, and cargo fmt --all -- --check plus git diff --check passed. The original full GitHub CI completed successfully; the new full matrix triggered by c691475 is still in progress with no failed jobs at review time, so final integration remains subject to its result.

No follow-up code changes are necessary from this review.

@swjnxyf
swjnxyf merged commit 3c14196 into yyjeqhc:main Nov 11, 2026
18 checks passed
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.

2 participants