Security Architecture
Security architecture is the practice of deciding where the walls go before anyone argues about vendor logos. Its output is a small set of diagrams and rules that let hundreds of engineers make consistent choices without asking a central team every week: which traffic may cross a boundary, where credentials live, what happens when a control fails, and which layer is responsible when two of them disagree. The discipline matters because inconsistent security is almost as fragile as none â two teams protecting the same data with overlapping controls will eventually disable each other's assumptions during an incident.
Defense in depth only works when layers fail independently
Layering is frequently faked. Five controls that all depend on the same identity provider, the same shared secret store or the same unpatched kernel are not five layers; they are one layer with five invoices. The test for genuine depth is independence: a bypass that defeats one control should leave others operational, and those others should be owned by a team with different tooling and different failure modes.
| Layer | Responsibility | Example controls | What it assumes |
|---|---|---|---|
| Perimeter | Filter bulk hostile traffic | WAF, DDoS protection, edge filtering | Attacks arrive from outside |
| Network | Constrain movement between systems | Segmentation, egress allow lists, mTLS | Perimeter is already breached |
| Host | Resist compromise of a machine | Hardening, patching, EDR, minimal images | Attackers land on endpoints |
| Application | Enforce intent of each action | Authentication, authorization, validation | Code runs in a hostile context |
| Data | Protect the asset itself | Encryption, masking, backup, classification | Every layer above has failed |
Reading the last column keeps the design honest: each layer is justified by the failure of the one before it. If a proposed control does not correspond to a realistic failure beneath it, it is probably duplication, and duplication is what teams cut first when budgets tighten.
Six principles you can apply to a concrete decision
Principles earn their place by resolving arguments quickly. Least privilege says the payment service reads one table, not the schema. Fail secure says a crashed authorization service denies rather than defaults to allow. Complete mediation says every request is checked, including the ones the cache has seen before. Separation of duties says the deployer is not the approver of the same change. Economy of mechanism says a control a junior engineer can explain is more likely to be deployed correctly than a clever one nobody can audit. Open design says secrets inside an algorithm are not a security strategy.
| Principle | The question it settles | Failure you see when it is ignored |
|---|---|---|
| Least privilege | What scope does this role need? | Compromised service account reaches everything |
| Fail secure | What is the default under error? | Outage silently becomes an open door |
| Complete mediation | Is this request re-checked? | Cached token outlives the revocation |
| Separation of duties | Who can complete this alone? | One stolen account ships and approves code |
| Economy of mechanism | Can the team explain the control? | Misconfiguration nobody notices for years |
| Open design | Does security hide inside the implementation? | Vendor lock-in and unreviewable crypto |
Zones and conduits: where the boundaries actually go
Group systems by what they protect and by what happens when they are compromised, then define the conduits between them explicitly. A zone boundary should be a place where identity is established, traffic is logged and policy is enforced â a shared firewall rule base with eight hundred entries is a boundary in name only.
# Zone and conduit definition for a three-tier service
zones:
untrusted:
classification: public
members: [cdn, public-dns]
dmz:
classification: public-facing
members: [waf, edge-lb]
ingress:
from: untrusted
allow: [443]
application:
classification: internal
members: [api-1, api-2, worker-1]
ingress:
from: dmz
allow: [8080]
require: [mtls, workload-identity]
datastore:
classification: restricted
members: [postgres-primary, redis]
ingress:
from: application
allow: [5432, 6379]
require: [mtls]
management:
classification: restricted
members: [bastion, ci-runner]
ingress:
from: []
note: "interactive access only via just-in-time elevation"
logging:
record_at: [dmz, application, datastore, management]
retention_days: 400
alert_on: ["denied_flow", "new_conduit", "policy_drift"]
The empty ingress list on the management zone is deliberate. Administrative planes should have no standing network path at all; access is granted on demand for a bounded window, which removes the most attractive lateral-movement route an intruder can find.
Choosing a pattern for the workload
Not every system warrants the same architecture. The table below is the decision most teams get wrong by copying a reference design from a company with different constraints.
| Pattern | Fits when | Main weakness to mitigate |
|---|---|---|
| Monolith behind a strong edge | Small team, single deployment unit | Blast radius concentrated in one process |
| Tiered three-layer service | Clear request, business and data separation | Tiers drift apart and share databases |
| Service mesh with mTLS | Many services, no central way to encrypt or authenticate | Operational complexity, opaque failure modes |
| Event-driven with signed payloads | Async workflows, multiple consumers | Replay and ordering attacks on the bus |
| Serverless functions | Spiky, short-lived work | Long-lived roles and over-permissive triggers |
| Edge-computed logic | Latency-sensitive, low compute needs | Secrets and validation running client-adjacent |
Choose the pattern that matches your team's ability to operate it. A mesh with five engineers produces more security incidents than a well-hardened monolith, because policy that nobody understands is policy nobody maintains.
Data-layer controls that survive a perimeter breach
If every control above the data fails, encryption and access logs are what remain. Encrypt at rest with keys the application can only use under conditions you control, separate duties between the holder of the ciphertext and the holder of the key, and keep plaintext out of logs by design rather than by review.
import os, json, base64
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
KEY = base64.urlsafe_b64decode(os.environ["APP_DATA_KEY"])
def protect(record, purpose):
"""Encrypt a record bound to its purpose, so a leak cannot be replayed elsewhere."""
body = json.dumps(record, sort_keys=True).encode()
nonce = os.urandom(12)
aad = purpose.encode() # associated data: purpose + record id
ct = AESGCM(KEY).encrypt(nonce, body, aad)
return {"v": 1, "nonce": base64.b64encode(nonce).decode(),
"ct": base64.b64encode(ct).decode()}
def reveal(blob, purpose):
"""Decrypt only when the caller states the same purpose it was written for."""
if blob.get("v") != 1:
raise ValueError("unsupported envelope version")
try:
raw = AESGCM(KEY).decrypt(base64.b64decode(blob["nonce"]),
base64.b64decode(blob["ct"]),
purpose.encode())
except Exception as exc:
raise PermissionError("purpose mismatch or corrupted record") from exc
return json.loads(raw)
sample = protect({"customer_id": 4812, "pan": "4111111111111111"}, "payment-auth")
print(reveal(sample, "payment-auth"))
Binding the purpose into the authenticated data means a database snapshot copied by an attacker cannot be decrypted by a service built for a different job, even if that service holds a legitimate key. Pair this with per-tenant key scoping and access logging at the query layer, and a perimeter failure stops being a data breach.
Documenting decisions so the next engineer knows why
Architecture documents rot fastest at the point where rationale lives. Record each significant decision as a short entry containing the context, the options considered, the choice, and the condition that would make you revisit it. Two years later, when someone proposes removing mutual TLS because a benchmark looks slow, the revisit condition settles the argument without a meeting.
â ī¸Two controls, one assumption
Common Mistakes
Stacking controls that all depend on one identity provider
Fix: Check independence explicitly: each layer should survive the failure of the layer above with different tooling and owners.
Copying a reference architecture designed for a much larger organization
Fix: Match the pattern to the team that must operate it, and record the trade-off you accepted.
Leaving an administrative plane reachable on the normal network
Fix: Remove standing ingress entirely and grant just-in-time elevation with logging and an expiry.
Encrypting data without separating ciphertext from key custody
Fix: Split the holder of the encrypted data from the holder of the key, and log every decryption purpose.
Documenting the design but not the reasoning behind it
Fix: Keep a decision record with context, options, choice and revisit condition so future changes are judged fairly.
Best Practices
- Derive zones from blast radius and data classification rather than from subnet history
- Define conduits explicitly and alert on any flow that creates a conduit without review
- Put fail-closed defaults in code so an outage cannot widen access
- Keep a decision record for every architectural choice with its revisit trigger
- Run a design review against the principles table before the first sprint of a new system
Key Takeaways
- Depth is only real when the layers fail independently under different owners
- Each layer exists because the layer below it is assumed to fail, which is why the assumption column matters
- Principles are decision tools: least privilege, fail secure, complete mediation and separation of duties settle most arguments
- Zones need explicit conduits and an administrative plane with no standing ingress
- Purpose-bound encryption and decision records protect the asset and the reasoning long after the design review