🇰🇷 한글 설명
Spotipy 라이브러리의 GitHub Actions 워크플로우에서 pull_request_target 이벤트를 부적절하게 사용하여, 포크된 PR의 코드가 base 저장소의 시크릿과 GITHUB_TOKEN에 접근할 수 있는 취약점입니다. 이를 통해 공격자는 저장소를 완전히 장악하고 민감한 인증정보를 탈취할 수 있습니다.
💡 쉬운 설명
GitHub의 CI/CD 설정이 잘못되어 다른 사람이 제출한 코드가 저장소의 비밀번호와 접근 권한에 도달할 수 있습니다. 공격자가 이를 이용하면 저장소를 완전히 제어할 수 있게 됩니다.
🇺🇸 원문 (English)
Spotipy is a Python library for the Spotify Web API. As of commit 4f5759dbfb4506c7b6280572a4db1aabc1ac778d, using `pull_request_target` on `.github/workflows/integration_tests.yml` followed by the checking out the head.sha of a forked PR can be exploited by attackers, since untrusted code can be executed having full access to secrets (from the base repo). By exploiting the vulnerability is possible to exfiltrate `GITHUB_TOKEN` and secrets `SPOTIPY_CLIENT_ID`, `SPOTIPY_CLIENT_SECRET`. In particular `GITHUB_TOKEN` which can be used to completely overtake the repo since the token has content write privileges. The `pull_request_target` in GitHub Actions is a major security concern—especially in public repositories—because it executes untrusted code from a PR, but with the context of the base repository, including access to its secrets. Commit 9dfb7177b8d7bb98a5a6014f8e6436812a47576f reverted the change that caused the issue.
📍 영향받는 시스템
Spotipy (commit 4f5759dbfb4506c7b6280572a4db1aabc1ac778d 이상, 9dfb7177b8d7bb98a5a6014f8e6436812a47576f 이전)
⚔️ 공격 벡터
포크된 저장소에서 악의적 코드를 포함한 PR을 생성하고, pull_request_target 이벤트로 실행되는 CI/CD 파이프라인이 base 저장소의 시크릿에 접근하도록 유도
🛡️ 대응 방법
.github/workflows/integration_tests.yml의 pull_request_target을 pull_request로 변경하거나, 최신 커밋(9dfb7177b8d7bb98a5a6014f8e6436812a47576f)으로 업그레이드
🔧 검증 코드
9dfb717 커밋이 있으면 패치됨, 4f57595만 있으면 취약함을 의미합니다.
git log --oneline --all | grep -E '9dfb717|4f57595' && echo 'Patch check: Vulnerable if only 4f57595 found'