Skip to content

fix(ci): drop root contents: write to contents: read (CIS GHA 1.2)#253

Merged
Cre-eD merged 2 commits into
mainfrom
fix/workflow-root-perms-tighten
May 13, 2026
Merged

fix(ci): drop root contents: write to contents: read (CIS GHA 1.2)#253
Cre-eD merged 2 commits into
mainfrom
fix/workflow-root-perms-tighten

Conversation

@Cre-eD
Copy link
Copy Markdown
Contributor

@Cre-eD Cre-eD commented May 11, 2026

Summary

Tightens root workflow permissions on `branch.yaml`, `branch-preview.yaml`, and `push.yaml`.

Before: every job inherited `contents: write`. Today only a handful of jobs need it (tag-release, welder deploy, sticky-comment posting); build/test/lint/docker-build are all read-only. This PR drops the root grant and adds explicit per-job `contents: write` only where required.

Workflow Root Per-job writes
branch.yaml read finalize (already had it)
branch-preview.yaml read publish-sc-preview, publish-git-tag, finalize
push.yaml read docker-finalize (tag-release), finalize

Verification

Frameworks satisfied

Framework Control
CIS GitHub Actions Benchmark §1.2 (restrict workflow permissions)
OWASP Top 10 CI/CD CICD-SEC-1 (insufficient flow control), CICD-SEC-5 (PBAC)
NIST SP 800-218 SSDF PS.1 (protect all forms of code)
OpenSSF Scorecard Token-Permissions check

Test plan

  • Semgrep clean on all 5 workflows
  • CI green on this branch (build, test, docker-build, docker-finalize all complete)
  • No tag-release / publish step fails for permission reasons

Three workflows previously declared `permissions: contents: write` at
file scope, granting the broadest blast radius to every job. Only a
handful of jobs actually need to write the repo (tag-release, welder
deploy, sticky-comment posting); every other job — build-setup, lint,
test, build-platforms, build-binaries, docker-build, docker-build-push,
build-docs, prepare — is read-only.

Per CIS GitHub Actions Benchmark §1.2 and OWASP CICD-SEC-5, this PR
drops the root grant to `contents: read` and explicitly grants
`contents: write` only on the jobs that need it.

| Workflow | Root | Per-job writes |
|---|---|---|
| branch.yaml | read | finalize (already had it) |
| branch-preview.yaml | read | publish-sc-preview, publish-git-tag, finalize |
| push.yaml | read | docker-finalize (tag-release), finalize |

Verification
============

- All 5 workflows scanned with the SC Semgrep ruleset
  (`simple-container-com/actions/semgrep-scan/rules/github-actions.yml`):
  **0 findings** across the existing 19 rules.
- Every `actions/checkout` still uses `persist-credentials: false`
  (preserved from PR #238).
- No OIDC `id-token: write` was previously set anywhere — none is
  needed for the current writes (token-issuing OIDC isn't used).
- The `branch.yaml` PPE caveat from PR #238 is deliberately out of
  scope here: the team-accepted defense-in-depth comment + nosemgrep
  on that workflow indicate the proper `workflow_run`-gated split is
  tracked separately. This PR only tightens permissions, not triggers.

Frameworks satisfied
====================

- CIS GitHub Actions Benchmark §1.2
- OWASP CICD-SEC-1 (insufficient flow control), CICD-SEC-5 (PBAC)
- NIST SP 800-218 PS.1 (protect all forms of code)
- OpenSSF Scorecard "Token-Permissions" check

Signed-off-by: Dmitrii Creed <creeed22@gmail.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 11, 2026

Semgrep Scan Results

Repository: api | Commit: 211a9f1

Check Status Details
✅ Semgrep Pass 0 total findings (no error/warning)

Scanned at 2026-05-13 13:18 UTC

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 11, 2026

Security Scan Results

Repository: api | Commit: 211a9f1

Check Status Details
✅ Secret Scan Pass No secrets detected
⚠️ Dependencies (Trivy) High 1 high, 1 total
⚠️ Dependencies (Grype) High 1 high, 1 total
📦 SBOM Generated 470 components (CycloneDX)

Scanned at 2026-05-13 13:19 UTC

@Cre-eD Cre-eD merged commit a8dca02 into main May 13, 2026
18 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.

2 participants