Mishandling of Errors And Exceptional Conditions Vulnerability
Description
Applications that fail to anticipate, detect, or correctly handle unexpected or faulty conditions such as invalid inputs, inconsistent states, or flawed logic paths are vulnerable to crashes, data corruption, information leaks, and unauthorized actions.
According to OWASP Top 10:2025, these issues often appear when systems react improperly to errors. For example, an application might swallow file-upload failures without freeing resources, causing denial-of-service conditions; return detailed database error messages to users, exposing sensitive internal information; or continue a multi-step financial transaction after an intermediate failure, leaving data and state inconsistent.
In essence, the weakness lies not only in the occurrence of an error, but in how the system responds: whether by ignoring it, mishandling it, or continuing execution in an unsafe state.
Impact
As these failures trigger unpredictable states, they may lead to a wide variety of downstream vulnerabilities: logic faults, resource leaks or exhaustion, race conditions, memory corruption, unauthorized access, sensitive data disclosure, denial of service, and more.
Scenarios
The following example shows a controller that fails open when handling authorization errors.
@route('/delete_account')
def delete_account():
try:
allowed = check_permission(current_user)
except NotAuthorizedException as e:
print("Error, user is not authorized", current_user)
delete_user(current_user)
# Sensitive action proceeds even though the permission check failed
print(f"Account deleted.")
Because the exception is caught but not handled properly (e.g., by stopping execution or returning an error response), the code proceeds with delete_user(). This results in a fail-open condition, allowing unauthorized users to perform privileged actions.
Prevention
To address this class of vulnerabilities, organizations should design with failure in mind. Exceptional conditions are inevitable; components will break, inputs will be invalid, and dependencies will occasionally fail. Systems that expect and handle such situations gracefully are far less likely to expose security risks.
Developers should catch and handle errors close to their source, rather than relying on high-level catch-all blocks that obscure context or allow unsafe continuation. When failures occur, applications must fail closed, stopping or rolling back operations safely instead of continuing in an insecure state.
A consistent, centralized approach to exception handling helps ensure that all components respond predictably to errors. Defining standard patterns for raising, logging, and recovering from exceptions reduces inconsistencies and unintended behavior.
To prevent exceptional conditions caused by bad inputs or uncontrolled resources, enforce strict validation and sensible limits (e.g., allow-lists, size quotas, request throttling). Complement this with structured logging and monitoring, alerting on recurring or abnormal error patterns to detect systemic issues early.
Ensure transaction consistency and cleanup by releasing resources, reverting partial operations, and returning the system to a safe baseline after failures.
Finally, make error handling part of regular testing and review processes. Include negative and fault-injection tests, and verify through code review or static analysis that exception paths are handled securely and consistently across the application.
Testing
Applications should handle errors securely and predictably. They should return only generic messages to users, keeping internal details hidden. When dependencies fail, systems should degrade gracefully rather than crash or bypass controls. Exceptions must cause the application to fail closed, halting unsafe operations instead of continuing after errors. Finally, a global error handler should catch any unhandled exceptions to log issues safely and maintain availability.
- OWASP ASVS: 16.5
- OWASP Testing Guide: Testing for Improper Error Handling