ci: harden github actions checkout with persist-credentials - #33772
Open
ShraddhaZoman wants to merge 1 commit into
Open
ci: harden github actions checkout with persist-credentials#33772ShraddhaZoman wants to merge 1 commit into
ShraddhaZoman wants to merge 1 commit into
Conversation
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.
What
Adds
persist-credentials: falseto theactions/checkoutstep in three workflows that didn't set it:.github/workflows/docs-preview-deploy.yml.github/workflows/google-internal-tests.yml.github/workflows/preview-deploy-dev-app.ymlWhy
actions/checkoutauthenticates git by writing a credential into the job's git configuration so later steps don't need to re-authenticate. Unlesspersist-credentials: falseis set, this credential remains in place for the rest of the job, usable by any process with filesystem access — not just git commands.Concretely, per affected file:
docs-preview-deploy.yml— requestspull-requests: write. The step immediately after checkout runs unpinnednpx -y firebase-tools@latest, resolved fresh from npm on every run. If that package (or a transitive dependency) were ever compromised at install time, it would have ambient access to apull-requests: write-scoped token it was never explicitly given.preview-deploy-dev-app.yml— samepull-requests: writeexposure, same structural risk for any current or future step added after checkout.google-internal-tests.yml— requestsstatuses: write. A compromised later step here could set arbitrary commit statuses using the same implicitly-available credential.In all three cases, impact is bounded by the job's own declared permissions (each already follows least privilege for its purpose) — this isn't a path to
contents: writeor secrets exfiltration beyond the ambient token itself. It's a defense-in-depth gap: the credential was never intended to be available past the checkout step, but in practice is available to everything that runs after it.Every other checkout in this repo already sets
persist-credentials: falsedirectly, or routes throughdev-infra'scheckout-and-setup-nodeaction, which sets it internally. These three were the only gap.Found while reviewing the repo's GitHub Actions configuration. This is a defense-in-depth fix rather than a demonstrated live exploit — it closes a gap where a credential persists longer than any of these jobs actually need it.
No behavior change expected — CI should be unaffected.