← Java / Spring · 目录

JAVA-065 / 中级

吞掉异常(catch 后忽略)导致安全事件遗漏

A09:2021 Security Logging and Monitoring Failures · CWE-390 Detection of Error Condition Without Action

为什么存在问题?

认证或签名验证失败被悄然忽略。

如何修复

java
try { verify(token); }
catch (JwtException e) { log.warn("jwt invalid reason={}", e.getClass().getSimpleName()); throw new Unauthorized(); }

延伸阅读