Skip to content

fix: keep undici and got requests on the configured proxy - #82

Merged
proxymesh merged 6 commits into
mainfrom
cursor/vulnerability-agent-memory-9801
Nov 2, 2026
Merged

proxymesh merged 6 commits into
mainfrom
cursor/vulnerability-agent-memory-9801

Conversation

@cursor

@cursor cursor Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes two proxy-bypass issues from the at-rest security scan.

Undici: HTTPS request() sent CONNECT, then ignored the tunnel and dialed the origin directly (connect: { socket } is not undici’s tunnel API). Origin TLS now wraps the CONNECT socket via httpSocket.

Got: Only agent.https was set, so http:// URLs and HTTPS→HTTP redirects used got’s default HTTP agent and connected directly. The adapter now rejects HTTP and protocol-downgrade redirects, and pins agent.http so a missed hook cannot fall back to a direct connect.

Unit tests cover:

  • undici origin traffic going through the CONNECT tunnel
  • undici not reaching the origin when CONNECT is not forwarded
  • got rejecting plain HTTP
  • got refusing HTTPS→HTTP redirects

npm run test:unit passes (20 tests).

Open in Web View Automation 

Fixes two proxy-bypass issues from the at-rest security scan. This PR is only that security fix: undici and got stay on the configured proxy. No dependency bumps, no peer or engine changes.

Undici

HTTPS request() completed CONNECT, then ignored the tunnel and dialed the origin directly. connect: { socket } is a TLS option, not undici’s pre-connected tunnel API. Origin TLS is now wrapped on the CONNECT socket with buildConnector and httpSocket.

tlsOptions is passed into that connector. connectTimeout bounds the origin handshake, which the “CONNECT not forwarded” test uses so a hung tunnel cannot fall through to a direct dial. proxyTlsOptions was already accepted and is now documented.

Got

Only agent.https was set, so http:// URLs and HTTPS→HTTP redirects used got’s default HTTP agent and connected directly. The adapter rejects those URLs and pins agent.http to the same proxy agent so a missed hook cannot fall back to a direct connect.

Tests in CI

npm run test:unit is node --test test/test_connect_security.js. New cases:

  • undici origin traffic goes through the CONNECT tunnel
  • undici does not reach the origin when CONNECT is not forwarded
  • got rejects plain HTTP
  • got refuses HTTPS→HTTP redirects

The Proxy integration tests workflow already runs npm run test:unit on ubuntu-24.04 (actions pinned by commit SHA) before the live PROXY_URL suite. No new workflow was added.

Files

  • lib/undici-proxy.js, lib/got-proxy.js — the fix
  • types/undici.d.ts, test/types.test.ts — tlsOptions and connectTimeout
  • docs/undici.md, docs/got.md, docs/getting-started.md — the behavior and the new options
  • test/test_connect_security.js — the four cases above
Open in Web Open in Cursor 

cursoragent and others added 2 commits November 1, 2026 19:08
Undici now wraps origin TLS on the CONNECT socket instead of dialing
the target directly. Got rejects HTTP URLs and HTTPS-to-HTTP redirects
so they cannot fall back to a direct connection.

Co-authored-by: ProxyMesh AI <proxymeshai@users.noreply.github.com>
The security fix already accepts connectTimeout on the undici request
options. Document it beside tlsOptions so the public API matches the types.

Co-authored-by: ProxyMesh AI <proxymeshai@users.noreply.github.com>
…agent-memory-9801

Co-authored-by: ProxyMesh AI <proxymeshai@users.noreply.github.com>
…agent-memory-9801

Co-authored-by: ProxyMesh AI <proxymeshai@users.noreply.github.com>

Copy link
Copy Markdown
Collaborator

bugbot review

@cursor

cursor Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Skipping Bugbot: Bugbot is disabled for this repository. Visit the Bugbot dashboard to update your settings.

Client connectTimeout is ignored when connect is a custom function, so a
hung origin handshake waited the connector default of 10s. Bytes that
arrived with the CONNECT response were unshifted on a still-flowing
socket, which dropped them before origin TLS.

Co-authored-by: ProxyMesh AI <proxymeshai@users.noreply.github.com>
@proxymeshai
proxymeshai marked this pull request as ready for review November 1, 2026 21:08
@cursor

cursor Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Review of the undici/got proxy-bypass fix.

The bypass is closed. Undici HTTPS wraps origin TLS on the CONNECT socket (httpSocket) and does not dial the origin when CONNECT is not forwarded. Got rejects http: URLs and HTTPS→HTTP redirects, and pins agent.http to the proxy agent. A later request hook that rewrites the URL to http: still fails before any socket is opened.

Two undici correctness bugs, fixed in 08a8fca:

  1. connectTimeout was ignored. Undici applies Client connectTimeout only when connect is not a custom function, so a hung origin handshake waited the connector default of 10s. The timeout is now passed into buildConnector.
  2. Bytes pipelined with the CONNECT response were dropped. The socket was still flowing after removeAllListeners('data'), so unshift emitted the tail with no listener. The socket is paused first, and the leftover is sliced by byte offset.

npm run test:unit passed locally. Proxy integration tests CI is green.

@proxymesh
proxymesh enabled auto-merge November 2, 2026 22:08
@proxymesh
proxymesh disabled auto-merge November 2, 2026 22:11
@proxymesh
proxymesh merged commit bcee650 into main Nov 2, 2026
2 checks passed
@proxymesh
proxymesh deleted the cursor/vulnerability-agent-memory-9801 branch November 2, 2026 22:11
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.

3 participants