JAVA-026 / 初級
Spring Boot デフォルトエラーページと情報露出(/error 詳細)
なぜ問題になるのか?
例外クラス名やパスがレスポンスに露出し、攻撃の手掛かりになります。
修正方法
java
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorDto> handle(Exception e) {
log.error("unhandled", e); // サーバーログのみ
return ResponseEntity.status(500).body(new ErrorDto("INTERNAL_ERROR"));
}