Information Leakage는
아래와 같이 민감한 정보(사용자 ID, 비밀번호, 서버 정보 등)가
로그 또는 오류 메시지를 통해 외부에 노출되는 경우를 말한다
@GetMapping("/user/{id}")
public ResponseEntity<?> getUser(@PathVariable Long id) {
User user = userService.getUserById(id);
if (user == null) {
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body("사용자가 존재하지 않습니다: " + id); //ID 노출 위험
}
return ResponseEntity.ok(user);
}
공통 에러 메시지 사용하여
공격자가 사용자 ID 추측할 수 없도록 실패 응답 작성
@GetMapping("/user/{id}")
public ResponseEntity<?> getUser(@PathVariable Long id) {
return userService.getUserById(id)
.map(user -> ResponseEntity.ok(user))
.orElse(ResponseEntity.status(HttpStatus.NOT_FOUND).body("아이디 또는 비밀번호가 일치하지 않습니다."));
}
'Etc' 카테고리의 다른 글
[Oracle] Delete 속도 보다 빠른 Truncate (0) | 2025.04.13 |
---|---|
docker 설치 중 WSL 관련 에러 해결기 (0) | 2025.04.06 |
개발자가 알아야 할 HTTP 헤더 5가지 (0) | 2025.04.06 |
BE개발자가 모르면 안되는 것 - 기능 이상 (Malfunction) (0) | 2025.03.30 |
인터페이스가 필요한가? (0) | 2025.03.30 |