mediumCWE-400A05:2021

Function Timeout Abuse

Serverless functions without a configured timeout can be kept running indefinitely by malicious or malformed requests, draining your budget.

How It Works

Cloud providers charge per execution millisecond. Without a timeout, an attacker can send a slow request that keeps your function alive for the maximum platform limit (15 minutes on Lambda). Multiply that by concurrent invocations and you have a denial-of-wallet attack.

Vulnerable Code
// BAD: serverless.yml with no timeout — defaults to 6s on AWS, can be 900s
functions:
  api:
    handler: src/handler.main
    # no timeout configured
Secure Code
// GOOD: set a tight timeout appropriate for the function's expected work
functions:
  api:
    handler: src/handler.main
    timeout: 10  # seconds — fail fast if something hangs

Real-World Example

A startup reported a $2,300 AWS bill in a single day after a bot started sending slow POST requests that held their Lambda functions open for the full 900-second default timeout.

How to Prevent It

  • Set explicit timeouts on every function — never rely on platform defaults
  • Set timeouts slightly above your p99 execution time, not the platform maximum
  • Enable AWS Lambda Concurrency Limits or equivalent to cap parallel executions
  • Set up billing alerts to detect unexpected cost spikes early

Affected Technologies

aws-lambdavercelcloudflare-workers

Data Hogo detects this vulnerability automatically.

Scan Your Repo Free

Related Vulnerabilities