Mishandling of Exceptional Conditions
Errors are handled in a way that leaks details or fails open.
What it is
Every app hits errors: timeouts, bad input, a database that is down. The risk is in what happens next: a stack trace sent to the user, a crash that takes the server down, or a check that says "allowed" because it threw.
What can happen
- Stack traces reveal file paths, versions and queries.
- "Fail open" turns an outage into a security hole.
- Unhandled rejections crash the whole server.
Example: Fail open vs fail closed
let allowed = false;
try {
allowed = await checkPermission(user, scan);
} catch {
allowed = true; // service down -> everyone allowed
}let allowed = false;
try {
allowed = await checkPermission(user, scan);
} catch (err: unknown) {
logger.error({ event: "permission_check_failed", err });
allowed = false; // when in doubt, deny
}If the check can't finish, the answer is "no".
Example: Error responses
app.use((err, req, res, next) => {
res.status(500).json({ error: err.stack });
});app.use((err: unknown, req: Request, res: Response, _next: NextFunction) => {
logger.error({ err }); // details stay on the server
res.status(500).json({ error: "Something went wrong" });
});The user gets a generic message. The details go to the logs.
How to prevent it
- One central error handler with generic messages to the client.
- Fail closed: on error, deny.
- Catch async errors, and handle unhandledRejection.
- Set timeouts and limits on everything external.
What CrimsonScan checks
Partly detectedThe heavy scan (ZAP) flags error pages that leak stack traces or framework details. Fail-open logic can only be found by reading the code.