🇰🇷 한글 설명
FastAPI Users 15.0.2 미만 버전에서 OAuth 로그인 시 상태 토큰(state token)이 세션과 연결되지 않는 결함이 발견되었습니다. 이로 인해 공격자가 생성한 상태 토큰을 피해자에게 강제로 사용하게 하여 로그인 CSRF 공격을 수행할 수 있습니다. 이는 피해자의 계정을 탈취하거나 피해자를 공격자의 계정으로 로그인시키는 결과를 초래할 수 있습니다.
💡 쉬운 설명
로그인 과정에서 '이 요청이 진짜 당신이 보낸 것인지' 확인하는 보안 장치가 제대로 작동하지 않는 문제입니다. 공격자가 만든 가짜 로그인 링크를 클릭하면, 내 계정이 해커의 계정과 연결되거나 내 계정을 해커가 조종할 수 있게 됩니다.
🇺🇸 원문 (English)
FastAPI Users allows users to quickly add a registration and authentication system to their FastAPI project. Prior to version 15.0.2, the OAuth login state tokens are completely stateless and carry no per-request entropy or any data that could link them to the session that initiated the OAuth flow. `generate_state_token()` is always called with an empty `state_data` dict, so the resulting JWT only contains the fixed audience claim plus an expiration timestamp. On callback, the library merely checks that the JWT verifies under `state_secret` and is unexpired; there is no attempt to match the state value to the browser that initiated the OAuth request, no correlation cookie, and no server-side cache. Any attacker can hit `/authorize`, capture the server-generated state, finish the upstream OAuth flow with their own provider account, and then trick a victim into loading `.../callback?code=<attacker_code>&state=<attacker_state>`. Because the state JWT is valid for any client for \~1 hour, the victim’s browser will complete the flow. This leads to login CSRF. Depending on the app’s logic, the login CSRF can lead to an account takeover of the victim account or to the victim user getting logged in to the attacker's account. Version 15.0.2 contains a patch for the issue.
📍 영향받는 시스템
FastAPI Users versions prior to 15.0.2
⚔️ 공격 벡터
공격자가 생성한 유효한 OAuth state 토큰을 포함한 콜백 URL을 피해자에게 클릭하도록 유도하는 Login CSRF 공격
🛡️ 대응 방법
FastAPI Users 라이브러리를 15.0.2 버전 이상으로 업데이트하십시오.
🔧 검증 코드
출력된 Version이 15.0.2 미만이면 취약한 상태이며, 15.0.2 이상이면 안전합니다.
pip show fastapi-users | grep Version