Skip to content

fix(policies): resolve the cache-poisoning release path per trigger - #500

Merged
thomasboni merged 3 commits into
mainfrom
fix/issue-705-conditional-cache
Sep 29, 2026
Merged

thomasboni merged 3 commits into
mainfrom
fix/issue-705-conditional-cache

Conversation

@thomasboni

@thomasboni thomasboni commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Closes #497.

Why

releaseWorkflowsMustNotRestoreUntrustedCache (ISSUE-705, High) treated any non-empty, non-"false" enable input as an active cache and reasoned at the job level. A repository doing exactly the remediation the finding recommends, disabling the cache on the publish trigger with cache: ${{ github.event_name != 'workflow_dispatch' && 'maven' || '' }} or splitting caching into a step whose if: excludes the publish trigger, got the same High as one doing nothing. A false positive there teaches maintainers to disable the control.

What

  • IR + collector: Action gains if, Job gains if (the job gate alone; Conditions flattens job and step ifs together and cannot serve) and scriptIfs (aligned with scripts, present only when some run step is conditional), filled from the workflow YAML. Optional fields, omitted when empty, so the contract stays forward-tolerant.
  • Policy: ISSUE-705 fires only when a restore and a publish can share an event. Restore events = the job triggers, narrowed by the job-level if:, the step if:, the canonical enable shape github.event_name ==/!= '<event>' && '<manager>' || '', and (default-mode actions) a conditional disable input in both disableValue directions. Publish events = the release trigger plus publish actions/scripts, each narrowed by its own if:. Unrecognized conditions narrow nothing, and jobs without trigger data keep the job-level context, so verdicts outside the new shapes are unchanged (all 20 pre-existing fixtures pass untouched).
  • Reusable workflows: github.event_name in a workflow_call workflow is the caller's event, never the literal "workflow_call", so the event universe there is the finite abstraction of the open caller domain: every event the job's conditions name plus a caller token that satisfies every != but no ==. An event-gated publish in a reusable workflow keeps its High while the remediation above still resolves inside one.
  • ISSUE-717 (new, medium): a whole-value enable or disable expression outside the resolvable shapes cannot be resolved per trigger, and asserting the High would claim a restore that may never happen. It downgrades to a verify-manually finding on the same control (one control, two codes graded by certainty, the ISSUE-307/310 pattern). Same identity key as ISSUE-705; the legacy payload counts the two separately; catalog golden refreshed (additive).

Testing

  • Fifteen new end-to-end fixtures through the real workflow scanner: both shapes from the issue and the == inverse, conditional disables (both directions, clean and overlap), job-level and publish-action if: gating, the reusable-workflow false negative and its remediated twin, three reusable-universe pins, and the unresolvable downgrades (asserted 0 x ISSUE-705, 1 x ISSUE-717 medium). Every behavior change watched red on the previous head first; clean fixtures assert silence of BOTH codes.
  • New collector test pins Action.If / Job.If / Job.ScriptIfs capture and the absent-when-unconditional contract; a legacy-payload test pins the split metrics.
  • Full policies (incl. identity harness), github, control, cmd, finding, configuration, internal/..., pbom, gitlab suites green; go vet clean; pinned golangci-lint: 0 issues.

Follow-up

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ft8dmcMLK7V9XZh7JX4vzs

Comment thread cmd/legacy_json_github.go Resolved
Comment thread policies/rules_test.go Resolved
@thomasboni
thomasboni force-pushed the fix/issue-705-conditional-cache branch from 83c6be2 to 20cf1a6 Compare September 29, 2026 00:04
Comment thread policies/cache_poisoning.rego Resolved
@thomasboni
thomasboni force-pushed the fix/issue-705-conditional-cache branch from 20cf1a6 to 8c327af Compare September 29, 2026 00:17
Comment thread policies/cache_poisoning.rego Resolved
Comment thread policies/cache_poisoning.rego Resolved
Comment thread policies/cache_poisoning.rego Resolved
@thomasboni
thomasboni force-pushed the fix/issue-705-conditional-cache branch from 8c327af to 205d814 Compare September 29, 2026 00:31
Comment thread policies/cache_poisoning.rego Resolved
@thomasboni
thomasboni force-pushed the fix/issue-705-conditional-cache branch from 205d814 to 2223e78 Compare September 29, 2026 00:41
Comment thread policies/cache_poisoning.rego Resolved
Comment thread policies/cache_poisoning.rego Resolved
@thomasboni
thomasboni force-pushed the fix/issue-705-conditional-cache branch from 2223e78 to a0ba2cb Compare September 29, 2026 00:54
The IR had no notion of when a step runs: Action lost the workflow's
step-level `if:`, Scripts was a bare list, and the job-level `if:`
only existed flattened into Conditions together with every step's,
unusable as the job gate. Action gains `if`, Job gains `if` (the job
gate alone) and `scriptIfs` (aligned index for index with Scripts, set
only when some run step is conditional), all filled by the GitHub
workflow collector. The fields are optional and omitted when empty, so
the ingestion contract stays forward-tolerant.

Groundwork for the issue #497 fix: the cache-poisoning release-path
resolution reads them.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ft8dmcMLK7V9XZh7JX4vzs
@thomasboni

Copy link
Copy Markdown
Contributor Author

e2e: standalone and platform mode, released v0.5.12 vs this branch

Scenario branch: plumber-lab-github e2e/issue-497, one workflow per shape (the issue's two shapes, the == inverse case folded into the split-steps one, an unresolvable vars.* expression, a reusable workflow with an event-gated publish, a job-level if: excluding release, a default-mode setup-go conditional disable) plus the original vulnerable.yml as the baseline that must keep firing.

Standalone (plumber analyze in the checkout, GH_TOKEN set)

job v0.5.12 this branch
vulnerable/publish ISSUE-705 ISSUE-705
i497-reusable/publish ISSUE-705 ISSUE-705
i497-repro/build-and-publish ISSUE-705 silent
i497-split-steps/build-and-publish ISSUE-705 silent
i497-job-if/test ISSUE-705 silent
i497-setup-go-conditional/publish ISSUE-705 silent
i497-unresolved/publish ISSUE-705 ISSUE-717 (medium)

Artifacts from the branch build: the SARIF carries an ISSUE-717 rule (level warning, helpUri to the docs page) and every result has a location (Code Scanning contract); the OCSF report and the legacy JSON are produced, the latter with unscopedCacheRestoreFound: 2, unresolvedConditionalCacheFound: 1; the terminal report renders MED [ISSUE-717] with its docs link and the summary row reads ISSUE-705, ISSUE-717.

Platform mode (GitHub Actions, PR build, e2e platform)

Run 36508644987 builds the CLI from 49d485d in the job and runs analyze --platform https://plumber.e2e.getplumber.tech: exit 0, same three verdicts, the usual GitHub "results sink" incomplete-collection notice. On the platform side the run was ingested and the issues stored with the pushed severity and the right control:

issue: code=ISSUE-705 | severity=high   | job=i497-reusable/publish  | control=releaseWorkflowsMustNotRestoreUntrustedCache | status=Detected
issue: code=ISSUE-705 | severity=high   | job=vulnerable/publish     | control=releaseWorkflowsMustNotRestoreUntrustedCache | status=Detected
issue: code=ISSUE-717 | severity=medium | job=i497-unresolved/publish | control=releaseWorkflowsMustNotRestoreUntrustedCache | status=Detected

The platform needs no change for the new code: ingestion has no code allowlist, display severity is the pushed one, and the scoring fallback for a code its pinned CLI module does not know is medium, which is ISSUE-717's severity. A pin bump after the release adds the title and doc URL to /issue-types and /controls.

Consistency pass

The third commit (e75c6ea) is the result of a whole-repo sweep: every place documenting the control (docs/GITHUB_ISSUES.md, both .plumber.yaml, config struct and schema docs, registry description, wizard label, rego comments, the ISSUE-717 wording) now describes the per-trigger resolution and the downgrade. Docs site companion: getplumber/getplumber.io#432.

Comment thread policies/rules_test.go Resolved
Comment thread policies/cache_poisoning.rego Resolved
@thomasboni
thomasboni force-pushed the fix/issue-705-conditional-cache branch from e75c6ea to 988a294 Compare September 29, 2026 01:50
Comment thread policies/cache_poisoning.rego Resolved
thomasboni and others added 2 commits September 29, 2026 02:01
Closes #497. releaseWorkflowsMustNotRestoreUntrustedCache treated any
non-empty enable input as an active cache and reasoned job-level, so a
repository doing the recommended remediation (a conditional `cache:`
expression that is empty on the publish trigger, or caching split into
a step whose `if:` excludes it) got the same High as one doing nothing.

ISSUE-705 now requires an event where a restore and a publish can
share a run: job triggers, narrowed by each step's `if:` and by the
canonical enable shape `${{ github.event_name ==/!= '<event>' &&
'<manager>' || '' }}`, intersected with the publish events (the
release trigger, publish actions and publish scripts, each narrowed by
its own `if:`). Unrecognized conditions narrow nothing and jobs
without trigger data keep the job-level context, so every existing
verdict outside the new shapes is unchanged.

A whole-value enable expression outside the canonical shape cannot be
resolved, and asserting the High would be a guess: it downgrades to
the new medium ISSUE-717 verify-manually code on the same control (one
control, two codes graded by certainty, the ISSUE-307/310 pattern).
The legacy payload counts the two separately and the catalog golden
picks up the additive code.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ft8dmcMLK7V9XZh7JX4vzs
…717 everywhere the control is documented

A consistency pass over every place that documents
releaseWorkflowsMustNotRestoreUntrustedCache after the issue #497
rework. docs/GITHUB_ISSUES.md gains the ISSUE-717 entry (table of
contents, section, control-name shortcut row) and the ISSUE-705 section
explains the per-trigger resolution; both .plumber.yaml files, the
config struct docs, the schema docs, the control registry description
and the wizard label stop describing the cache modes in literal-value
terms only. The ISSUE-717 message and description now name the
default-mode disable input the rule also downgrades, not just the
opt-in enable input, and the contract test counts a stray ISSUE-717 on
its clean case as a failure.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ft8dmcMLK7V9XZh7JX4vzs
@thomasboni
thomasboni force-pushed the fix/issue-705-conditional-cache branch from 988a294 to e23695f Compare September 29, 2026 02:01
Comment thread policies/cache_poisoning.rego Resolved
@thomasboni
thomasboni merged commit c626275 into main Sep 29, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ISSUE-705 flags a setup action whose cache: input is disabled on the release trigger by an expression

1 participant