System design · Identity, access, encryption and secrets

System design security explained

System design security means deciding who may perform each action, protecting data across every trust boundary, and limiting the damage when a credential or service is compromised. Connect each control to a specific threat, including the paths used by workers, exports and operators.

Updated · 5 min read

A document request crosses an encrypted transport boundary, an identity check and an object permission check before reaching private storage.

System Design Security architecture diagram

A document request crosses an encrypted transport boundary, an identity check and an object permission check before reaching private storage.

The short version

  • TLS protects a connection. Disk encryption protects stored bytes. Neither decides who may read a document.
  • Authentication says who the caller is. Authorisation checks this action on this object, on every request.
  • Workers, exports, backups and operators need their own narrow identities and the same permission checks.
  • A signed token isn't encrypted and isn't instantly revocable. Name where revocation actually takes effect.

Clarifying questions to ask first

  • Which data needs protection? (Assume a document service with private documents, public share links and account credentials.)
  • Who can access each document? (Assume tenants have members and administrators, and sharing one document grants nothing else.)
  • Who reads plaintext? (Assume the document API, for authorised requests; not a backup operator.)
  • What happens on revocation? (Assume new reads stop promptly, and the product states what happens to existing downloads and share links.)
  • What runs without a user? (Assume indexing and export jobs with their own identities, narrower than a tenant administrator's.)

Threat models and trust boundaries

Trace the journey: browser to edge, the document API checks access, storage returns content, a worker indexes it later, and a support operator has a separate admin path. At each boundary, ask what the receiver can trust about the caller, the object and the metadata. A stolen credential means session revocation; a leaked snapshot, which keys read it; a compromised indexer, whether it reads every tenant.

OWASP's threat-modelling questions: what are we building, what can go wrong, what will we do, is it enough (https://cheatsheetseries.owasp.org/cheatsheets/Threat_Modeling_Cheat_Sheet.html).

Encryption in transit and at rest

TLS 1.3 (RFC 8446, https://www.rfc-editor.org/rfc/rfc8446) protects one connection; the client must validate the expected identity, not just any certificate. If TLS ends at the edge, the edge sees plaintext and edge-to-API is a separate connection. A queued message isn't covered by transport encryption. See networking basics.

Disk encryption doesn't stop an app with legitimate access returning plaintext to the wrong user. Envelope encryption keeps an encrypted data key beside the data (AWS KMS, https://docs.aws.amazon.com/kms/latest/developerguide/data-keys.html), so ciphertext access differs from decrypt access. Check backup, restore and app identities separately, and test that key versions still exist; deleting the last key makes retained backups unreadable.

Authentication versus authorisation

OWASP recommends deny by default and a permission check on every request (https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html). A hard-to-guess document ID isn't a permission check. Derive tenant and principal from trusted identity state, never from a tenant ID in the request, and resolve the document's real owner.

Check the export and thumbnail routes too, and make a removed membership affect an old browser tab's next request. Workers need service identities; a private network grants nothing. The API gateway can reject invalid sessions, but only the document service knows whether this object is shared with this caller.

Sessions, JWTs and revocation

A server-side session keeps mutable state behind an opaque ID. A JWT (RFC 7519, https://www.rfc-editor.org/rfc/rfc7519) is signed, not necessarily encrypted, so keep secrets out of its claims. Validate issuer, audience and lifetime as well as the signature; decoding isn't accepting. RFC 8725 covers explicit algorithm checks and token substitution (https://www.rfc-editor.org/rfc/rfc8725), so use a maintained library and keep user and worker tokens distinct.

A self-contained token stays valid until something rejects it. A short expiry limits that window but is a threat-model choice, not immediate revocation. Decide how sign-out, suspension and membership removal take effect.

Passwords and account recovery

Store a verification hash, never a decryptable copy. OWASP prefers Argon2id where available, with a unique salt and stored parameters; a pepper lives apart from the password database (https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html). Tune parameters to your capacity, because attackers can drive costly verification even when every attempt fails.

Recovery bypasses the password, so it's inside the same boundary. Test an existing account, an unknown one, an expired credential and a reused one after a reset. Keep reset credentials out of logs. Don't promise a password change revokes every session unless it does.

Secrets, safe queries and audit trails

Each credential belongs to one workload with only the permissions it needs, lives in a secret manager, stays out of source and build logs, and has a replacement and revocation path (https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html). A leaked indexer credential shouldn't delete keys or change memberships.

User input is data: use parameterised queries (https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html). A tenant check doesn't make concatenated SQL safe. Audit events record actor, action, object and outcome, never passwords, tokens or whole documents (https://cheatsheetseries.owasp.org/cheatsheets/Logging_Cheat_Sheet.html). Test a key rotation during a running job and a revocation while an export is queued.

Where it's used

  • API gateway: edge identity checks, with document-sharing rules left to the resource service.
  • Dropbox: permissions on sync, download links and background jobs, not just ordinary reads.
  • UPI payments: a transport-protected request is not authority to debit an account.
  • Metrics and monitoring: keep security events without turning logs into a store of credentials.

Common traps

  • Checking ownership only in the UI. Callers hit the API or an old export URL directly.
  • Encrypting passwords so support can recover them. Hash them and use a recovery flow.
  • Treating a valid JWT as permission for every object.
  • Letting a shared cache return one customer's private response to another because both requests came over HTTPS.
  • Rotating a secret but leaving the old one valid forever. Retirement needs a tested step.
  • Sending private request bodies to telemetry by default. The diagnostic copy defeats the restricted storage path.

Follow-up questions interviewers ask

  • "The worker credential leaks." Revoke that workload identity, find what it could reach, and replace it without handing every worker a shared admin credential.
  • "Can an operator restore backups?" Through an audited key-access path, without blanket plaintext access.
  • "What would you test first?" Cross-tenant reads through secondary routes, reused recovery credentials, and an export queued before revocation.

Frequently asked questions

Does encryption at rest protect against an application bug?

+

Only against particular storage threats. An application with legitimate decryption access can still return plaintext to the wrong user.

Is a signed JWT encrypted?

+

Not necessarily; signing and encryption are different properties. Assume a token holder can read the claims.

Can the simulator demonstrate security guarantees?

+

No; this is an explanation-only guide. The simulator's capacity and failure results don't validate cryptography, permissions or attack resistance.

Now fix it yourself.

Run the design under real traffic and see what breaks first. No signup.