Serverless Denial of Service and Resource Limits
You'll learn how serverless functions' auto-scaling power can become a security liability, and how to control resource consumption to prevent abuse.
The Double-Edged Sword of Auto-Scaling
Serverless functions scale automatically with demand—their greatest strength and biggest DoS risk. Unlike traditional VMs with fixed capacity, a sudden flood of malicious requests triggers unlimited scaling, potentially racking up massive cloud bills and exhausting account-level quotas. An attacker doesn't need to crash your function; they just need to invoke it thousands of times per second.
Think of it like a restaurant with infinite chefs: normally great for handling rushes, but if someone sends in fake orders, you'll pay for thousands of meals no one will eat.
Protection Through Limits and Controls
Defend against runaway invocations with these mechanisms:
Concurrent execution limits: Set maximum simultaneous function instances (e.g., AWS Lambda reserved concurrency). This caps your blast radius—you might sacrifice availability under attack, but you won't face unlimited billing.
Throttling: Implement rate limits at the API Gateway or function level. Reject requests beyond your threshold (e.g., 100 requests/minute per IP).
Timeouts: Configure aggressive execution time limits. A function that normally runs in 200ms shouldn't be allowed 15 minutes—shortened timeouts limit the cost of each malicious invocation.
Cost alarms: Set billing alerts that trigger when spend exceeds expected patterns, giving you early warning of an attack.
The Shared Responsibility Reality
Remember: your cloud provider protects the platform; you must protect your function's invocation path. Unsecured event sources (like public API endpoints without authentication) are common DoS entry points.
Key Takeaway: Serverless functions scale infinitely by design, so DoS protection requires setting hard limits on concurrent executions, aggressive timeouts, and API-level throttling—treating your auto-scaling capability as a controlled resource rather than an unlimited one.