Skip to content
All work

Security audit · A client platform review

Serverless security beyond Firestore rules

Serverless security is configuration security. The client talks to a managed data plane, the identity provider mints the token, and a rules file or IAM policy is the only thing between one tenant and another. This case study describes the review model I apply across Firebase, AWS, Azure, Supabase and Cloudflare; specific findings stay with the client.

platform models in the cross-provider checklist
5
platform models in the cross-provider checklist
review workstreams
6
review workstreams

01

Why serverless authorization is easy to get wrong

The distinction between list and read permissions is subtle enough that a ruleset can pass a casual review, behave correctly on the common path, and still permit direct document access the author believed was blocked. A query can be denied while a direct document get is allowed, or the reverse, depending on how the rule is written. The browser SDK talks to the data plane directly, so there is no server-side controller to catch what the rule misses. Rules are code, and they need the same adversarial reading and tests as the application they protect.

02

Serverless moves the perimeter into configuration

In a traditional stack, the application server is a chokepoint: every request passes through code you can review, instrument and patch. In a serverless stack the client talks to a managed data plane, the identity provider mints the token, and the only thing standing between a user and another tenant's data is a rules file, an IAM policy or a row-level security policy. There is no bastion host to scan and no middleware to add a check to. The configuration is the security control, and it is usually deployed by a different pipeline from the application.

03

The same failure modes, provider by provider

  • Firebase and Google Cloud: Firestore and Storage rules; callable functions must validate the auth context; App Check is attestation, not authorization; service-account IAM and Cloud Run ingress decide what the backend can reach; Secret Manager instead of environment variables.
  • AWS: Cognito user and identity pools, API Gateway authorizers, Lambda execution roles, DynamoDB condition expressions and leading keys, S3 Block Public Access and presigned URLs, and resource policies on EventBridge, SNS and SQS that can invite a confused-deputy call.
  • Azure: Entra ID app registrations and token audience, Functions auth levels and function keys, Cosmos DB data-plane RBAC and partition-key design, Blob SAS scope and stored access policies, managed identities and Key Vault references.
  • Supabase and Postgres: RLS enabled on every table, separate policies for select, insert, update and delete, security-definer functions with a fixed search_path, anon versus service_role key handling, and storage policies that mirror table policies.
  • Cloudflare: Workers with D1, R2 and KV bindings; Access or JWT verification at the edge; WAF and rate limits; per-environment secrets; preview URLs that are not public by default.
  • Vercel and Netlify: edge function environment scoping, preview deployments, build logs and deploy protection. A preview URL with production secrets is a production incident with a staging hostname.

04

Identity is the only front door

  • Validate the token, not its presence: signature, issuer, audience, expiry and revocation. A decoded JWT is not a verified JWT.
  • Roles and tenant IDs belong in server-issued claims, never in a request body the client controls. Refresh claims when roles change; stale claims are stale authorization.
  • Cognito identity pools can issue AWS credentials to unauthenticated users. If you enable that path, scope the role to almost nothing and log its use.
  • Entra and OIDC integrations need tenant and audience checks; a token from the wrong app or tenant must fail closed.
  • Supabase's anon key is public by design. RLS is the boundary; the service_role key bypasses RLS and must never reach a browser or a mobile bundle.
  • Firebase App Check reduces abuse of your project by unattested clients, but it does not tell you who the user is. Do not use it as an authorization decision.

05

Function and event security

  • Validate event payloads. Lambda events, Pub/Sub messages, queue bodies and webhook payloads are attacker-controlled input, not trusted internal calls.
  • Give each function its own role or identity. A shared execution role turns one compromised function into the union of every permission in the account.
  • Check the source on resource policies: an SNS topic or S3 bucket that can invoke a function from another account is a confused deputy waiting to happen.
  • Use a secret manager with rotation; environment variables are visible to anyone who can read the function configuration and often end up in logs.
  • Bound recursion, concurrency and timeouts; add dead-letter queues and idempotency keys so a retry storm does not become a billing incident.
  • Treat dependencies and base images as part of the perimeter: pin, scan and rebuild on a schedule.

06

Storage and signed URLs

  • Block public access at the account or project level, then allow the specific bucket or container you mean.
  • Scope presigned URLs by method, object, content type and a short expiry. Never sign a prefix that covers other tenants.
  • Mirror storage authorization to data authorization: Firebase Storage rules, S3 bucket policies, Azure SAS and R2 bindings all need the same tenant check as the database.
  • Watch metadata: object names, content types and error messages can enumerate users or internal structure even when the bytes are protected.

07

The authorization tests that generalize

  • Unauthenticated direct read and write against every collection, table, bucket and function.
  • Authenticated cross-tenant read: sign in as tenant A and request tenant B's object by ID.
  • list versus get: test the query path and the direct-document path separately; a rule can deny one and allow the other.
  • Field-level projection: confirm the response does not include password hashes, internal IDs, provider credentials or another user's PII.
  • Function invocation outside the UI: call the function directly with a valid token but the wrong role or tenant.
  • Token tampering: change the audience, issuer, tenant or role claim and confirm the service rejects it.
  • Expired and revoked tokens: confirm they fail, and that refresh cannot resurrect a revoked session.
  • Signed URL reuse after expiry, and with a different method or content type.
  • Rules drift: compare the deployed rules, IAM policies and RLS policies against the repository, environment by environment.
  • Bulk export and error enumeration: pagination, CSV endpoints and verbose errors often bypass UI-level checks.

08

Deployment drift is the quiet failure

  • Rules, IAM and RLS are code. Keep them in version control, review them like application code, and deploy them with the app.
  • Test with the provider's emulator or a local stand-in: Firestore emulator, LocalStack, Azurite, Supabase CLI, Miniflare.
  • Stage a rule diff and a rollback path; a permissive rule pushed at 2 a.m. should be reversible in one command.
  • Alert on denied-request spikes, auth failures and function errors. A sudden drop in denials can mean someone found a path that no longer denies.
  • Audit service accounts and CI identities on a schedule; a stale deploy key with owner rights is the serverless equivalent of a forgotten VPN account.
  • Keep preview and production projects separate, with separate credentials and data.

09

What a review produces

A prioritised remediation plan, corrected rule or policy definitions where needed, and a regression suite that exercises direct data-plane access. The client keeps the detail; the method is what generalises.

Tools and platforms

  • Firebase
  • Firestore security rules
  • Cloud Functions
  • AWS IAM / Cognito
  • Azure Entra / Functions
  • Supabase RLS
  • Cloudflare Workers

Next

Revenue assurance through operational data