Repository navigation
Conversation
…s bytes A token run named its GitHub-side cache scope after a hash of the token. Installation tokens (an Action's App token or GITHUB_TOKEN) are minted every run, so ETags, immutable Git objects, catalogs, hints, the inventory actor and nix/mise listings never carried over between runs. `Client::identify` now scopes a `ghs_` token by the API root, its App's bot user id and either the account (`all`) or the sorted repository ids (`selected`), read live from installation/repositories and GraphQL viewer. It uses that scope only after the token reads a repository's contents in the run, and keeps the token hash on any unexpected answer. Other tokens keep the token hash. Cached blobs are now checked against their SHA, since the scope is no longer secret. The threat model states the invariants.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
count-patchula | 782d15a | Commit Preview URL Branch Preview URL |
Nov 16 2026, 02:23 AM |
…unrevalidated endpoints, gate the action's cache save Drop the repository_selection "all" branch: every ghs_ token is keyed by its bot and the sorted ids it lists, so a narrowed token can never share the full installation's scope whatever GitHub calls its selection. List the endpoints the scoped cache answers without revalidation in unrevalidated::ENDPOINTS; any other such read fails, and a test checks every get_immutable call site against the list. The action now restores and saves separately and saves in a public repository only when the token is an installation token listing that repository alone, since fork pull requests can restore the cache. The threat model covers confidentiality and repositories leaving an installation.
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 and why
A token run (the CLI and the action) named its GitHub-side cache scope after
sha256("Bearer <token>"). Installation tokens are minted fresh every Action run, so nothing keyed by the scope carried over: ETags,get_immutableGit objects,catalogstate,LookupHint,inventory-actorand the nix/mise listings. The server already used a stablegithub-app:{id}/installation:{id}.Client::identify(crates/github/src/identity.rs) runs forghs_tokens only, which includesGITHUB_TOKEN. It makes live requests that never touch the cache:GET /installation/repositories?per_page=100(at most 10 pages, walked to the end), GraphQLviewer { databaseId }, and a contents proof. The scope is always{api root}|app:{bot id}/repos:{sha256 of sorted listed ids}.repository_selectionmust beallorselectedand stay the same across pages, but it never shapes the key. So a token narrowed to fewer repositories can't share the full installation's entries, whatever GitHub calls its selection.total_count, a viewer without an id, or a failed contents proof. An installation with more than 1,000 repositories therefore keeps the token hash.ghp_,github_pat_),gho_andghu_tokens keep the token hash and make no request.unrevalidated::ENDPOINTSis the one list of endpoints the cache answers without asking GitHub: Git blobs, recursive trees and commits, underrepos/{owner}/{repo}or a renamed repository'srepositories/{id}. Each needs onlycontents: read. Any other read that skips revalidation fails withError::Unrevalidated, and a unit test checks theformat!path of everyget_immutablecall in the workspace against the list. The scope is used only after the token readsrepos/{r}/commits?per_page=1on a repository in its set, a private one if there is any.blobs()now always asks GitHub.ghs_token whose listing is exactly that repository. Everything else saves nothing and leaves a notice, including failed checks and personal tokens. The reason: a fork's pull request can restore a public repository's cache, and the cache is as confidential as the widest token that filled it.Engine::from_settingsis now async so a token run can callidentifybefore the client is cloned.internals/github-client.mdgains a "Token scope" section, andinternals/cache.mdlinks to it.guide/github-actions.mdsays what carries over (blobs, catalogs, listings, hints; no 304s promised) and adds a caution for public repositories. It tells users to run organization-wide tokens from a private runner repository and to delete caches older action versions saved.State versions
The
crates/github/src/tree,blobs.rsanddatasource/src/lib.rsare hashed sources, so these are bumped and their rows updated:extract,files,config,config-files,source-head,tag-catalog,tag-object,release-notescatalog,catalog-controls,changelog,notes-adaptergithub-release-head,notes-adapter-listing,parsed-postgres-sgml,parsed-go-historyTests
All offline, in
crates/github/tests/identity.rsandsrc/unrevalidated.rs:alland for two-pageselectedlistingsghs_tokens with the same listing, includingallagainstselectedover the same idsall, or with another App's botRan on the VM:
cargo testand clippy with-D warningsfor github, datasource, notes, engine, update, cli and server. Locally: zizmor and jactionlint onaction.yml,gh actions-lock --no-fix(lock unchanged).Follow-ups
GITHUB_TOKENcan callGET /installation/repositories. If it can't, aGITHUB_TOKENrun keeps the token hash, and in a public repository it doesn't save the cache. Both fail closed.