Skip to content

ci: declare contents:read on jit-format workflow - #128205

Merged
akoeplinger merged 2 commits into
dotnet:mainfrom
arpitjain099:chore/declare-workflow-perms
Jul 19, 2026
Merged

akoeplinger merged 2 commits into
dotnet:mainfrom
arpitjain099:chore/declare-workflow-perms

Conversation

@arpitjain099

Copy link
Copy Markdown
Contributor

Pins .github/workflows/jit-format.yml to permissions: contents: read at the workflow level. The job sets up .NET and Python, runs the JIT format scripts on the changed code, and then uploads a format.patch artifact via actions/upload-artifact. Artifact upload is part of the run's own scope; none of the steps call a GitHub API that requires write access.

This is a defense-in-depth measure rooted in CVE-2025-30066 (the March 2025 tj-actions/changed-files supply-chain attack), where a tampered third-party action exfiltrated GITHUB_TOKEN via the workflow logs. The leaked token retained whatever scope was issued, so capping each workflow to the minimum it needs is the most reliable way to bound that blast radius if any of the dozens of actions/* and actions/setup-* consumers ever get compromised. Declaring this in-file also gives drift protection against future repo or org default changes and is what OpenSSF Scorecard's Token-Permissions check credits.

YAML validated with yaml.safe_load.

@arpitjain099
arpitjain099 requested review from a team and jeffhandley as code owners May 14, 2026 15:53
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label May 14, 2026
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 14, 2026
@arpitjain099

Copy link
Copy Markdown
Contributor Author

Gentle ping - has been open for a couple weeks. When you have a moment, would you mind giving it a quick look? Happy to address any feedback.

@JulieLeeMSFT JulieLeeMSFT left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
CC @jeffhandley.

@JulieLeeMSFT JulieLeeMSFT added this to the 11.0.0 milestone May 27, 2026
@JulieLeeMSFT JulieLeeMSFT added area-Infrastructure and removed area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labels May 27, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

@github-actions

github-actions Bot commented Jul 19, 2026 •

Copy link
Copy Markdown
Contributor

Workflow state for the Holistic Review Orchestrator.

{
  "version": 5,
  "last_dispatched_commit": "67b4f421a5563e86236bc25e100766e7788153c1",
  "last_dispatched_base_ref": "main",
  "last_dispatched_base_sha": "2c21b93b70abc47370477712689190e993a3706f",
  "last_reviewed_commit": "67b4f421a5563e86236bc25e100766e7788153c1",
  "last_reviewed_base_ref": "main",
  "last_reviewed_base_sha": "2c21b93b70abc47370477712689190e993a3706f",
  "last_recorded_worker_run_id": "29690681185",
  "review_attempt_commit": "",
  "review_attempt_base_ref": "",
  "review_attempt_count": 0,
  "max_review_attempts": 5,
  "review_history_format": "holistic-review-disclosure-v1",
  "review_history": [
    {
      "commit": "67b4f421a5563e86236bc25e100766e7788153c1",
      "review_id": 4730924704
    }
  ]
}

@arpitjain099

Copy link
Copy Markdown
Contributor Author

@JulieLeeMSFT This PR hasn't been merged (it got approved earlier, thanks to you). Can you please follow-up to see and get it merged please.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holistic Review

Motivation: Harden the jit-format.yml GitHub Actions workflow by adding an explicit top-level permissions block. Without an explicit block, the workflow inherits the repository/organization default GITHUB_TOKEN scopes, which can be broader than necessary. Constraining the token to least privilege is a recognized supply-chain security best practice.

Approach: A single permissions: mapping with contents: read is added at the top level of the workflow, immediately after the on: trigger and before jobs:. This makes read-only contents the default for every job and step. The workflow's actual work — actions/checkout, setup-dotnet, setup-python, running jitformat.py, and upload-artifact on failure — only requires read access to repository contents, so no additional permissions are needed.

Summary: The change is minimal, correct, and low-risk. contents: read is the appropriate least-privilege scope for this format-checking workflow, and no step needs write access. YAML placement and indentation are valid. This is a clean security improvement with no functional downside. LGTM.

Detailed Findings

No actionable issues. The added permissions: contents: read block is well-placed and matches the workflow's actual token needs.

Note

This review was generated by this repository's Holistic Review agentic workflow to complement the built-in Copilot review.

Generated by Holistic Review · 42.6 AIC · ⌖ 10.2 AIC · ⊞ 10K

@akoeplinger akoeplinger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holistic Review

Motivation: Justified. Adding an explicit workflow-level permissions: contents: read to jit-format.yml is a real, well-understood defense-in-depth hardening. Without an explicit block, the GITHUB_TOKEN inherits the repository/org default (potentially write), so pinning it bounds the blast radius if any consumed action is compromised, and provides drift protection against future default changes.

Approach: Correct and minimal. I independently traced every step: actions/setup-dotnet, actions/checkout (into runtime/), actions/setup-python, running jitformat.py, and actions/upload-artifact on failure. None of these calls a GitHub API that requires write scope — artifact upload uses the runtime's own artifact backend, not the contents API. A single top-level contents: read therefore grants exactly what the run needs, and since there is only one job, a job-level block would be equivalent; the workflow-level placement is fine and slightly more future-proof. This matches the pattern used across other hardened workflows in the repo.

Summary: ✅ LGTM. A 3-line, low-risk security hardening that follows the least-privilege convention. No correctness, performance, or behavioral concerns; the workflow's functional steps are unchanged and all remaining operations are read-only.

Note

This review was generated by this repository's Holistic Review agentic workflow to complement the built-in Copilot review.

Generated by Holistic Review · 38 AIC · ⌖ 9.92 AIC · ⊞ 10K

@akoeplinger
akoeplinger merged commit 5ab062f into dotnet:main Jul 19, 2026
23 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot modified the milestones: 11.0.0, 11.0-preview7 Jul 20, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-Infrastructure community-contribution Indicates that the PR has been added by a community member

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants