Skip to content

Reach IPv6 addresses over plain HTTP and through an IPv6 upstream in the egress filter - #710

Merged
davidmckayv merged 4 commits into
CopilotKit:mainfrom
Chebaleomkar:fix/egress-ipv6-literals
Oct 2, 2026
Merged

davidmckayv merged 4 commits into
CopilotKit:mainfrom
Chebaleomkar:fix/egress-ipv6-literals

Conversation

@Chebaleomkar

Copy link
Copy Markdown
Contributor

What this changes

URL.hostname keeps an IPv6 address's brackets (new URL("http://[::1]:8080/").hostname is "[::1]"). The egress filter passed that string to the socket in two places:

  • forwardPlain: a plain-HTTP request to http://[::1]:port/ was looked up as a name and answered 502 Bad Gateway. An IP literal is not resolved and pinned, so nothing else caught it. CONNECT [::1]:port already worked, because splitHostPort strips the brackets.
  • upstreamAddress: an upstream proxy configured as http://[::1]:8080 could not be reached.

In addition, tunnel wrote CONNECT ::1:443 to the upstream, which is not a valid authority. An IPv6 host is now bracketed there.

Where it runs

The agent computer's egress filter.

Boundary and audit

None. Decisions already used normalizeHost, which strips brackets. Only the forwarding is fixed.

Changelog

Entry under Unreleased.

Proof

Two live tests in agent-computer/tests/egress-policy.test.ts (an origin and a fake upstream listening on ::1). Both fail on main (19 pass, 2 fail) and the file passes 21/21 with the fix. Biome format and lint are clean, and tsc reports nothing in the changed files.

URL.hostname keeps an IPv6 address's brackets, and forwardPlain and
upstreamAddress passed it to the socket as written, so the address was
looked up as a name and the request answered 502. Strip the brackets
there, and bracket an IPv6 host in the CONNECT line sent upstream.
Chebaleomkar and others added 3 commits October 3, 2026 00:47
The computer runs on Bun, which already reaches a bracketed IPv6 host
over plain HTTP, so that 502 never happened in the shipped image. The
fix is an upstream proxy at an IPv6 address and the brackets on a
CONNECT target.
@davidmckayv

Copy link
Copy Markdown
Contributor

I pushed one commit that rewrites the CHANGELOG entry. The computer image runs on Bun (agent-computer/Dockerfile), and Bun already reaches http://[::1]:<port>/ with the brackets in place, so the plain-HTTP 502 the entry described only happens on Node. The entry now names the two things this fixes in the shipped image: an upstream proxy at an IPv6 address, and the brackets on a CONNECT target. The code is unchanged.

@davidmckayv
davidmckayv merged commit e8993ea into CopilotKit:main Oct 2, 2026
19 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