Book 8 · Volume V — Security, Privacy & Compliance · Topic 1.2
Security Architecture
Trust boundaries · attack surfaces
10 min readStage 3 · Systems10 interview questions
Written byMaheshFounder · Senior Technical Architect
Chapter
Chapter 1 — Security as a Quality Attribute
Prerequisites
Topic 1.1
You will be able to
Identify trust boundaries in an architecture, assign security zones, define the controls every boundary crossing requires, inventory and measure attack surface, reduce it systematically, and document security architecture views that reviewers and auditors can follow
Security architecture describes how a system's structure enforces its security requirements: where trust changes (trust boundaries), what an attacker can reach or influence (attack surface), and which controls sit at each point.
Term
Definition
Trust boundary
A point where data or control passes between components with different trust levels
Security zone
A group of components with the same trust level and controls
Attack surface
The sum of entry points (network, API, human, supply chain, data) an attacker can use
Control
A mechanism that enforces a security requirement at a point
Table 1 — Vocabulary
Figure 1 — Trust boundaries — ShopNow
2Why It Exists
Attackers don't attack "the system"; they attack an entry point and move across boundaries. Making boundaries and surfaces explicit tells you where controls go and what to shrink.
Figure 2 — Perimeter vs boundaries everywhere
3Core Concepts
3.1 Trust Boundaries
Boundary (ShopNow)
From → to
Why trust changes
TB1
Internet → edge
Anonymous, hostile traffic
TB2
Edge → API gateway
Untrusted payloads, user tokens
TB3
Gateway → services
Internal but must be authenticated (zero trust)
TB4
Services → data stores
Highest-value assets
TB5
Services → partners (PayGrid, SMS)
External organisations
TB6
Staff/admin → production
Privileged humans
TB7
CI/CD → production
Code and images entering
Table 2 — Boundaries at ShopNow
Figure 3 — Security zones
Figure 4 — Controls at each boundary
Crossing checklist
Question
Authenticate
Who is the caller (user, service, partner)?
Authorise
May this caller do this action on this resource?
Validate
Is input well-formed, bounded, expected (schema, size, type)?
Encrypt
Is the channel protected (TLS/mTLS)?
Log
Is the crossing recorded for detection and audit?
Limit
Can the caller overwhelm the next zone (rate, size)?
# Istio: only the gateway and checkout may call pricing (TB3 enforced per identity)apiVersion: security.istio.io/v1kind: AuthorizationPolicymetadata: { name: pricing-allow, namespace: pricing }spec: selector: { matchLabels: { app: pricing } } action: ALLOW rules: - from: - source: principals: - cluster.local/ns/checkout/sa/checkout - cluster.local/ns/gateway/sa/gateway to: - operation: { methods: ["POST"], paths: ["/v1/quotes"] }
HCL
# TB4: database reachable only from app security group, no public accessresource "aws_security_group_rule" "orders_db_from_app" { type = "ingress" from_port = 5432 to_port = 5432 protocol = "tcp" security_group_id = aws_security_group.orders_db.id source_security_group_id = aws_security_group.checkout_pods.id}
JAVA
// TB2: strict input validation at the edge of the service (records + Bean Validation)publicrecord AddToCartRequest(@NotBlank@Pattern(regexp = "^[A-Z0-9-]{6,32}$") String sku,@Min(1) @Max(10) int quantity) {}@PostMapping("/cart/items")ResponseEntity<Void> add(@Valid@RequestBody AddToCartRequest req, Principal user) { … }
6Practical Examples
6.1 The forgotten boundary
A seller-portal "bulk upload" endpoint accepted CSV files and passed them to an internal import service. The internal service assumed its callers were trusted and didn't validate file size or formulas; a crafted CSV caused formula injection in exported reports. The upload was treated as a new boundary: size limits, schema validation, formula escaping and malware scanning.
6.2 Public ALB bypassing WAF
A scan found an ALB reachable directly from the internet, bypassing CloudFront and WAF. Fix: ALB only accepts CloudFront (managed prefix list + secret header), and a config rule alerts on new internet-facing load balancers.
6.3 Attack surface diet
Change
Result
Retired v1 mobile APIs
−210 endpoints
Moved internal admin APIs off public gateway
−120 endpoints
Bastions replaced by SSM Session Manager
0 SSH ports open
Distroless base images
CVEs per image −78%
Table 7 — Measured reduction
6.4 Worked example — boundary crossing analysis (checkout → PayGrid)
6.6 Worked example — attack surface inventory metrics
Metric
2024
2026
Internet-facing endpoints
480
96
Resources with public IPs
37
0
Humans with prod write access
64
9 (JIT for others)
Third-party scripts on checkout page
14
3 (SRI + CSP)
Table 10 — Surface as a tracked metric
6.7 Worked example — interview whiteboard
Prompt
Answer outline
"How do you approach the security architecture of a new system?"
"Draw the context and data flows, mark trust boundaries — internet, gateway, service-to-service, data, partners, admin, CI/CD — and group components into zones. At each crossing apply six checks: authenticate, authorise, validate, encrypt, log and limit. Inventory the attack surface across network, APIs, humans, supply chain and data, reduce it by removing, hiding and minimising, and track it as a metric with alerts for new public resources."
Table 11 — Structured answer
6.8 Worked example — admin boundary (TB6)
Control
Implementation
Identity
Workforce SSO with FIDO2 keys
Access
Read-only by default; JIT elevation (1 h) with ticket
Channel
SSM Session Manager (no SSH), private EKS endpoint via VPN
Audit
CloudTrail, session recordings
Break-glass
Sealed accounts, alarm on use
Table 12 — Privileged humans are a boundary too
6.9 Worked example — CI/CD boundary (TB7)
Threat
Control
Compromised dependency
SCA, pinned versions, SBOM
Malicious pipeline change
Protected branches, reviewed workflow changes
Stolen deploy credentials
OIDC federation to AWS (no static keys)
Unsigned images
Admission controller verifies Cosign signature
Table 13 — The pipeline is an attack surface
6.10 Worked example — browser boundary
Control
Setting
Content-Security-Policy
script-src 'self' + 3 hashed vendors
Subresource Integrity
On third-party scripts
Cookies
HttpOnly, Secure, SameSite=Lax
Clickjacking
frame-ancestors 'none'
Table 14 — The user's browser runs your code on a hostile boundary
6.11 Worked example — partner boundary (TB5) at PayGrid
Inbound partner call
Control
Identity
OAuth2 client credentials with private_key_jwt; optional mTLS for top partners
Tenant scoping
partner_id from token, never from request body
Validation
OpenAPI schema validation at gateway; size ≤ 64 KB
Rate
Per-partner token bucket
Outbound webhooks
Signed (HMAC), egress proxy blocks private IP ranges (SSRF)
Table 15 — Boundaries with other organisations need the strictest checks
6.12 Worked example — data boundary (TB4) review
Finding
Fix
Reporting tool connects to writer with superuser
Read-only role on replica
Lambda has rds:* on all clusters
Scoped to one cluster, IAM auth
S3 exports bucket readable by analytics account
Bucket policy with VPC endpoint condition
Table 16 — Data boundaries leak through over-broad permissions
7Common Problems & Mistakes
Mistake
Fix
Trusting internal callers
Authenticate every hop
Unknown public resources
Inventory + config rules
Validation only in UI
Validate at every boundary
Forgetting human/CI boundaries
Treat as TBs
Flat networks
Zones and SG references
Surface grows silently
Metrics and alerts
Table 17 — Mistakes and fixes
8Performance & Production Considerations
Consideration
Practice
mTLS overhead
~3% per hop; acceptable
Validation cost
Cheap; reject early
Continuous checks
AWS Config, Security Hub, external scans
Change reviews
New boundaries flagged in design review
Table 18 — Operating security architecture
Security controls at boundaries cost little at run time compared with the risk they remove. Istio mTLS adds a few per cent of CPU and well under a millisecond per hop with current sidecars or ambient mode, and schema validation is cheap, especially when it rejects bad input before any business logic runs. The bigger production concern is drift: new public resources, widened security groups and forgotten test endpoints appear with ordinary releases. Run AWS Config rules and Security Hub standards continuously, alert on any new internet-facing load balancer or public IP, and schedule external attack-surface scans. Treat certificate and secret rotation as automated operations rather than manual tasks, because expired certificates on internal mTLS are a common cause of self-inflicted outages. Finally, flag every design change that introduces a new boundary so that it gets a security review.
9Architecture & Design Considerations
Guideline
Detail
Minimise boundaries crossed by Sensitive data
Keep it in few services
Single, controlled entry points
CloudFront → gateway
Explicit zones in IaC
Tags, SGs, namespaces
Views in architecture docs
Boundaries, zones, identity
Table 19 — Design guidance
10Interview Questions & Answers
Q1L1 · BasicConcept
What is a trust boundary?
A trust boundary is a point where data or control passes between components with different levels of trust, so the receiving side cannot assume the input or the caller is legitimate. Typical boundaries are internet to edge, edge to API gateway, gateway to services, services to data stores, calls to and from partners, privileged humans entering production, and the CI/CD pipeline deploying code. They are where most vulnerabilities live: an unvalidated input, an unauthenticated call or data leaving unencrypted. Drawing them on the context and data-flow diagrams is the first step of security architecture, because every crossing then gets the same explicit set of controls.
Q2L1 · BasicConcept
What is an attack surface?
The attack surface is the sum of all entry points an attacker can reach or influence, not just open ports. It includes the network surface, such as public load balancers and IPs; the API surface, every exposed endpoint and version; the human surface, staff, sellers and contractors with access; the supply chain of libraries, base images and pipelines; data copies, such as exports, backups, logs and staging databases; and the control plane, meaning the cloud console, Kubernetes API and CI/CD. The larger it is, the more places need controls. ShopNow tracks it as a metric and cut internet-facing endpoints from 480 to 96 between 2024 and 2026.
Q3L2 · IntermediateConcept
What controls belong at a boundary?
Six checks belong at every crossing. Authenticate: establish who the caller is, whether user, service or partner, through tokens or mTLS identity. Authorise: decide whether this caller may perform this action on this resource. Validate: ensure the input is well formed, bounded in size and matches the expected type and schema. Encrypt: protect the channel with TLS 1.3 or mTLS. Log: record the crossing for detection and audit, without sensitive data such as card numbers. Limit: rate-limit and cap sizes so a caller cannot overwhelm the next zone. Applying the same checklist everywhere makes reviews consistent and makes a missing control obvious.
Q4L2 · IntermediateTricky
Why authenticate internal calls?
Because the network perimeter is not a guarantee of trust. If internal services accept any call from inside the VPC, one compromised pod, leaked credential or SSRF bug gives the attacker free lateral movement to everything, including the data stores. Zero trust treats gateway-to-service and service-to-service hops as real boundaries: each call carries a workload identity through Istio mTLS and is authorised per caller and operation with an AuthorizationPolicy, so at ShopNow only the gateway and checkout may call the pricing quote endpoint. It also limits the blast radius of internal mistakes, such as a misconfigured batch job, and produces an audit trail of who called what.
Q5L3 · Senior EngineerDesign
How do you reduce attack surface?
Work through a cycle of remove, hide, minimise, consolidate, restrict and measure. Remove unused endpoints, old API versions, stale feature flags and idle resources. Hide internal APIs so they are not routable from the internet, and use private endpoints for the EKS API and AWS services. Minimise what runs, with distroless base images, disabled HTTP methods and fewer libraries. Consolidate public traffic through one path, CloudFront then ALB. Restrict network paths with security groups that reference other security groups rather than 0.0.0.0/0. Then measure, with a monthly inventory diff and alerts on new public resources. ShopNow removed 330 endpoints and every open SSH port this way.
Q6L3 · Senior EngineerScenario
How do you prevent WAF bypass?
Make the origin reachable only through CloudFront, so there is no direct path around the WAF. Restrict the ALB's security group to the AWS-managed CloudFront origin-facing prefix list, and have CloudFront add a secret custom header that an ALB listener rule checks, rejecting requests without it; rotate that secret regularly. Better still, use CloudFront VPC origins, so the ALB sits in private subnets with no public exposure at all. Then detect regressions with an AWS Config rule or Security Hub control that alerts on any new internet-facing load balancer, plus regular external scans. ShopNow found its bypassing ALB through exactly such a scan.
Q7L4 · Technical ArchitectTricky
Which non-network surfaces matter?
The ones teams forget because no port scan shows them. Humans: staff, sellers and contractors with production access, protected by SSO, phishing-resistant MFA and just-in-time elevation. The supply chain: hundreds of open-source libraries and base images, controlled with SBOMs, pinned versions, scanning and signatures. CI/CD: a pipeline that can deploy to production is effectively an administrator, so it needs protected branches, reviewed workflow changes and OIDC federation instead of static keys. Data copies: exports, backups, logs and staging databases often hold production data under weaker controls. The browser is another surface, where third-party scripts run on your own checkout page.
Q8L4 · Technical ArchitectConcept
What's a security zone?
A security zone is a group of components that share the same trust level and the same set of controls, so boundaries lie between zones rather than between every pair of components. ShopNow uses five: public for CloudFront and WAF; a DMZ for the API gateway and BFFs; application for checkout, pricing and orders; data for Aurora, Valkey and MSK; and restricted for KMS administration, break-glass roles and CI signing keys. Each component is assigned exactly one zone, and the zone defines who may talk to it and how. Zones are expressed in infrastructure as code through subnets, security groups, Kubernetes namespaces and tags.
Q9L5 · Solution ArchitectDesign
How do you keep surface under control over time?
Treat attack surface as a tracked metric with automated detection, not a one-off review. Keep an inventory of internet-facing endpoints, public IPs, privileged humans and third-party scripts, compare it every month, and set a target for each figure. Enforce guardrails continuously with AWS Config rules, Security Hub and external scans that alert on new public resources or overly wide security group rules. Add a design-review question for any change that creates a new boundary, such as a file upload or a partner integration. Retire old API versions on a published schedule. Assign an owner, because without one the surface quietly grows with every release.
Q10L5 · Solution ArchitectDesign
What views document security architecture?
Five views, each serving a different audience. A context view with trust boundaries shows external actors and where trust changes, for everyone. A data-flow view with classification shows where sensitive data travels and is stored, for privacy teams and auditors. A network and zone view shows VPCs, subnets, security groups and endpoints, for the platform team and auditors. An identity view shows who authenticates where and how tokens flow, for engineers. A control-mapping view links each requirement to a control and its evidence, for compliance frameworks such as PCI-DSS v4. Keep them in the architecture documentation and update them whenever a boundary changes.