Repository navigation
ci: guard required checks against paths filters and workflow-wide write tokens #17457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b9e6b6b
b762cf2
a3dba44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -94,17 +94,18 @@ concurrency: | |
| group: nightly-build-${{ github.ref_name }}-${{ github.event_name == 'workflow_dispatch' && inputs.promote_nightly_next_sha != '' && format('nightly-next-promote-{0}', github.run_id) || github.event_name == 'schedule' && github.event.schedule == '17 */6 * * *' && 'cache-seed-scheduled' || inputs.seed_only && 'cache-seed-manual' || github.event_name == 'workflow_dispatch' && github.event.inputs.build_only == 'true' && format('nightly-measure-{0}', github.run_id) || (github.event_name == 'workflow_dispatch' && github.event.inputs.fast == 'true' && 'fast' || 'full') }} | ||
| cancel-in-progress: false | ||
|
|
||
| permissions: | ||
| contents: write | ||
| attestations: write | ||
| id-token: write | ||
| permissions: {} | ||
|
|
||
| env: | ||
| CREATE_DMG_VERSION: 8.0.0 | ||
| CI_CACHE_R2_PUBLIC_URL: ${{ vars.CI_CACHE_R2_PUBLIC_URL || 'https://ci-cache.cmux.com' }} | ||
|
|
||
| jobs: | ||
| decide: | ||
| permissions: | ||
| contents: write | ||
| attestations: write | ||
| id-token: write | ||
|
Comment on lines
+105
to
+108
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🛡️ Detected with Advanced Tier | 🔵 Trivial | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- named revisions ---'
git cat-file -t 615a10315f13e5eeeb412a92f8d550ec1a1aba67
git cat-file -t a3dba44a70a6a4f501fb0ae4087dbf5db1ff28cd
printf '%s\n' '--- PR diff ---'
git diff --find-renames 615a10315f13e5eeeb412a92f8d550ec1a1aba67 a3dba44a70a6a4f501fb0ae4087dbf5db1ff28cd -- .github/workflows/nightly.yml
printf '%s\n' '--- reviewed workflow ---'
git show a3dba44a70a6a4f501fb0ae4087dbf5db1ff28cd:.github/workflows/nightly.yml | nl -ba
printf '%s\n' '--- policy mentions for workflows ---'
rg -n -i --glob '*.md' --glob '*.yml' --glob '*.yaml' 'permissions:|least privilege|contents: write|attestations: write|id-token: write|SwiftPM Package.resolved Policy' .githubRepository: manaflow-ai/cmux Length of output: 42377 🤖 get_repo_knowledge executed:
Length of output: 47700 🏁 Script executed: #!/bin/bash
set -e
f=.github/workflows/nightly.yml
printf '%s\n' '--- target-job steps and API operations ---'
rg -n -C 4 '^( decide:| probe-nightly-tag-permission:| refresh-compilation-cache:| refresh-test-compilation-cache:| build-nightly-ghostty-cli-helper:| build-nightly-app:| publish-nightly:| permissions:)|uses:|github\.rest\.(git|repos)\.(create|update|delete|push|patch|put)|attest-build-provenance|id-token|google-github-actions/auth|aws-actions/configure-aws-credentials' "$f" | sed -n '1,300p'
printf '%s\n' '--- permission-probe reusable workflow ---'
nl -ba .github/workflows/nightly-tag-permission-probe.yml | sed -n '1,130p'
printf '%s\n' '--- candidate mandatory guidance ---'
nl -ba .github/review-bot-rules/swiftpm-package-resolved.md | sed -n '1,100p'
printf '%s\n' '--- least-privilege references in reviewed workflow ---'
rg -n -i -C 2 'least privilege|permissions' .github/workflows/nightly.yml | sed -n '1,150p'Repository: manaflow-ai/cmux Length of output: 25680 🏁 Script executed: #!/bin/bash
set -e
f=.github/workflows/nightly.yml
printf '%s\n' '--- app-build job and actions ---'
sed -n '1062,1432p' "$f" | rg -n '(^ build-nightly-app:|^ permissions:|^ [a-zA-Z0-9_-]+:|^[[:space:]]+- name:|^[[:space:]]+uses:|^[[:space:]]+run:|github\.token|GH_TOKEN|GITHUB_TOKEN|github\.rest\.|attest-build-provenance|id-token|permission-contents|permission-workflows)'
printf '%s\n' '--- app-build permission-adjacent source ---'
nl -ba "$f" | sed -n '1058,1080p;1370,1435p'
printf '%s\n' '--- all app-build GitHub API/token references ---'
sed -n '1062,1432p' "$f" | rg -n -i 'github\.rest|github\.api|gh api|gh release|gh pr|github\.token|github_token|gh_token|git push|update-ref|createRef|updateRef|createRelease|uploadReleaseAsset|attest-build-provenance' || test "$?" -eq 1Repository: manaflow-ai/cmux Length of output: 8118 Security Misconfiguration Reachability: Internal Limit each job to the permissions it uses. These job grants preserve the workflow-level permissions from the base, so they do not increase effective privileges. The jobs still have scopes they do not need. Narrow the job permissions decide:
permissions:
- contents: write
- attestations: write
- id-token: write
+ contents: read
probe-nightly-tag-permission:
permissions:
contents: write
- attestations: write
- id-token: write
refresh-compilation-cache:
permissions:
- contents: write
- attestations: write
- id-token: write
+ contents: read
refresh-test-compilation-cache:
permissions:
- contents: write
- attestations: write
- id-token: write
+ contents: read
build-nightly-ghostty-cli-helper:
permissions:
- contents: write
- attestations: write
- id-token: write
+ contents: read
build-nightly-app:
permissions:
- contents: write
+ contents: read
attestations: write
id-token: write🧰 Tools🪛 zizmor (1.30.1)[warning] 106-106: permissions without explanatory comments (undocumented-permissions): needs an explanatory comment (undocumented-permissions) 🤖 Prompt for AI Agents |
||
| if: github.event_name != 'workflow_dispatch' || ((inputs.probe_mode || 'off') == 'off' && inputs.promote_nightly_next_sha == '') | ||
| runs-on: ${{ github.repository_owner != 'manaflow-ai' && 'ubuntu-24.04' || vars.LINUX_RUNNER || 'blacksmith-4vcpu-ubuntu-2404' }} | ||
| outputs: | ||
|
|
@@ -574,6 +575,10 @@ jobs: | |
| core.notice(`Promoted ${target} to ${sha}; its push run publishes it.`); | ||
|
|
||
| probe-nightly-tag-permission: | ||
| permissions: | ||
| contents: write | ||
| attestations: write | ||
| id-token: write | ||
| if: github.event_name == 'workflow_dispatch' && (inputs.probe_mode || 'off') != 'off' | ||
| uses: ./.github/workflows/nightly-tag-permission-probe.yml | ||
| with: | ||
|
|
@@ -582,6 +587,10 @@ jobs: | |
| secrets: inherit | ||
|
|
||
| refresh-compilation-cache: | ||
| permissions: | ||
| contents: write | ||
| attestations: write | ||
| id-token: write | ||
| needs: decide | ||
| # The schedule skips this Blacksmith warmer while owned pools serve pull | ||
| # requests (CI_PR_POOL_OWNED is 1). build-nightly-app saves the same key on | ||
|
|
@@ -746,6 +755,10 @@ jobs: | |
| key: spm-${{ hashFiles('cmux.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved', 'scripts/ci/swiftpm-cache-layout') }} | ||
|
|
||
| refresh-test-compilation-cache: | ||
| permissions: | ||
| contents: write | ||
| attestations: write | ||
| id-token: write | ||
| needs: decide | ||
| # The schedule skips this Blacksmith seeder while owned pools serve pull | ||
| # requests (CI_PR_POOL_OWNED is 1): admission then runs on owned minis that | ||
|
|
@@ -987,6 +1000,10 @@ jobs: | |
| key: ${{ steps.derived-data-seed-key.outputs.scoped }}${{ needs.decide.outputs.head_sha }} | ||
|
|
||
| build-nightly-ghostty-cli-helper: | ||
| permissions: | ||
| contents: write | ||
| attestations: write | ||
| id-token: write | ||
| needs: decide | ||
| if: needs.decide.outputs.should_build == 'true' && (github.event_name != 'schedule' || github.event.schedule == '47 8 * * *') && needs.decide.outputs.build_only != 'true' | ||
| # Zig 0.15.2 cannot link the real helper on macOS 26. Match the stable | ||
|
|
@@ -1043,6 +1060,10 @@ jobs: | |
| retention-days: 1 | ||
|
|
||
| build-nightly-app: | ||
| permissions: | ||
| contents: write | ||
| attestations: write | ||
| id-token: write | ||
| needs: decide | ||
| outputs: | ||
| daemon_build: ${{ steps.remote_daemon.outputs.build }} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🛡️ Detected with Advanced Tier | 🔵 Trivial | 💤 Low value
🧩 Analysis chain
🏁 Script executed:
Repository: manaflow-ai/cmux
Length of output: 42071
🤖 get_repo_knowledge executed:
get_repo_knowledge manaflow-ai/cmux /tmp/coderabbit-repo-knowledge/manaflow-ai-cmux-b0f68d40/conventions /tmp/coderabbit-repo-knowledge/manaflow-ai-cmux-b0f68d40/learningsLength of output: 47650
🏁 Script executed:
Repository: manaflow-ai/cmux
Length of output: 3687
🌐 Web query:
GitHub Actions official documentation reusable workflows GITHUB_TOKEN permissions caller called workflow can only reduce permissions job level💡 Result:
Security Misconfiguration
Reachability: Internal
Exploitability: Difficult
CWE: CWE-250
Limit the probe caller to
contents: write. The called job requests onlycontents: write. Remove the unused caller scopes so the reusable workflow cannot use them if it later requests broader permissions.Narrow the caller permissions
View in Security blast radius
🤖 Prompt for AI Agents