Skip to content

fix: Apple ID 토큰 서명 검증 누락 취약점 수정 - #202

Merged
unam98 merged 1 commit into
mainfrom
fix/apple-jwt-signature-verification
Jul 28, 2026
Merged

fix: Apple ID 토큰 서명 검증 누락 취약점 수정#202
unam98 merged 1 commit into
mainfrom
fix/apple-jwt-signature-verification

Conversation

@unam98

@unam98 unam98 commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

취약점

AppleSignInService.getSocialInfo()가 클라이언트가 보낸 Apple ID 토큰(idToken)을 SignedJWT.parse()파싱만 하고 암호학적 서명 검증을 한 번도 수행하지 않고 있었음.

검증 로직은 iss(발급처)/aud(대상)/exp(만료시간)/email_verified 클레임 만 확인했는데, 서명 검증이 없으면 이 값들은 클라이언트가 3-segment 구조만 맞춰서 임의로 채울 수 있음. 즉 실제 Apple 로그인 없이도 POST /api/authprovider=APPLE과 함께 위조 토큰을 보내면 정식 유저 생성/조회 + accessToken·refreshToken 발급이 그대로 통과하는 상태였음.

수정

Apple의 공개키(JWKS, https://appleid.apple.com/auth/keys)로 RS256 서명을 검증하도록 변경. 이미 의존성에 있는 nimbus-jose-jwtJWSVerificationKeySelector + RemoteJWKSet + DefaultJWTProcessor를 사용해, 서명이 유효한 토큰에서만 클레임을 신뢰하도록 함 (새 의존성 추가 없음).

서명 검증 실패(BadJOSEException), JWKS 조회 실패(JOSEException), 파싱 실패(ParseException) 모두 기존과 동일하게 INVALID_APPLE_ID_TOKEN_EXCEPTION으로 처리.

발견 경위

부하테스트용 JWT 발급 방법을 조사하던 중 발견함 (Google/Kakao 로그인은 각각 GoogleIdTokenVerifier, 카카오 서버 API 호출로 정상 검증 중이며 이 이슈는 Apple 로그인 경로에만 해당).

테스트

./gradlew compileJava 성공 확인. (실제 Apple 기기로 로그인 재검증은 별도 필요)

AppleSignInService.getSocialInfo()가 클라이언트가 보낸 Apple ID 토큰을
SignedJWT.parse()로 파싱만 하고 암호학적 서명 검증을 하지 않고 있었음.
발급처(iss)/대상(aud)/만료시간/이메일 인증 여부 같은 클레임 값만 확인했는데,
이 값들은 서명 검증 없이는 클라이언트가 얼마든지 임의로 채울 수 있어
실제로는 애플 로그인 없이도 provider=APPLE로 정식 로그인/토큰 발급이
가능한 상태였음.

Apple의 공개키(JWKS, https://appleid.apple.com/auth/keys)로 RS256 서명을
검증하도록 수정. nimbus-jose-jwt(기존 의존성)의 JWSVerificationKeySelector +
DefaultJWTProcessor를 사용해 서명이 유효한 토큰만 클레임을 신뢰하도록 함.
@unam98 unam98 self-assigned this Jul 28, 2026
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 44fb596e-3edd-4799-ba4f-2ccc8df25f81

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/apple-jwt-signature-verification

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@unam98
unam98 merged commit e5fbaf5 into main Jul 28, 2026
2 checks passed
@unam98
unam98 deleted the fix/apple-jwt-signature-verification branch July 28, 2026 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants