Skip to content

Drop actor UDP egress to every port but DNS - #1623

Open
haiyanmeng wants to merge 1 commit into
agent-substrate:mainfrom
haiyanmeng:block-non-dns-udp
Open

Drop actor UDP egress to every port but DNS#1623
haiyanmeng wants to merge 1 commit into
agent-substrate:mainfrom
haiyanmeng:block-non-dns-udp

Conversation

@haiyanmeng

@haiyanmeng haiyanmeng commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

Only TCP is redirected into atunnel, so UDP left the worker pod through the compatibility masquerade with no CONNECT authority, no access log, and no policy hook. QUIC on 443 is the case that matters: an actor could make its own HTTPS egress unintercepted just by speaking HTTP/3, with no timing trick needed.

Add a forward-chain rule ahead of the catch-all accept that drops UDP from the actor veth to any destination port but 53, keeping the DNS exception the masquerade exists for. The rule counts what it drops, so a workload that legitimately needs UDP surfaces in nft list table ip ateom_actor rather than as an unexplained timeout.

The rule is installed whether or not an egress gateway is configured: unlike the redirect it needs nothing to redirect to, and a deployment with no egress control is where unrestricted UDP is worst.

The existing TODO narrows rather than goes away. The DNS exception is still any port-53 destination rather than the configured cluster resolver, and protocols other than TCP and UDP still reach the masquerade.

It's a good idea to open an issue first for discussion.

  • Tests pass
  • Appropriate changes to documentation are included in the PR

Only TCP is redirected into atunnel, so UDP left the worker pod through
the compatibility masquerade with no CONNECT authority, no access log,
and no policy hook. QUIC on 443 is the case that matters: an actor could
make its own HTTPS egress unintercepted just by speaking HTTP/3, with no
timing trick needed.

Add a forward-chain rule ahead of the catch-all accept that drops UDP
from the actor veth to any destination port but 53, keeping the DNS
exception the masquerade exists for. The rule counts what it drops, so a
workload that legitimately needs UDP surfaces in
`nft list table ip ateom_actor` rather than as an unexplained timeout.

The rule is installed whether or not an egress gateway is configured:
unlike the redirect it needs nothing to redirect to, and a deployment
with no egress control is where unrestricted UDP is worst.

The existing TODO narrows rather than goes away. The DNS exception is
still any port-53 destination rather than the configured cluster
resolver, and protocols other than TCP and UDP still reach the
masquerade.

@bowei Bowei Du (bowei) 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.

Looks ok

Seems like we are exporting things we don't need to, can you check?

Comment thread internal/ateomnet/net.go
ActorVethSubnet = "169.254.17.0/30"

// DNSPort is the only destination port on which actor UDP egress is forwarded.
DNSPort = 53

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.

This doesn't need to be exported?

Move the constant to where it is used.

Comment thread internal/ateomnet/net.go
//
// TODO: Restrict the compatibility masquerade to DNS traffic sent to the
// configured cluster resolver and drop all other non-tunneled actor egress.
// TODO: Restrict the DNS exception to the configured cluster resolver

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.

Not clear we want to do exactly this. Remove the TODO for now.

Comment thread internal/ateomnet/net.go
}

func TCPProtocol() []expr.Any {
return L4ProtocolEqual(unix.IPPROTO_TCP)

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.

To fit the naming, this should be L4TCPProtocol

Comment thread internal/ateomnet/net.go
return L4ProtocolEqual(unix.IPPROTO_TCP)
}

func UDPProtocol() []expr.Any {

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.

same here

L4UDPProtocol

Comment thread internal/ateomnet/net.go
// The rule counts what it drops: a workload that legitimately needs UDP shows
// up as a rising counter in `nft list table ip ateom_actor` rather than as an
// unexplained timeout.
func ActorNonDNSUDPDropRule(table *nftables.Table, chain *nftables.Chain) *nftables.Rule {

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.

Can you check that these actually need to be exported? Seems like there are identifiers in this file that may not really need to be exported but are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants