Skip to content

fix: harden CI workflow: switch to pull_request trigger and remove unnecessary id-token:write#214

Merged
gvanrossum merged 2 commits intomicrosoft:mainfrom
hgvfhsrtyvrt456vtg:fix/ci-security
Mar 5, 2026
Merged

fix: harden CI workflow: switch to pull_request trigger and remove unnecessary id-token:write#214
gvanrossum merged 2 commits intomicrosoft:mainfrom
hgvfhsrtyvrt456vtg:fix/ci-security

Conversation

@hgvfhsrtyvrt456vtg
Copy link
Contributor

Addressing two issues in the CI workflow:

  1. pull_request_target > pull_request: Fork PRs currently run in the base repo's execution context. Switching to pull_request runs fork PRs in the fork's context, which matches the workflow's declared read-only permissions and is the recommended trigger for CI jobs that don't need write access to the base repo.

(Some references:

  1. Remove id-token: write: No active job uses OIDC. This permission is a leftover from the commented-out online-test job and grants unnecessary token-minting capability.

No CI behavior change. All active jobs (check, format, offline-test) only need contents: read and pull-requests: read, which work identically with pull_request.

… "id-token:write" permission

Addressing two issues in the CI workflow:

1. **`pull_request_target` > `pull_request`**: Fork PRs currently run in the base repo's
   execution context. Switching to pull_request runs fork PRs in the fork's context, which matches the workflow's declared read-only permissions and is the recommended trigger for CI jobs that don't need write access to the base repo.

2. **Remove `id-token: write`**: No active job uses OIDC. This permission is a leftover
   from the commented-out `online-test` job and grants unnecessary token-minting capability.

No CI behavior change. All active jobs (`check`, `format`, `offline-test`) only need
`contents: read` and `pull-requests: read`, which work identically with `pull_request`.
@hgvfhsrtyvrt456vtg hgvfhsrtyvrt456vtg marked this pull request as ready for review March 5, 2026 11:03
@hgvfhsrtyvrt456vtg
Copy link
Contributor Author

Hello @gvanrossum

Just FYI, this is in relation to the two CI issues I mentioned earlier.

@gvanrossum
Copy link
Collaborator

I will discuss this with @robgruen.

But doesn't this enable a type of attack that changes the CI yml files?

Copy link
Collaborator

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Thanks -- two nits and then I'll approve it.

1. Removed the comment from  "pull_request: "
2. Removed the "id-token: write" line
Copy link
Collaborator

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Thanks! Will merge now.

@gvanrossum gvanrossum merged commit 671e00b into microsoft:main Mar 5, 2026
14 checks passed
@hgvfhsrtyvrt456vtg
Copy link
Contributor Author

Thanks, Guido!

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