Skip to content

ISSUE-705 follow-ups: cache-mode edge cases after the #533 rework #554

Open

Description

@Exypte

Is your feature request related to a problem? Please describe.

The ISSUE-705 rework in #533 (untrustedTriggersMustNotWriteCache: a job granted cache-mode: write or write-only on an untrusted trigger) left a few edge cases unhandled. Each one is rare, but each can make the finding wrong or less useful:

  1. Untested contexts in cache-mode expressions. GitHub rejects a cache-mode expression that reads github, vars or inputs (probed on github.com). matrix, needs and strategy were not probed. Plumber treats any expression that reads a context as invalid and stays silent, so if GitHub accepts e.g. ${{ needs.setup.outputs.mode || 'write' }}, that write grant is missed.
  2. YAML aliases and merge keys give line 0. A job defined through an alias (b: *a) or a merge key (<<: *defaults) that carries cache-mode gets its value, but the finding carries line: 0.
  3. An empty job-level cache-mode: drops the workflow's value. cache-mode: with no value (null) on a job is ignored instead of falling back to the workflow-level cache-mode. GitHub probably rejects such a file, so this is mostly about not hiding a grant.
  4. The old key under gitlab.controls points to the wrong fix. releaseWorkflowsMustNotRestoreUntrustedCache under gitlab.controls (reachable by migrating a v1 file) warns to run plumber config migrate, but migrate only rewrites github.controls and then reports "Nothing to do".
  5. Jobs that never run are still flagged. A job under a constant false if: with cache-mode: write raises ISSUE-705 and is counted as exempted, while the attack-path engine already ignores such jobs.

Describe the solution you'd like

  1. Probe matrix, needs and strategy on a scratch repository. Until then, resolve an expression that reads a context to write when one of its quoted strings is write or write-only (a file GitHub rejects never runs, so this costs nothing).
  2. Resolve aliases and merge keys when locating the cache-mode line, or fall back to the job's own line.
  3. Treat a null job-level cache-mode as absent, so the workflow-level value applies.
  4. Make the rename warning provider-aware, or have plumber config migrate drop the key from gitlab.controls and list the change.
  5. Skip dead jobs in the ISSUE-705 rule and in the exempted-jobs count.

Configuration in .plumber.yaml

No configuration change:

github:
  controls:
    untrustedTriggersMustNotWriteCache:
      enabled: true
      exemptWorkflows: []
      exemptJobs: []

Implementation Hints

  • Items 1 to 3 are in the GitHub collector's cache-mode resolution (ir.Job.CacheMode).
  • Item 4 is in the control rename warning and the migrate rename step.
  • Item 5 is a not job.dead guard in the rule, mirrored in the Go stats.
  • Every item needs a fixture under policies/testdata/ISSUE-705/github/, plus the rego/Go parity test.

Why It's Valuable

The point of #533 was a finding a maintainer cannot disprove. These cases either miss a real grant (1, 3), point at the wrong line (2) or the wrong fix (4), or flag a job that never runs (5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions