Repository navigation
feat(spored): egress-proxy mode — allowlisted forward proxy with idle-terminate (#1515 phase 2) - #1517
Merged
Conversation
…ty file as instance state; escape Unicode test literals
scttfrdmn
force-pushed
the
feat/1515-spored-egress-proxy
branch
from
November 3, 2026 07:25
2208ff9 to
6c710f7
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Nov 3, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1515 (phase 2 of the build plan: the proxy as a mode of spored).
This PR is self-contained. Nothing creates a proxy instance, wires launches to one, sets proxy env in member bootstraps or adds
spawn egress-proxycommands; phases 3–5 do those.What it adds
pkg/egressproxy, standard library only:CONNECT host:443, tunnelled byte for byte with no TLS interception.GET/HEADto port 80, with hop-by-hop and allProxy-*headers stripped both ways. The upstreamHostis the URI's host, never the client'sHostheader.egressproxy.Allowlist, one exported list with aWhyper entry. An entry matches exactly or by a one-label*.wildcard. Hosts are normalised for case and one trailing dot; IP literals, non-ASCII names and malformed labels are refused.fd00:ec2::/32), CGNAT, unspecified, multicast or reserved, or is a mapped, NAT64, 6to4 or Teredo form of one. The proxy then dials the vetted IP only, never the name, which closes the rebinding gap.LastActivity()andStats(). Activity is updated on accept and while bytes flow; refusals don't count.LoadActivity,SaveActivity(atomic) andInitialActivity.spored egress-proxy: runs the normal lifecycle daemon (runDaemonis nowrunDaemonWith(nil)) plus the proxy.--listen(default: the private IP),--port 3128,--idle 336h,--state-file /var/lib/spored/egress-proxy-activity.jsonand--max-conns 256.pkg/agent.ExternalIdle/SetExternalIdle: a minimal hook incheckAndAct's idle step. When it is set, it replaces spored's CPU, network and session idle signals. Past the timeout it calls the existinga.terminate(...), the TTL's path, retried each tick and announced asttl_expiredonly once accepted. It never stops or hibernates.pkg/userdataandpkg/launcherassert that the EFA installer origin and the AWS CLI origin they fetch from are on the allowlist.instancestate.Paths, so an imaged proxy doesn't inherit it.TestEveryWrittenStatePathIsCoveredcaught this.Design choices
ExecStart, which only its user data writes. A tag could be flipped by anything that holdsec2:CreateTags. No other spored ever opens a listener.Revert gates (each mutation compiled; the named tests failed; then the change was reverted)
TestNonPublicResolutionIsRefused,TestDialerSeamDoesNotBypassTheAddressCheckstrings.HasSuffixTestAllowedCannotBeBypassed,ExampleAllowedTestDialUsesTheVettedAddressNotANewLookup(dialled 169.254.169.254)checkAndActTestExternalIdleTerminatesThroughTheTerminatePath,TestExternalIdleRetriesARefusedTerminatestopinstead ofterminateInitialActivityignores persisted/launch timeTestInitialActivity,TestEgressProxyActivitySurvivesRestartChecks
make checkpasses.go test -race ./pkg/egressproxy/... ./pkg/agent/... ./cmd/spored/...passes with AWS env stripped.go test ./...passes.semgrep scan --config=auto --error .is clean.pkg/egressproxyis not in the public surface.Deferred to later phases
http_proxy/no_proxy.spawn egress-proxyCLI and reaper coverage.al2023-repos-*) are not on the allowlist. They should go through the S3 endpoint viano_proxyin phase 4, and that needs confirming in the phase 6 live test.