fix: Apple ID 토큰 서명 검증 누락 취약점 수정 - #202
Merged
Merged
Conversation
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
requested review from
RinRinPARK,
YuSuhwa-ve and
funnysunny08
as code owners
July 28, 2026 17:50
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
취약점
AppleSignInService.getSocialInfo()가 클라이언트가 보낸 Apple ID 토큰(idToken)을SignedJWT.parse()로 파싱만 하고 암호학적 서명 검증을 한 번도 수행하지 않고 있었음.검증 로직은
iss(발급처)/aud(대상)/exp(만료시간)/email_verified클레임 값만 확인했는데, 서명 검증이 없으면 이 값들은 클라이언트가 3-segment 구조만 맞춰서 임의로 채울 수 있음. 즉 실제 Apple 로그인 없이도POST /api/auth에provider=APPLE과 함께 위조 토큰을 보내면 정식 유저 생성/조회 + accessToken·refreshToken 발급이 그대로 통과하는 상태였음.수정
Apple의 공개키(JWKS,
https://appleid.apple.com/auth/keys)로 RS256 서명을 검증하도록 변경. 이미 의존성에 있는nimbus-jose-jwt의JWSVerificationKeySelector+RemoteJWKSet+DefaultJWTProcessor를 사용해, 서명이 유효한 토큰에서만 클레임을 신뢰하도록 함 (새 의존성 추가 없음).서명 검증 실패(
BadJOSEException), JWKS 조회 실패(JOSEException), 파싱 실패(ParseException) 모두 기존과 동일하게INVALID_APPLE_ID_TOKEN_EXCEPTION으로 처리.발견 경위
부하테스트용 JWT 발급 방법을 조사하던 중 발견함 (Google/Kakao 로그인은 각각
GoogleIdTokenVerifier, 카카오 서버 API 호출로 정상 검증 중이며 이 이슈는 Apple 로그인 경로에만 해당).테스트
./gradlew compileJava성공 확인. (실제 Apple 기기로 로그인 재검증은 별도 필요)