Don't record private IP literals as outbound hostnames (Zen alert flood)#308
Merged
Merged
Conversation
DNSRecordCollector recorded every getAllByName() argument as an outbound hostname, including raw IP literals. When something resolves a private/internal IP literal directly (Reactor Netty DNS-resolver bootstrap resolving nameserver/gateway addresses, service discovery connecting by IP, a library building a private-IP matcher at startup, ...), the agent flooded the "new outbound connection" feature with private IPs on port 0. Skip recording into HostnamesStore when the looked-up host is a private IP literal (IsPrivateIP.isPrivateIp). Real DNS names that resolve to private IPs are still recorded by name; public IP literals are unaffected; SSRF/stored-SSRF, stats and outbound-domain blocking are unchanged. Pending ports are still consumed so they can't leak into a later lookup. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
bitterpanda63
approved these changes
Jun 26, 2026
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.
Summary
The Zen Java agent flooded the "New outbound connection detected" feature with private/internal IP addresses on port 0 (e.g.
10.0.0.0,172.16.0.0,192.168.0.0,169.254.0.0,100.64.0.0,127.0.0.1,10.20.x.x). This was reported by a customer after a Spring Boot 4.1 upgrade (Minze / "Lutastic API", agent v1.1.29).This PR stops the agent from recording private IP literals as outbound hostnames. Real DNS names (incl. internal ones that resolve to private IPs) are still recorded; public IPs and all security checks are unaffected.
Why the bug existed
DNSRecordCollector.report()is invoked from thegetAllByNamehook (InetAddressWrapper) and recorded everygetAllByName(host)argument intoHostnamesStore— the store that powers the outbound-domains/connections feature — without distinguishing a real domain from a raw IP literal:getAllByNamealso accepts IP literals (it just parses them, no DNS). So whenever the runtime resolves a private IP literal directly, the agent recorded it as a brand-new "outbound domain". Port is0because no HTTP URL/port is associated with these resolutions (URLCollectoronly registers a pending port forhttp(s)URLs).Observed sources of private-IP-literal
getAllByNamecalls:/etc/resolv.confand wildcard binds (0.0.0.0,::,10.x.x.x,192.168.x.x). In ECS/Fargate these are exactly169.254.169.253, VPC DNS10.x, etc.10.20.x.x).*.0.0CIDR base addresses in the alerts (10.0.0.0,172.16.0.0, …) match the RFC1918 ranges exactly, i.e. something resolves each range's base address once at startup.The framework version itself is not the cause (see below); the upgrade changed which HTTP client / resolver path is exercised.
The fix
DNSRecordCollector.report()returns early when the looked-up host is a private IP literal, before it records anything or runs outbound blocking:A first pass only skipped the
HostnamesStorerecord but still fell through to the outbound-blocking check, which blocks private IPs in lockdown mode. The early return skips both.keycloak.internal...) are not literals, so they still flow through: recorded by name, subject to lockdown, and SSRF-checked.hostname == ipis treated as "no resolution, safe").Behaviour
getAllByName("10.20.11.143"), or Netty bootstrap resolving0.0.0.0/ nameservers)http://10.0.0.1:8080)URLCollectorregisters the pending port, thengetAllByName("10.0.0.1")returns early. Nothing recorded, not blocked in lockdown, and the pending port is still consumed.keycloak.internal...)How it reproduces
A plain Spring Boot app + agent, making a
WebClient(Reactor Netty) call, is enough — the resolver bootstrap records private infra IPs on port 0. Recording is identical on Spring Boot 3.3.5 and 4.1.0 (so it is client/runtime-driven, not a framework-version regression).RestTemplateand the JDKHttpClientrecord the hostname instead and do not leak.How we tested it (e2e, offline)
Fully local, no cloud: a mock that captures the heartbeat payload (the
hostnamesarray that would be sent to Zen), a Spring Boot app run under the released agent vs the patched agent, probing each HTTP client against a hostname that resolves to a private IP.Result (Spring Boot 4.1.0, identical load):
intsvc.local,localhost0.0.0.0,10.2.0.1,::intsvc.local,localhostNames are preserved; private IP literals no longer reach the cloud.
CLI commands
Tests
testPrivateIpLiteralNotRecordedAsOutboundHostname— private IP literals (incl. RFC1918 base addresses,10.20.x.x,127.0.0.1) are not recorded.testPrivateIpLiteralWithPendingPortStillConsumedButNotRecorded— pending port consumed, nothing recorded.testHostnameResolvingToPrivateIpStillRecorded— internal DNS name still recorded by name.testPublicIpLiteralStillRecorded— public IP literals unaffected.testPrivateIpLiteralNotBlockedInLockdownMode— a private IP literal is not blocked in lockdown mode.testPrivateIpLiteralViaUrlInLockdownNotBlockedNorRecorded— private IP via URL: not recorded, not blocked, pending port consumed.🤖 Generated with Claude Code