Skip to content

[ Auth ] /users 의 사용자 관리 기능으로 권한 상승과 개인정보 열람이 가능하다 #83

Description

@RosieOh

💚 어떤 기능인가요?

UserController 의 클래스 제약이 @PreAuthorize("isAuthenticated()") 하나인데
그 아래에 관리 기능이 함께 있다. 가입만 하면 누구나 실행할 수 있다.

경로영향
PUT /users/{id}/role자신/타인을 ADMIN 으로 승격
DELETE /users/{id}, PUT /users/{id}/deactivate타인 계정 삭제·정지
PUT /users/{id}/activate, /reactivate정지·탈퇴 계정 임의 복구
GET /users/{id}타인 PII 조회 (IDOR)
/users/search, /active, /verified, /by-region/{region}, /by-type/{t}, /recently-active, /statistics전체 회원 개인정보 열거

@RequireAdminRole 어노테이션이 core/annotation 에 정의돼 있지만 사용처가 0건이다.
의도는 있었으나 연결되지 않았다.

PUT /users/{userId} 는 반대로 경로 변수를 무시하고 현재 사용자를 수정한다.
안전하지만 시그니처가 동작과 달라, 누군가 "버그"로 오해하고 고치면 즉시 IDOR 이 된다.

URL 규칙 하나에 의존하면 안 된다. 이 저장소는 /health/**/hospitals/** 를 삼켜
공개 API 가 통째로 막힌 전례가 있다.

✅ To Dos

  • 사용자 관리 기능을 /api/admin/users 로 이관
  • UserServiceupdateUserRole / activateUser / reactivateUser@PreAuthorize("hasRole('ADMIN')") 직접 부착
  • 경로 변수가 남은 구 경로에 본인 확인(requireSelf) 추가 — 계정 열거 방지를 위해 404 가 아니라 403
  • GET /users/{userId}, PUT /users/{userId} 삭제하고 /users/me 계열 제공
  • 접근제어 계약 테스트에 회귀 케이스 추가

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions