[no-ci] ci: restrict PR metadata check token to pull-request read access - #2081
[no-ci] ci: restrict PR metadata check token to pull-request read access#2081arpitjain099 wants to merge 3 commits into
Conversation
| @@ -17,6 +17,10 @@ on: | |||
| - reopened | |||
| - ready_for_review | |||
|
|
|||
| permissions: | |||
| contents: read | |||
There was a problem hiding this comment.
I asked Cursor GPT-5.4 Extra High Fast if read (in general) is sufficient. After fetching a bunch of GHA API documentation, it came back with a "yes", but it isn't sure if the contents: read is actually required.
@arpitjain099: since this workflow only reads PR metadata via gh pr view and does not check out code, do you know whether pull-requests: read alone is sufficient, or whether contents: read is also required?
There was a problem hiding this comment.
Good question. The workflow only calls gh pr view, which goes through the REST API and doesn't touch repo contents, so pull-requests: read alone is sufficient. I left contents: read in as future-proofing in case a checkout step ever gets added, but happy to drop it for the minimum scope if you prefer. Either works for the CVE-2025-30066 hardening intent.
Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
8af3fb2 to
fc6baf9
Compare
|
We (that's codex gpt-5.6-sol ultra & rwgk) took a careful second look at this PR, including the workflow's actual API use, GitHub's We also confirmed that Background considered (optional reading)General workflow hygiene. Declaring permissions explicitly documents what the job needs, avoids inheriting broader repository defaults, and sets every unspecified configurable permission to
Preventing accidents. A mistaken command or future workflow edit cannot mutate repository state unless someone first expands the declared permissions. The failing authorization then acts as a useful review tripwire instead of allowing an accidental write. Guarding against attacks. This is meaningful defense in depth, particularly for a The current workflow already has a small attack surface: it does not check out or execute PR code, uses no third-party Action, and exposes no separate credential. The explicit minimum permission complements those safeguards by limiting the blast radius of future regressions or supply-chain compromise. |
rwgk
left a comment
There was a problem hiding this comment.
@arpitjain099 sorry for the long delay, this totally slipped my attention.
pr-metadata-check.ymlruns onpull_request_targetand usesgh pr view --json assignees,labels,milestoneto enforce PR hygiene. It only reads PR metadata, no checkout. Addingcontents: read(for the implicit checkout if it gets re-added later) pluspull-requests: read(for thegh pr viewcall) caps the otherwise-inherited token scope onpull_request_target.