DEV Community

Cover image for The registry said 127.0.0.1. Docker went.

The registry said 127.0.0.1. Docker went.

samuel mbabhazi on November 25, 2026

Shipkeep is an open-source platform to deploy apps on your own servers. You give it an image reference, and an agent on the server asks the Docker ...
Collapse
 
analista_83 profile image
Sammi De Blas •

The split between who checks the name and who opens the connection is the real bug. The control plane validates a DNS name and then hands the same name to the daemon, which resolves it again on the node, so the check is advisory. Pinning the resolved address in the pull request, or running the pull through the same resolver as the check, closes the gap you tested.

Collapse
 
samuelmbabhazi profile image
samuel mbabhazi •

Agreed, that split is the bug. A check that runs in one place on a name, while the connection opens somewhere else on a fresh lookup, can't hold.

Pinning the address wouldn't have been enough, though. The lab showed two more paths the control plane never sees: the daemon follows blob redirects anywhere, plain HTTP included, and calls whatever token service the registry names in its 401. Pulling by IP also breaks TLS, since the certificate names the host.

So the fix moves the check to where the connection opens:

  • The Docker daemon on each node pulls through a small egress proxy (a mode of the agent binary, its own service and user). It accepts CONNECT only, resolves the name itself, and checks the address in the dialer, on the socket it actually connects to. A second DNS answer can't change it. Loopback, private, link-local, CGNAT and reserved ranges are refused, IPv4-mapped and NAT64 forms included.
  • Go never sends loopback requests to a proxy, so an nftables rule rejects new connections from the daemon's cgroup to 127.0.0.0/8 and ::1, except the proxy and the local resolver.
  • Before each pull, the agent checks that the daemon still reports exactly that proxy, and refuses the pull otherwise.

The control plane keeps its own check, so a bad reference never reaches a node, but the node no longer relies on it. ADR 0023 has the lab results: github.com/shipkeepdev/shipkeep/bl...

Collapse
 
analista_83 profile image
Sammi De Blas •

Log the dialed address first, it is cheap. Without it a name resolving to a private range leaves nothing to audit.

Collapse
 
samuelmbabhazi profile image
samuel mbabhazi •

Agreed, and the version in the post didn't do it: a tunnel logged its host, its port and its outcome, not the address. That has changed since (#535, on main, in the next release). Each tunnel now logs the address the socket connected to, the one the guard checked, not a second lookup. Each refusal logs its reason and the addresses the name gave, so a name that resolves to a private range leaves that address in the journal. Headers and paths are still never logged.

Collapse
 
analista_83 profile image
Sammi De Blas •

Logging the dialled address per tunnel makes the guard auditable, a refusal without it cannot be replayed later.

Thread Thread
 
samuelmbabhazi profile image
samuel mbabhazi •

Yes, and that's why refusals log their addresses too, not only tunnels (#535, in v0.1.0-alpha.8). A refusal logs its reason along with the addresses that decided it:

for not_public, the answers that weren't public. A name that mixed one private answer with public ones logs only the private one.
for unreachable, the addresses that never answered.
Each line holds exactly what the guard judged, so the decision can be checked again later, against the same rules or newer ones.

The one case with nothing to replay is a name that never resolved. It logs unresolved with an empty list, because there was no answer to keep.

Collapse
 
analista_83 profile image
Sammi De Blas •

Checking in the dialer is the right place, a second DNS answer cannot change the socket already open.

Collapse
 
samuelmbabhazi profile image
samuel mbabhazi •

Yes, that's why it moved there. The control plane checked one answer, and then the Docker daemon resolved the name again on its own. Control runs on the address the socket is about to connect to, after every lookup, so there is no gap left between the check and the connect. A second answer can only lead to a new socket, and that one goes through the same check.

Collapse
 
analista_83 profile image
Sammi De Blas •

Checking after every lookup closes the gap, but the log still needs the address dialled, not the name asked.

Thread Thread
 
samuelmbabhazi profile image
samuel mbabhazi •

Agreed, and it's in now: v0.1.0-alpha.8, released this morning, came out of your earlier comment (#535). The egress proxy now logs the address the socket connected to, the same one the dialer's check passed. It is never resolved a second time:

"msg":"egress tunnel","host":"registry.example.com","port":443,"address":"8.8.8.8:443"
A refusal names the addresses it was about. A name with one private answer among public ones logs only that answer:

"host":"mixed.example.com","port":443,"addresses":["169.254.169.254:443"]
So a name that maps to the wrong socket now shows up in journalctl -u shipkeep-egress, next to the name that was asked. Headers, paths and credentials still stay out of the log.

Collapse
 
analista_83 profile image
Sammi De Blas •

One gap left: log the resolved address per pull. Then a name-to-socket mismatch shows in the audit, not in an incident.

Collapse
 
samuelmbabhazi profile image
samuel mbabhazi •

Fair point, and it is a gap today. The proxy checks the address the socket actually dials (the check runs in the dialer, after resolution), so a name that resolves somewhere private is refused. But what it logs is the host and port, plus the reason for a refusal. The address it connected to, or refused, is not recorded, and those lines stay in the server's journal, not in the control plane's audit log.

Two steps, then. First, log the dialed address on every tunnel and every refusal, which is a small change. Then put it next to the pull in the deployment's record, so a name that resolved somewhere unexpected shows up where people already look. The second part needs the proxy to report to the agent, which it does not do yet. Thanks for pushing on this.