Pre-submission checks
zizmor version
1.23.1
Expected behavior
Swatinem/rust-cache with save-if: ${{ github.event_name != 'pull_request' }} should not trigger cache-poisoning, since save-if: false prevents cache writes entirely — the same mitigation as lookup-only: true but less restrictive (cache restoration still works on PRs for build speed).
Actual behavior
zizmor flags the step as cache-poisoning regardless of the save-if value. Looking at cache_poisoning.rs, the Swatinem/rust-cache ActionCoordinate only registers lookup-only as the control field:
ActionCoordinate::Configurable {
uses_pattern: "Swatinem/rust-cache".parse().unwrap(),
control: ControlExpr::single(
Toggle::OptOut,
"lookup-only",
ControlFieldType::Boolean,
true,
),
},
save-if is not recognized at all, even though it directly controls whether cache writes happen.
Reproduction steps
on:
push:
branches: [main]
tags: ['v*']
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'pull_request' }}
- run: cargo build
Running zizmor on this workflow reports a cache-poisoning finding on the Swatinem/rust-cache step, despite save-if preventing cache writes on PR events.
Suggested fix
Add save-if as a second recognized control field for Swatinem/rust-cache in cache_poisoning.rs, as an OptOut boolean toggle (when save-if: false, no cache is written — same effect as lookup-only: true for the poisoning vector).
Additional context
Related issues:
save-if documentation in Swatinem/rust-cache
Pre-submission checks
zizmor version
1.23.1
Expected behavior
Swatinem/rust-cachewithsave-if: ${{ github.event_name != 'pull_request' }}should not triggercache-poisoning, sincesave-if: falseprevents cache writes entirely — the same mitigation aslookup-only: truebut less restrictive (cache restoration still works on PRs for build speed).Actual behavior
zizmor flags the step as
cache-poisoningregardless of thesave-ifvalue. Looking atcache_poisoning.rs, theSwatinem/rust-cacheActionCoordinateonly registerslookup-onlyas the control field:save-ifis not recognized at all, even though it directly controls whether cache writes happen.Reproduction steps
Running
zizmoron this workflow reports acache-poisoningfinding on theSwatinem/rust-cachestep, despitesave-ifpreventing cache writes on PR events.Suggested fix
Add
save-ifas a second recognized control field forSwatinem/rust-cacheincache_poisoning.rs, as anOptOutboolean toggle (whensave-if: false, no cache is written — same effect aslookup-only: truefor the poisoning vector).Additional context
Related issues:
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}being vulnerable to a cache poisoning attack #1940 — similar false positive forsccache:parameter onPyO3/maturin-actionsave-ifdocumentation in Swatinem/rust-cache