Serverless Cold Start and Timing Side Channels
What you'll learn: How serverless cold starts create timing patterns that attackers can exploit to leak internal state and secrets.
The Security Problem with Cold Starts
When a serverless function hasn't run recently, the cloud provider must initialize a new execution environment — a "cold start." This takes longer than invoking a warm function (one already initialized). The problem? This timing difference can leak sensitive information.
Think of it like this: If someone times how long it takes you to answer the door, they might guess whether you were already in the front hall (fast) or sleeping upstairs (slow). Similarly, attackers can infer your application's internal state by measuring function response times.
Common Timing Side Channels
Secret-dependent execution paths: If your function checks a password or API key early and returns faster on mismatch, an attacker can time requests to guess valid credentials one character at a time.
State inference: Cold start times reveal whether a function has been recently used. This can expose user activity patterns, feature usage, or even whether specific tenants are active in a multi-tenant system.
Resource enumeration: Timing differences when accessing different resources (databases, storage) can help attackers map your infrastructure or determine which resources exist.
Mitigation Strategies
- Keep functions warm with scheduled "ping" invocations to reduce cold starts for sensitive operations
- Constant-time comparisons for any secret validation (don't short-circuit on first mismatch)
- Randomize delays slightly to obscure timing patterns
- Rate limiting to prevent rapid timing measurement attacks
- Move secrets out of environment variables that load during cold start; fetch them lazily when needed
- Monitor timing metrics for anomalous patterns indicating reconnaissance
Key Takeaway: Serverless cold starts create measurable timing differences that can leak secrets, state, and infrastructure details — use constant-time operations, keep sensitive functions warm, and add controlled jitter to response times.