Skip to main content
HighAI codeOWASP A07:2021CWE-636

How to fix: Auth Check Fails Open on Error

An authentication check is wrapped in try/catch, and the catch block only logs the error rather than denying access, letting a thrown/rejected auth check silently succeed.

Why it matters

Any condition that causes the auth check to throw (a downed auth service, a malformed token, a timeout) results in the request proceeding as if authentication succeeded, rather than being rejected.

Fail-open error handling is a frequent AI-generated code smell: the happy path correctly calls verify()/authenticate(), but the exception path was written purely to avoid an unhandled-rejection crash, without considering that a caught auth failure must still result in denial.

How to fix it

  1. 1In every auth-check catch block, explicitly deny access (return 401/403) rather than merely logging.
  2. 2Write a test that forces the auth check to throw and asserts the request is rejected, not allowed through.
  3. 3Prefer a linting rule or code-review checklist item for 'every catch around an auth check must fail closed'.

Code examples

Fail closed on auth errors

TypeScript
try {
  await verify(token);
} catch (err) {
  logger.error('auth check failed', err);
  return new Response('Unauthorized', { status: 401 });
}

References

Detected automatically by VulnRadar. The check id is vibe-auth-check-fails-open, stable across every scan so you can filter or diff on it.

See every ai code check

Questions

How severe is Auth Check Fails Open on Error?
VulnRadar rates this high severity in the ai code category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id vibe-auth-check-fails-open, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Auth Check Fails Open on Error map to?
It maps to CWE-636. In the OWASP Top 10 it falls under A07:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for auth check fails open on error

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: Auth Check Fails Open on Error | VulnRadar