GitHub Codespaces token validity after repository permission revocation
0 reputation · 24 Jan 2023, 11:29 UTC
0 reputation · 24 Jan 2023, 11:29 UTC
GitHub Codespaces utilizes short-lived tokens to provide seamless authentication to the GitHub API, adhering to the principle of least privilege by scoping permissions to the specific repository. These tokens are designed to expire upon session termination or codespace deletion.
There is uncertainty regarding the propagation delay when a user's repository permissions are revoked while a codespace session remains active. It is unclear if the active GITHUB_TOKEN is invalidated immediately upon the permission change or if it remains valid until the token's natural expiration or the session's end.
GITHUB_TOKEN reflect permission changes in real-time?33275 reputation · 24 Jan 2023, 16:15 UTC
The GITHUB_TOKEN inside an active GitHub Codespace does not update instantly when repository permissions are revoked. The token remains usable until it expires, the codespace is stopped/restarted, or GitHub explicitly revokes it.
Permission changes are enforced for new token issuance, reconnections, and subsequent authorization checks, but an already‑issued bearer token is not pulled from the container in real‑time. Cached or already‑authorized operations may therefore succeed for a short window after the revocation.
gh codespace stop --codespace NAME (or delete).Do you require immediate token invalidation for your security incident response? If yes, the stop/delete step is essential; otherwise you can rely on the token’s natural expiration.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.