01Draw trust boundaries
Mark browser, edge, application, tool sandbox, data plane, and external systems. Identify assets and attacker goals. Authentication establishes identity; authorization must still run at every protected resource boundary.
Authentication establishes who is making a request; authorization decides whether that identity may perform this action on this resource now. A valid session does not imply access to every file. Derive tenant identity from trusted authentication context, then check the requested object's owner and sharing policy. Never let a caller's arbitrary tenant_id field define the security boundary.
Draw where trust changes: browser to edge, edge to service, service to storage, worker to provider. At each boundary, list the credential, allowed operation, and validation performed. A signed download URL delegates access for its lifetime; it is effectively a temporary credential. Choose its scope and expiry based on how quickly revocation must take effect.
Threat modeling is a disciplined walkthrough of assets and possible misuse. For a file service, protect confidentiality of bodies, integrity of permissions, and availability of uploads. Trace a guessed object ID, a stolen link, a malicious upload, and a revoked member. Match each to an enforcement point and a test. Saying “encrypt the database” leaves most of those paths unanswered.
- Short-lived, scoped credentials limit blast radius
- JWT validation includes signature, issuer, audience, and expiry
- OAuth delegates access; it is not authorization policy by itself
02Multi-tenancy is a data-flow property
Carry tenant identity from authenticated request through cache keys, queries, events, object paths, logs, and tools. Enforce policy server-side. High-risk workloads may need physical isolation beyond row filters.
Tenant isolation must survive every derived representation: database rows, search indexes, caches, exported files, logs, and asynchronous jobs. A perfectly filtered API can still leak through a cache keyed only by file ID or a worker that trusts an old permission snapshot. Carry trusted tenant context and resource identity into downstream work.
Use defense in depth with explicit ownership. Application checks can apply sharing rules; database policies can guard against missing filters; scoped storage credentials can limit a worker's reach. These controls need a consistent tenant model and tests for administrative or migration paths. A privileged maintenance script can bypass an otherwise careful request flow.
Revocation is a time problem as well as a data problem. Decide when access must stop for cached previews, already queued jobs, and active downloads. Recheck before publishing sensitive results and before consequential effects where required. If an already issued URL remains valid for five minutes, describe that exposure and decide whether the product can accept it.
- Default-deny resource access
- Avoid confused-deputy tool calls
- Partition quotas and concurrency per tenant
03Abuse is reliability plus economics
Layer cheap controls before expensive work: input limits, identity reputation, token buckets, anomaly detection, and spend caps. Preserve headroom for trusted traffic and record appeal/recovery paths for false positives.
Abuse often uses valid requests at economically harmful volume. A free account can submit expensive exports, large uploads, or long-running inference requests. A request-rate limit treats cheap and costly operations alike. Combine caller, tenant, operation, concurrency, byte, and spend limits, using an estimate on admission and reconciliation after completion.
Place admission before scarce work. If the system parses a huge archive or invokes a model before checking quota, the limit arrives too late. Bound input size, expansion ratio, execution time, and output volume. Protect shared resources against many accounts acting together as well as one noisy tenant; per-account limits alone do not stop distributed abuse.
Separate authentication failures, policy denials, quota exhaustion, and upstream outages in telemetry. Otherwise an attack can look like an unexplained reliability drop. Audit sensitive access with resource and principal identities while restricting access to the audit log itself. Recovery includes credential rotation, revocation, and determining what data was exposed.
- Rate-limit by user, tenant, IP, and credential as appropriate
- Audit policy changes and privileged actions
- Minimize and expire sensitive data