Skip to main content

A10:2025 — Mishandling of Exceptional Conditions

OWASP · Top 10:2025 · Reading time: ~12 min

At a Glance​

Rank#10 in 2025 — new category
Mapped CWEs24
Example CWEsCWE-636 Not Failing Securely ('Failing Open'), CWE-754 Improper Check for Unusual or Exceptional Conditions, CWE-755 Improper Handling of Exceptional Conditions, CWE-209 Error Message Containing Sensitive Information, CWE-248 Uncaught Exception, CWE-252 Unchecked Return Value, CWE-460 Improper Cleanup on Thrown Exception, CWE-476 NULL Pointer Dereference
Where it came fromMany of these CWEs used to sit under general "poor code quality." Grouping them makes a clear point: how software behaves when things go wrong is a security property

In Plain English​

Most code is written for the happy path: the database answers, the file uploads, the payment provider replies, the input is the right type. Exceptional conditions are everything else — timeouts, missing parameters, nulls, full disks, permission errors, unexpected status codes, half-finished operations.

When those cases aren't handled deliberately, an application can:

  • fail open — skip a security check because the check itself errored,
  • leak information — print stack traces, queries or file paths,
  • corrupt state — complete half of a transaction but not the other half,
  • exhaust resources — leak connections or file handles on each error until it falls over.
┌── handled deliberately ──► safe failure (deny, roll back, log)
Something unexpected ───┤
└── not handled ───────────► fail open · leak · corrupt · crash

Attackers deliberately create these conditions — sending malformed input, missing fields, huge values, concurrent requests — because the error paths are usually the least tested code in the application.

Freshers' takeaway

When you test, don't just send "bad" values — send weird ones. Leave a parameter out entirely. Send it twice. Send an array where a string is expected. Send null, an empty string, a negative number, a 10 MB value. Cut a multi-step flow off halfway. Watch what the application does when it's surprised.


How It Happens​

FailureExample
Failing openAn authorization service times out, and the code's catch block allows the request.
Verbose errorsA database error with the full SQL query is returned to the user, helping an attacker refine an injection.
Unchecked return valuesA function returns false or an error code meaning "permission denied," but the caller never checks it.
Generic catch-all handlerscatch (Exception e) {} swallows a security-relevant failure silently.
Partial transactionsA transfer debits one account, then crashes before crediting the other — or worse, credits before debiting and can be interrupted.
Resource leaks on errorEach failed upload leaves a file handle or connection open until the server runs out.
Missing/extra parameter handlingA missing field is treated as "no restriction"; a duplicated field is processed twice.
Missing default casesA switch on user role has no default branch, so an unexpected role falls through to privileged behaviour.
Inconsistent handlingOne endpoint handles an error safely; a near-identical endpoint doesn't.

Vulnerable vs. Fixed Code​

Vulnerable — an error in the check grants access:

async function canAccess(user, resource) {
try {
return await policyService.check(user.id, resource.id);
} catch (err) {
console.warn('policy service unavailable, allowing');
return true; // fails OPEN
}
}

Fixed — errors deny by default, and are logged and alerted:

async function canAccess(user, resource) {
try {
return (await policyService.check(user.id, resource.id)) === true;
} catch (err) {
logger.error({ event: 'authz.check_failed', err, userId: user.id });
return false; // fails CLOSED
}
}

Note the strict === true: an unexpected return value (undefined, an error object, the string "false") is also treated as a denial.


Example Attack Scenarios​

  • Denial of service through error paths — An upload handler catches exceptions but never releases the resources it acquired. An attacker uploads thousands of deliberately malformed files until no connections or file handles remain.
  • Information disclosure — A malformed query parameter triggers a raw database error showing table names and the query structure, turning a blind injection attempt into a guided one.
  • Interrupted transactions — An attacker aborts a multi-step transfer at exactly the right moment, or fires the same request concurrently, exploiting the gap between "debit" and "credit" to move money twice.
  • Fail-open authentication — When an external identity provider or MFA service is slow, the application "temporarily" skips the check. An attacker who can induce the slowdown (or simply waits for one) bypasses MFA.

How to Test for It​

  • Remove required parameters one at a time; duplicate parameters; change types (string ↔ number ↔ array ↔ object ↔ null).
  • Send extreme values: very long strings, huge numbers, negative numbers, zero, Unicode edge cases.
  • Look at every error response for stack traces, queries, internal paths, hostnames or library versions.
  • Interrupt multi-step flows (close the connection mid-request, skip the final step) and check for inconsistent state.
  • Send concurrent identical requests to state-changing endpoints (race conditions).
  • In a test environment, simulate dependency failures — make the auth service, database or payment provider slow or unavailable — and check whether security checks fail closed.
  • Watch resource usage (connections, memory, file handles) while repeatedly triggering errors.
  • In code review, look for empty catch blocks, catch-all handlers that continue normally, unchecked return values, and switch/if chains without a safe default.

How to Prevent It​

PracticeWhy
Fail closedWhen a security decision can't be made, the answer is "no."
Handle errors where they occurThe code closest to the problem knows best how to recover safely.
Centralised, consistent error handlingOne approach across the app (and ideally the organisation) means fewer forgotten edge cases.
Global exception handler as a safety netCatches anything that slips through and returns a generic response.
Atomic transactions with full rollbackNever leave state half-changed.
Guaranteed cleanuptry-with-resources, finally, with, defer — release resources on every path.
Strict input validationReject missing, extra and wrongly-typed parameters early, before business logic runs.
Generic user-facing errors; detailed logsUsers get an error ID; engineers get the stack trace.
Rate limiting and quotasLimits how many exceptional conditions an attacker can trigger.
Monitor error patternsA spike in errors from one source is often an attack in progress (see A09). Summarise repeated identical errors instead of flooding logs.
Test failure, not just successChaos testing, fault injection and negative test cases.

Pro Notes​

  • Fail-safe defaults is one of the oldest secure design principles (Saltzer and Schroeder, 1975): base access decisions on permission rather than exclusion. A10 is that principle, measured.
  • Circuit breakers and timeouts improve resilience, but decide explicitly what happens when a circuit is open for a security dependency — degraded mode must never mean "unauthenticated mode."
  • Idempotency keys make retries safe for payments and other state-changing operations, preventing double processing when clients retry after a timeout.
  • Languages differ. Exceptions (Java, Python, JavaScript), error return values (Go, C) and result types (Rust) each have characteristic mistakes: swallowed exceptions, ignored err values, and over-eager unwrap() calls respectively.
  • Overlap is intentional. This category touches A01 (fail-open authorization), A02 (verbose errors), A06 (designing for failure) and A09 (alerting on error spikes). It exists to make error handling a first-class security topic rather than an afterthought.

Key Takeaways​

  • A10 is new in 2025: how software behaves when something unexpected happens is a security issue.
  • The big dangers are failing open, leaking details in errors, partial state changes and resource exhaustion.
  • Fail closed, handle errors close to the source, use atomic transactions, and always clean up.
  • Test the unhappy paths deliberately — they're where attackers look first.

Go deeper: Timing Attacks & Denial of Service · Access Control & Business Logic Flaws


Next​

Move from web apps to APIs: OWASP API Security Top 10.