Catalog My learning Blog
OWASP Top 10 2025 Explained with Examples and Fixes · Phase 4 · Lesson 11 · 4 min read

Mishandling of Exceptional Conditions (OWASP A10)

On this page
  1. Failing open when the auth service goes down
  2. Fail closed instead
  3. Why A10 is a new category in 2025
  4. How to prevent mishandled exceptional conditions
  5. Knight Capital and Cloudflare: when nothing fails safely
  6. Check yourself

Failing open when the auth service goes down

A payroll endpoint asks an authorization service whether the user may see the data. Someone wrapped the call in try/catch so an outage wouldn't break the page:

JavaScript
app.get('/v1/payroll', async (req, res) => {
  try {
    if (!(await check(req.query.user))) return res.status(403).end();
  } catch (err) {
    console.warn('authz check failed, allowing request:', err.cause?.code ?? err.name);
  }
  res.json({ payroll: 'all salaries' });
});

With the authorization service stopped, an unknown user asks:

Shell
curl 'localhost:3301/v1/payroll?user=mallory'
Code
authz check failed, allowing request: ECONNREFUSED
{"payroll":"all salaries"} 200

The check never ran, the catch block swallowed the error, and execution fell through to the data. This is failing open: when the system couldn't decide, it chose "allow".

Fail closed instead

When a security decision can't be made, the answer is no:

JavaScript
  } catch (err) {
    console.error('authz check failed, denying request:', err.cause?.code ?? err.name);
    return res.status(503).json({ error: 'Authorization unavailable' });
  }
Code
authz check failed, denying request: ECONNREFUSED
{"error":"Authorization unavailable"} 503

503 (Service Unavailable) tells clients it's temporary and tells monitoring something is down, which a 200 never would. Also note AbortSignal.timeout(500) on the fetch in this lab. Without a timeout, a hung dependency doesn't throw at all; it just holds requests open until something else gives way.

When a dependency times out or errors, a fail-open path continues as if the check passed, while a fail-closed path denies, rolls back and alerts.
When a dependency times out or errors, a fail-open path continues as if the check passed, while a fail-closed path denies, rolls back and alerts.

Why A10 is a new category in 2025

OWASP added this category in 2025. It groups 24 CWEs about improper error handling, logic errors and failing open. These bugs hide well. Tests usually exercise the happy path, and scanners rarely force a dependency to time out halfway through a request. So the exceptional path is the least tested code in most systems.

Common shapes:

Exceptional conditionFails openFails closed
Authorization service unreachableAllow the requestDeny with 503, alert
Payment or fraud check times outShip the order anywayHold the order until the check completes
Config or feature-flag service downUse the most permissive defaultsUse last known good config, or safest defaults
Error during a multi-step transactionLeave it half appliedRoll back the whole transaction
Unexpected exceptionReturn the stack trace (Day 3)Generic error to the client, details in logs

How to prevent mishandled exceptional conditions

  • Decide the failure mode for every security check, on purpose, and write it in the code review.
  • Keep a global error handler as a backstop, so anything unexpected gets a safe default response.
  • Use transactions so a failure halfway rolls everything back.
  • Set timeouts and limits on every call, queue and upload, so exhaustion doesn't become the exceptional condition.
  • Watch resilience libraries. A retry or fallback policy (Polly in .NET, or any client wrapper) whose fallback returns "allowed" or an empty permission set by default fails open just like the catch block above. Fallbacks are fine for recommendations, never for security decisions.
  • Test failure on purpose. Stop the dependency in a test, add latency, send malformed responses, and assert the endpoint denies. Chaos testing does this in larger systems.

Knight Capital and Cloudflare: when nothing fails safely

Two well-documented incidents show the cost:

  • Knight Capital, 2012. A deployment missed one of eight servers, which still ran old code. A reused flag woke up that old code, and nothing stopped the stream of unintended orders. The firm lost about $460 million in roughly 45 minutes.
  • Cloudflare, July 2019. A new firewall rule contained a regular expression that consumed all CPU on many machines, and traffic failed for about 27 minutes. Cloudflare's write-up describes the missing safeguards, including CPU limits on rule execution.

Neither was a classic security hole, but both show the pattern: code met a condition nobody had planned for, and nothing failed safely.

Check yourself

If the check throws, the request continues as if it passed: failing open. The catch should deny, typically with a 503, and raise an alert.

Use the last known good configuration from a local cache, fall back to the most restrictive defaults, or refuse to start and let health checks hold traffic back. Never fall back to permissive settings like disabled authentication, because an outage would then become a security hole.

The unsafe path only runs when something fails, such as a timeout, an outage or a malformed response, and normal tests and scans seldom create those conditions.

When a security check can't be completed, the system denies the action instead of allowing it. For example, if the authorization service times out, the request is rejected with an error rather than treated as authorized.

Inject faults deliberately: make dependencies time out, return malformed data or run out of disk, and check that security decisions fail closed and errors don't leak details. Chaos experiments and targeted unit tests for error paths both help.