Skip to content

Conversation

@marcpopMSFT
Copy link
Member

@marcpopMSFT marcpopMSFT commented Oct 30, 2025

Tool was recommended by @blowdart I used the --fix switch.

Copilot AI review requested due to automatic review settings October 30, 2025 21:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances security in GitHub Actions workflows by preventing credential persistence and standardizing environment variable usage. The changes address security best practices for workflows that interact with PRs and external repositories.

  • Adds persist-credentials: false to checkout actions across multiple workflows to prevent credential exposure
  • Refactors GitHub Actions expression interpolation to use environment variables instead of direct inline expressions in shell scripts
  • Changes workflow triggers from pull_request_target to pull_request for safer execution context

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.github/workflows/update-static-web-assets-baselines.yml Adds persist-credentials: false and refactors all GitHub Actions expressions to use environment variables for safer shell script execution
.github/workflows/update-man-pages.yml Adds persist-credentials: false to checkout action
.github/workflows/remove-lockdown-label.yml Changes trigger from pull_request_target to pull_request for safer execution
.github/workflows/copilot-setup-steps.yml Adds persist-credentials: false to checkout action
.github/workflows/add-lockdown-label.yml Changes trigger from pull_request_target to pull_request and adds persist-credentials: false to checkout action

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

on:
pull_request_target:
pull_request:
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is going to work, nor do I think the change is correct.

As noted in GitHub's docs:

And noted in Zizmor's docs:

This workflow is precisely doing what the pull_request_target workflow is situated for: performing privileged actions on the upstream repo (labeling) without running code from the pull request. The pull_request event, for pull requests from forks, will not have the necessary permission, which would result in the PR showing the action as needing to be authorized. If authorized, that would permit a pull request to run an action with escalated permissions.

This is precisely why the dotnet/issue-labeler uses pull_request_target.

However, the other remediation notes on zizmor apply:

  1. Never run PR-controlled code in the context of a pull_request_target-triggered workflow.
  2. Consider adding a branch filter to only run the workflow for matching target branches.
  3. consider adding a github.repository == ... check to only run for your repository but not in forks

Where we've set up issue-labeler in each of our repos, we do apply all three of those remediations as well.

/cc @blowdart


on:
pull_request_target:
pull_request:
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as above; I don't think this change is right.

Comment on lines +6 to +9
branches:
- 'release/8.*'
- 'release/9.*'
- 'release/10.*'
Copy link
Member

Choose a reason for hiding this comment

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

I think it's reasonable to just use 'release/*' here as that probably matches the branch protection rule, then it wouldn't need to be updated with each release.

Comment on lines +19 to +20
# Only run on the main repository, not forks
if: github.repository == 'dotnet/sdk'
Copy link
Member

Choose a reason for hiding this comment

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

This works. Alternate approach we used for the issue-labeler is to only check the org and also to allow a manual dispatch to bypass this check. I doubt this repo would be renamed or that you care to let forks manually dispatch the action though.

https://github.com/dotnet/runtime/blob/0ad494ba0eb84ada521d259c7d24dd0892c7a54d/.github/workflows/labeler-predict-pulls.yml#L49-L50

@marcpopMSFT marcpopMSFT merged commit 3f743a9 into main Nov 1, 2025
27 checks passed
@marcpopMSFT marcpopMSFT deleted the marcpopMSFT-improveworkflows branch November 1, 2025 01:01
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.

4 participants