One parser bug, every credential
Tallow, a small payments company, ran its merchant API on servers that did everything: they parsed each request, checked it, wrote to the database, called the card vault and signed outbound webhooks. Then a flaw in the library that parsed merchants' JSON let a crafted request run code on one of them, and the attacker read the process environment: the database password, the vault credential and the webhook signing secret. The bug was in parsing; the damage came from what the parsing host held.
Patching the library closed that bug and not the next one. Code that reads raw bytes from the internet is best assumed to have flaws, so the team asked a different question: what should such a flaw be worth? The Gatekeeper pattern answers it by splitting one host into two. The gatekeeper faces the internet, receives every request, checks it and forwards the ones that pass; it holds no credentials for the database, the vault or any third party. The trusted host behind it holds those credentials and does the work, and nothing outside can reach it except through the gatekeeper.
The trusted host has no public address and accepts calls only from the gatekeeper. The gatekeeper holds no database, vault or webhook credentials.
A narrow road between the two
The split is only as good as the path between the hosts. If the trusted host accepts calls on any path that does not go through the gatekeeper, from the internet or from elsewhere on the internal network, an attacker who reaches that path bypasses the gatekeeper. So the trusted host runs on its own compute boundary, with no public endpoint, and accepts connections only from the gatekeeper, on one port, over TLS. Where the platform offers it, mutual TLS or a workload identity lets the trusted host check that the caller really is the gatekeeper; Secrets management & encryption describes both. The gatekeeper does hold a credential that proves this identity, often short-lived and issued by the platform, so a breached gatekeeper can still call the trusted host; the trusted host grants that identity nothing beyond calling its own API.
The road should be narrow in what it carries, too. The trusted host offers a short list of operations, such as create a payment, refund a payment and fetch a payment's status, each with a fixed shape. It does not offer "run this query" or a generic proxy to the internal network, because then a breached gatekeeper could ask for anything and the split would protect nothing.
What the gatekeeper does with a request
- Validates it against what this endpoint accepts: the method, the content type, a size limit and, once the body is parsed, a schema with the expected fields, types and ranges. A refund for minus 40 euros, an unknown field or a 30 MB body is rejected here.
- Sanitises it: normalises encodings and builds a fresh request in the internal format from the validated fields alone.
- Forwards that rebuilt request, never the original bytes, and passes the trusted host's answer back.
This is the answer to Tallow's breach: the code that parses untrusted JSON now runs on a host that holds no credentials for the data or the services behind it, and the trusted host parses only the fixed internal format the gatekeeper builds, which it still checks, because a breached gatekeeper can send anything. A gatekeeper may also check the caller's credentials and apply rate limits; it does no business processing and reads no stored data, so that a flaw in it reaches as little as possible.
Validated does not mean safe
A merchant's shop name of O'Brien & Sons passes every rule the gatekeeper has, and it still breaks a SQL statement built by concatenating strings on the trusted host. Validation at the broker narrows what reaches the backend; it does not make input safe to use. The root defences against injection and cross-site scripting sit where the input is used: parameterised queries where it meets the database, output encoding where it meets a page. Web application security: injection, XSS, CSRF & SSRF explains each of them. The trusted host also re-checks its own rules, such as a refund never exceeding the original charge, because it is the one that knows them.
When the gatekeeper itself is breached
Suppose the next flaw lands on the gatekeeper. The attacker does not get the database password or the vault credential, which never touched it, but three things are still within reach:
- Every request that passes through while the attacker is there, readable after TLS ends at the gatekeeper, card numbers included unless the merchant's page sends them to the vault directly.
- The trusted host's narrow API. If the trusted host believes a header from the gatekeeper saying which merchant is calling, the attacker can call it as any merchant. Passing the merchant's own signed token through, for the trusted host to verify itself, keeps that decision on the inner side, though the attacker can still replay the tokens passing through until they expire.
- Availability: a gatekeeper the attacker controls can drop or delay everything.
The split also has running costs: an extra network hop on every request, and a tier that can become a single point of failure, so gatekeepers run as several identical instances behind a load balancer.
Next to a WAF and an API gateway
A web application firewall filters requests mainly by rules written for common attacks rather than for your endpoints (Edge protection: WAF, DDoS & defence in depth); a gatekeeper decides per endpoint, schema and caller, and the two stack well, a WAF at the edge and a gatekeeper behind it. An API gateway routes and shapes traffic (API gateway & the edge), and Gateway Offloading moves TLS termination and token checks into it. Either can play the gatekeeper's part, as long as it holds no credentials for the data or the services behind it and reaches no data store. Valet Key goes the other way for large files: the client gets a scoped, expiring grant to the storage itself, and the app stays out of the data path.
Quarantine is the other checkpoint in this family, for a different moment: it holds an artifact, a package or a file, until checks pass and it becomes available. The gatekeeper checks each request at request time.
Where to draw it
No Challenge asks for a Gatekeeper by name. The closest is Payment Processing System, whose brief asks for card payments handled securely, webhook callbacks from payment providers and sensitive data encrypted. Draw the public API and the webhook ingress as hosts with no edge to the database or the vault and no credentials for either, and give only the service behind them those edges and credentials, with the one path between labelled by what it carries. In API Gateway Patterns, list what the offloading gateway holds once it terminates TLS and checks tokens, and mark which of those items a gatekeeper could keep, and which, such as a credential for the data or the services behind it, it would leave to the service behind it.