Safeguard
Application Security•

CWE-408 Early Amplification: Expensive Work Before Auth

If your service does costly work before it checks who is asking, anyone can spend your CPU and memory. CWE-408 explained, with fixes.

Safeguard Security Team
2 min read

CWE-408 covers products that let an entity perform a legitimate but expensive operation before authentication or authorization has happened. The operation itself is allowed. The order is the bug.

How it happens

A request arrives, and the code starts working on it right away: allocating memory, building a directory, parsing a large body, running a query. The identity check comes later, or never gates the costly part.

MITRE's observed example is a tool that created directories before authenticating the user (CVE-2004-2458). An anonymous caller could trigger real work on the server without ever logging in.

What an attacker gains

The consequence is availability. System resources, CPU and memory, can be consumed quickly, which can lead to poor performance or a crash. The attacker does not need an account, and each request costs them far less than it costs you.

How to find it

The record lists no detection methods, so use these checks:

  • Trace a request from the socket to the first line that checks identity. List everything that runs before that line.
  • Send unauthenticated requests with large bodies or heavy parameters and watch server resource use.
  • Review code that allocates or writes to disk early in a handler.

How to fix it

  1. Authenticate and authorize first, then do the expensive work.
  2. Keep the pre-authentication path cheap. Limit body size, header count and connection time.
  3. Rate limit unauthenticated callers by address.
  4. Defer allocation until the request is known to be legitimate.

A simple mental model

Imagine a front desk that makes a custom badge for every visitor before checking their name. Anyone can walk in and keep the badge printer busy. Moving the identity check to the start costs almost nothing and removes the attack. In software terms, the cheapest checks should run first and the costliest work should run last.

Quick check

Is this the same as a denial of service flood?

Not quite. A flood overwhelms with volume. Early amplification lets a small number of requests do outsized work because the expensive step runs before the access check.

Sources

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.