Trust Boundaries
5 exercises — master trust boundary vocabulary: what trust boundaries are and why they matter, the crunchy-outside anti-pattern, database credential scoping, webhook signature verification, and context switching injection vulnerabilities.
0 / 5 completed
Trust boundary quick reference
- Trust boundary — where data crosses from one trust level to another; every trust boundary crossing requires authentication, authorisation, and validation.
- Trust levels — Internet (untrusted) → authenticated user → internal service → database. Each step up requires validation.
- "Crunchy outside, soft inside" — anti-pattern: only validating at the perimeter. Single bypass exposes all internal services.
- Credential scoping — separate DB users with minimum permissions per component. Frontend user ≠ admin user.
- Webhook signatures — HMAC-SHA256 verification required even for "trusted" partners. HTTPS alone does not verify sender identity.
- Context switching vulnerabilities — user input in SQL context → SQL injection; in HTML context → XSS; in shell → command injection. Fix: parameterise and encode for each context.
- DFD — Data Flow Diagram. Dashed rectangles = trust boundaries. All flows crossing dashed lines need security controls.
1 / 5
A security engineer draws a system diagram and says: "I've identified several trust boundaries in this system. Can someone explain what a trust boundary is and why it matters for security design?"
Trust boundaries — wherever data or control transitions from one trust level to another, that boundary requires explicit security enforcement. All vulnerabilities can be traced to insufficient validation at a trust boundary.
Trust levels in a typical web application:
Why every vulnerability traces to a trust boundary:
• SQL injection: user input (trust level 1) crosses a trust boundary into SQL execution (trust level 3) without parameterisation
• XSS: user input crosses into the DOM execution context without output encoding
• SSRF: attacker controls a URL that crosses from user input into internal network requests
• Privilege escalation: lower-trust code gains access to higher-trust resources due to missing authorisation check at the boundary
Data Flow Diagrams (DFDs) and trust boundaries:
DFDs are the standard tool for visualising trust boundaries. A rectangle on a DFD represents a trust boundary (often drawn as a dashed line). Every data flow that crosses a dashed line requires: authentication (who is crossing?), authorisation (are they allowed to cross?), and input validation (is the data safe?)
Key vocabulary:
• Trust boundary — the line between two trust levels in a system; all data crossing this boundary must be validated and authenticated
• Trust level — the degree of confidence in the origin, integrity, and intent of data or a caller; lower trust = more validation required
• DFD (Data Flow Diagram) — a diagram showing processes, data stores, external entities, and data flows; trust boundaries are drawn as dashed rectangles
• Untrusted data — any data originating from a lower-trust zone; must be validated before use regardless of apparent source
Trust levels in a typical web application:
| Zone | Trust level | Required controls at boundary crossing |
|---|---|---|
| Internet / public | 0 — fully untrusted | TLS, WAF, rate limiting, full input validation |
| Authenticated user session | 1 — authenticated but untrusted for data content | Auth verification, session validation, input sanitisation |
| Internal application logic | 2 — trusted for own processing | Parameterised queries, output encoding, service auth |
| Database layer | 3 — high trust for stored data | DB user least privilege, encryption at rest, audit logging |
| External third-party API | 1 — untrusted (even if "partner") | Response validation, schema enforcement, error handling |
Why every vulnerability traces to a trust boundary:
• SQL injection: user input (trust level 1) crosses a trust boundary into SQL execution (trust level 3) without parameterisation
• XSS: user input crosses into the DOM execution context without output encoding
• SSRF: attacker controls a URL that crosses from user input into internal network requests
• Privilege escalation: lower-trust code gains access to higher-trust resources due to missing authorisation check at the boundary
Data Flow Diagrams (DFDs) and trust boundaries:
DFDs are the standard tool for visualising trust boundaries. A rectangle on a DFD represents a trust boundary (often drawn as a dashed line). Every data flow that crosses a dashed line requires: authentication (who is crossing?), authorisation (are they allowed to cross?), and input validation (is the data safe?)
Key vocabulary:
• Trust boundary — the line between two trust levels in a system; all data crossing this boundary must be validated and authenticated
• Trust level — the degree of confidence in the origin, integrity, and intent of data or a caller; lower trust = more validation required
• DFD (Data Flow Diagram) — a diagram showing processes, data stores, external entities, and data flows; trust boundaries are drawn as dashed rectangles
• Untrusted data — any data originating from a lower-trust zone; must be validated before use regardless of apparent source