In a serverless API using API Gateway + Lambda with a DynamoDB-backed data layer, which change best prevents accidental exposure of other tenants’ records when the tenant ID is supplied by the client?

Answer

Use an authorizer that validates the tenant identity from a trusted token and inject the tenant scope into the Lambda environment/context; enforce tenantId in every database query/update

Explanation

Best practice is to derive tenant scope from trusted identity (e.g., token claims validated by an authorizer) and enforce it server-side on every access path. Client-controlled tenant IDs are a common source of broken authorization.

Last reviewed: October 2026

Reviewed by FirstInTest Editorial Team

Report an error
QuestionBack to list