ci: pull-request runs can write caches that main's release builds restore #1430

Open
opened 2026-09-24 00:10:50 +00:00 by enricobuehler · 0 comments
Owner

The runner's cache server (gitea/runner 1.0.8) scopes cache entries by repository only, not by branch or event. A pull-request run can therefore save an entry under a key that a later build on main restores. The newest complete entry wins, for an exact key and for a prefix match. A workflow if: guard can't close this, because a pull request controls its own workflow file. Fork pull requests are included: the Linux lanes run for them.

Where it matters today

  • android.yml runs on pull_request and saves cargo-home-<Cargo.lock hash> with the combined actions/cache step (saves on a miss).
  • deb restores the cargo-home- prefix, which also matches cargo-home-ci-*, contrary to the comment in ci.yml.
  • deb's packages are what main publishes to the canary and release registries. So a cache written by a pull-request run can reach published artifacts.
  • Target caches were tightened in #1429: saves come only from pushes to main. That keeps honest pull requests from writing them, but it doesn't stop a workflow file written to save anyway.

Fix options

  1. Server side, the real fix: enable Gitea's "require approval to run workflows for pull requests from outside collaborators/forks", and/or give pull-request runs their own cache: a separate cache server, or runner-enforced key separation by event.
  2. In repo, for honest runs: pull-request jobs use actions/cache/restore only, never the combined action or a save. Registry caches restored by release jobs (deb, rpm, arch) should key on a prefix that pull-request lanes never write.
  3. Release jobs: build published packages from caches written only by main (or from no cache), and verify dependency sources against Cargo.lock checksums, which cargo already does for registry crates.

Found while reviewing the cache change for #1352 (#1429).

The runner's cache server (gitea/runner 1.0.8) scopes cache entries by repository only, not by branch or event. A pull-request run can therefore save an entry under a key that a later build on main restores. The newest complete entry wins, for an exact key and for a prefix match. A workflow `if:` guard can't close this, because a pull request controls its own workflow file. Fork pull requests are included: the Linux lanes run for them. ## Where it matters today - `android.yml` runs on `pull_request` and saves `cargo-home-<Cargo.lock hash>` with the combined `actions/cache` step (saves on a miss). - deb restores the `cargo-home-` prefix, which also matches `cargo-home-ci-*`, contrary to the comment in `ci.yml`. - deb's packages are what main publishes to the canary and release registries. So a cache written by a pull-request run can reach published artifacts. - Target caches were tightened in #1429: saves come only from pushes to main. That keeps honest pull requests from writing them, but it doesn't stop a workflow file written to save anyway. ## Fix options 1. **Server side, the real fix:** enable Gitea's "require approval to run workflows for pull requests from outside collaborators/forks", and/or give pull-request runs their own cache: a separate cache server, or runner-enforced key separation by event. 2. **In repo, for honest runs:** pull-request jobs use `actions/cache/restore` only, never the combined action or a save. Registry caches restored by release jobs (deb, rpm, arch) should key on a prefix that pull-request lanes never write. 3. **Release jobs:** build published packages from caches written only by main (or from no cache), and verify dependency sources against `Cargo.lock` checksums, which cargo already does for registry crates. Found while reviewing the cache change for #1352 (#1429).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: unom/punktfunk#1430