Repository navigation
[Bug]: SIWC token exchange ignores proxy configuration #3327
Description
Description
SIWC browser authorization and the localhost callback complete successfully, but the Midscene CLI fails during OAuth token exchange or ID token verification.
The SIWC network requests appear to bypass the configured proxy and connect directly to auth.openai.com:443.
Environment
- Midscene: 1.17.2
- Node.js: 24.14.0
- OS: macOS
- Network proxy: ClashX Pro
- Local mixed proxy:
http://127.0.0.1:17890
Steps to reproduce
-
Configure proxy-related environment variables and start SIWC login:
HTTP_PROXY=http://127.0.0.1:17890 \ HTTPS_PROXY=http://127.0.0.1:17890 \ NO_PROXY=localhost,127.0.0.1 \ MIDSCENE_MODEL_HTTP_PROXY=http://127.0.0.1:17890 \ ./node_modules/.bin/midscene model siwc login --no-open --port 8787
-
Open the generated authorization URL and complete authorization.
-
The browser successfully redirects to the localhost callback and displays
Authorization received. -
The CLI fails during token exchange.
Actual behavior
OpenAI login failed.
SiwcError: Stage: Login
Stage: Token exchange
fetch failed
ConnectTimeoutError: Connect Timeout Error
(attempted address: auth.openai.com:443, timeout: 10000ms)
code: UND_ERR_CONNECT_TIMEOUT
In another attempt, token exchange succeeded but JWKS retrieval failed:
Stage: ID token verification
socket hang up
code: ECONNRESET
Network verification
The OpenAI JWKS endpoint is reachable through the same proxy:
curl -x http://127.0.0.1:17890 \
-sS -o /dev/null -w '%{http_code}\n' \
https://auth.openai.com/.well-known/jwks.jsonThis returns HTTP 200. A standalone Node.js request configured to use the proxy can also reach the OpenAI token endpoint, while the Midscene SIWC flow still reports a direct connection attempt to auth.openai.com:443.
Expected behavior
SIWC token exchange and JWKS retrieval should respect one of the following:
MIDSCENE_MODEL_HTTP_PROXYHTTPS_PROXY/HTTP_PROXY- A dedicated SIWC proxy setting
Ideally, the SIWC authorization flow should reuse Midscene's existing proxy-agent implementation.
Suspected cause
exchangeSiwcCode() uses bare global fetch(), and ID token verification uses createRemoteJWKSet(), without applying Midscene's proxy configuration.
Relevant source:
packages/core/src/ai-model/service-caller/openai/siwc/authorization.ts
The regular model-request path already has proxy-agent handling, but the SIWC authorization path does not appear to use it.
Security note
This report intentionally excludes authorization URLs, authorization codes, OAuth state values, access tokens, and credential-file contents.
Activity