Trust Boundaries and Attack Surface

Topics Covered

Trust and Where It Changes

What trust means here

Boundaries you can see

Boundaries you cannot see

The confused deputy

Implicit trust and its cost

Crossing a boundary safely

Who decides where boundaries are

A worked example

Every system decides, explicitly or by accident, which inputs it believes. A service that reads a user identifier from a header believes whoever set the header. A job that processes files from a bucket believes whoever could write to the bucket. A front end that hides an admin button believes the user will not call the admin endpoint directly. Security engineering starts by making these beliefs visible and asking, for each one, whether it is justified. The places where the answer changes are trust boundaries, and most vulnerabilities are a failure to check something at one of them.

What trust means here

Trust in this sense is not a feeling about people. It is a statement about what a component assumes of its inputs: that they are well formed, that they come from who they claim to come from, that the sender was allowed to send them, and that they have not been altered on the way. A component that trusts an input skips checks it would otherwise perform. That is often reasonable, because checking everything everywhere is expensive and duplicative, but it is only safe when something upstream really did perform those checks and nothing can bypass that upstream component.

Boundaries you can see

Some boundaries are obvious. The edge between the internet and a public API is one, and almost every team knows to authenticate requests and validate input there. The boundary between a user's browser and the server is another, although teams sometimes forget that everything in the browser, including front end validation, hidden fields and disabled buttons, is under the user's full control. The boundary between the system and a third party it calls, such as a payment provider or a webhook sender, is a third. In each case data arrives from somewhere the system does not control and must be treated as potentially hostile.

Teams also forget that the boundary between the internet and the application includes everything in the request, not only the obvious body fields. Headers such as the forwarded client address, the host name, cookies, query parameters and even the request path are all supplied by the caller. Applications that use the forwarded address for rate limiting or geolocation, or the host header to build password reset links, have been exploited repeatedly because those values looked like infrastructure metadata rather than user input. A useful rule is that any byte arriving from outside is user input until a component the system controls has replaced or verified it.

Boundaries you cannot see

Other boundaries are less obvious because they lie inside what looks like one system. A queue that several services write to is a boundary, because a compromise of any writer lets it send messages to every reader. A shared database is a boundary between all the services that connect to it. A cache that stores rendered pages is a boundary between users if keys are built carelessly. A configuration store is a boundary between whoever can edit configuration and the services that read it. These internal boundaries are where many serious incidents begin, because each side assumes the other is trustworthy and nobody checks.

All 14 internal endpoints trusted a gateway header. One was also exposed through a load balancer rule, so any caller could set the header and act as any user.

The confused deputy

A recurring failure at boundaries is the confused deputy: a component with privileges that acts on behalf of a less privileged caller without checking whether the caller was entitled to the action. A file conversion service with read access to every bucket that converts any path a user names, a backend that fetches any URL a user supplies using its own network position, and an internal admin service that performs any operation the support tool forwards are all deputies. The fix is the same in each case: the deputy must decide whether this caller may do this thing, not only whether the deputy itself may.

Implicit trust and its cost

Implicit trust is attractive because it is cheap. If the gateway authenticates the user, every downstream service can read the identifier from a header and skip authentication. If the network is private, services can skip transport security. If only the front end calls an endpoint, it can skip authorization. Each shortcut is fine as long as its assumption holds. The trouble is that assumptions decay: a new route is added to the load balancer, a partner is given network access, a debugging tool calls the endpoint directly. The shortcut then becomes a vulnerability without any change to the code that relies on it.

Crossing a boundary safely

Data crossing a boundary should be authenticated, so the receiver knows who sent it; authorized, so the receiver knows the sender may make this request; validated, so the receiver knows it is well formed and within expected limits; and, where it travels over a network, protected in transit. Not every boundary needs every check in full. A message on an internal queue might carry a signed identity rather than repeat a full login, and a call between two services in the same trusted zone might rely on mutual TLS for authentication. What matters is that the checks at each boundary are chosen deliberately and written down.

Of 62 boundary crossings, internet facing ones were checked 95 percent of the time, while queue and shared database crossings were checked under half the time.

Writing the boundary checks down also makes them reviewable. A short table per service, listing each input channel, the identity that is established for it, the authorization performed and the validation applied, lets a reviewer see at a glance where a check is missing. It also gives new team members a precise statement of what the service relies on its neighbours for and what it verifies itself, which is exactly the knowledge they need when they add a new route or a new consumer and must decide whether the existing checks still cover it.

Who decides where boundaries are

In a well run system, boundaries are a design decision made deliberately and recorded, not an accident of how the network happened to be configured. Architecture documents should state which zones exist, what may cross between them, and what checks each crossing requires. When a team proposes a new connection, such as giving an analytics job direct read access to a production database, the question is whether it creates a new boundary crossing and what checks it needs. Making this a routine part of design review keeps the set of boundaries understood as the system grows, instead of discovered during an incident.

A worked example

Consider a document service that lets users upload files, stores them in a bucket and generates previews with a worker. The obvious boundary is between the user and the upload API, where authentication, size limits and type checks belong. Less obvious is the boundary between the bucket and the preview worker: the worker reads files that came from untrusted users and parses them with complex libraries, so it should run with minimal privileges in an isolated environment, because a parser bug could let a malicious file run code. Another is the boundary between the preview output and other users' browsers, where previews must be served from a separate domain so they cannot run script in the main application. Each boundary implies a specific control, and missing any one leaves a gap that the others do not cover.

The rest of this lesson builds on this view. Once boundaries are visible, the attack surface is simply the set of places where they can be crossed, validation is what happens on the receiving side of each crossing, and reduction and internal segmentation are ways of having fewer and stronger crossings.

Every belief about an input is a trust decision

A trust boundary is wherever a component receives data from something less trusted. Internal queues, shared databases, caches and configuration stores are boundaries too. At each crossing, decide deliberately which authentication, authorization, validation and transport checks apply, and beware deputies that act with their own privileges on a caller's request.