🇰🇷 한글 설명
GitHub CLI의 gh repo clone, gh repo fork, gh pr checkout 명령어가 GitHub.com 외부 호스트의 git 서브모듈을 처리할 때 GITHUB_TOKEN을 불필요하게 노출하는 취약점입니다. 2.63.0 버전 이전에서는 비GitHub 호스트를 GitHub Enterprise로 취급하여 환경변수의 토큰을 git에 전달하므로 악의적인 외부 서브모듈 서버가 토큰을 탈취할 수 있습니다.
💡 쉬운 설명
GitHub CLI에서 외부 서버의 코드를 내려받을 때 자동으로 로그인 토큰이 노출되는 결함입니다. 공격자가 이를 이용해 사용자의 GitHub 계정을 제어할 수 있습니다.
🇺🇸 원문 (English)
The gh cli is GitHub’s official command line tool. A security vulnerability has been identified in the GitHub CLI that could leak authentication tokens when cloning repositories containing `git` submodules hosted outside of GitHub.com and ghe.com. This vulnerability stems from several `gh` commands used to clone a repository with submodules from a non-GitHub host including `gh repo clone`, `gh repo fork`, and `gh pr checkout`. These GitHub CLI commands invoke git with instructions to retrieve authentication tokens using the `credential.helper` configuration variable for any host encountered. Prior to version `2.63.0`, hosts other than GitHub.com and ghe.com are treated as GitHub Enterprise Server hosts and have tokens sourced from the following environment variables before falling back to host-specific tokens stored within system-specific secured storage: 1. `GITHUB_ENTERPRISE_TOKEN`, 2. `GH_ENTERPRISE_TOKEN` and 3. `GITHUB_TOKEN` when the `CODESPACES` environment variable is set. The result being `git` sending authentication tokens when cloning submodules. In version `2.63.0`, these GitHub CLI commands will limit the hosts for which `gh` acts as a credential helper to source authentication tokens. Additionally, `GITHUB_TOKEN` will only be used for GitHub.com and ghe.com. Users are advised to upgrade. Additionally users are advised to revoke authentication tokens used with the GitHub CLI and to review their personal security log and any relevant audit logs for actions associated with their account or enterprise
📍 영향받는 시스템
GitHub CLI < 2.63.0
⚔️ 공격 벡터
공격자가 외부 호스트에 git 서브모듈을 포함한 저장소를 생성한 후, 사용자가 gh repo clone/fork 또는 gh pr checkout 명령어로 이 저장소를 처리하도록 사회공학 또는 유인을 통해 유도
🛡️ 대응 방법
GitHub CLI를 2.63.0 이상으로 업그레이드하고 기존 인증 토큰을 폐기한 후 새로운 토큰 생성
🔧 검증 코드
출력이 'safe'면 안전하고 'vulnerable'이면 즉시 업그레이드 필요
gh --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | awk -F. '{if($1==2 && $2>=63) print "safe"; else print "vulnerable"}'