← Java / Spring · 目次

JAVA-071 / 中級

JPA エンティティの直接 JSON 返却:機密フィールド・遅延ロードの露出

A01:2021 Broken Access Control · CWE-200 Exposure of Sensitive Information

なぜ問題になるのか?

password ハッシュや関連エンティティ全体が露出し、循環参照による DoS が発生します。

修正方法

java
@GetMapping("/me") UserDto me() { return UserDto.from(userRepo.findById(id).orElseThrow()); }

参考資料