Potential fix for code scanning alert no. 265: Checkout of untrusted code in trusted context - #57
Merged
Merged
Conversation
…code in trusted context Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
joel-rieke
marked this pull request as ready for review
January 28, 2026 18:36
meghan-bailey
approved these changes
Jan 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Potential fix for https://github.com/trimble-oss/go-mysql-server/security/code-scanning/265
General fix approach: avoid running potentially untrusted PR code while the job has
contents: writeand an elevated token. In this workflow, the risky part is theformatjob: it checks out the PR head with a token that can push, runs a repository script, and commits changes. To align better with best practices while preserving functionality, we should (a) avoid using a custom secret token and rely on the defaultGITHUB_TOKENthat is already scoped by GitHub, and (b) ensure we are not explicitly checking out the “untrusted” PR head with special privileges. Since this workflow already separates forked PRs viaalt-verify, the simplest safe improvement within the shown snippet is to remove the use ofsecrets.REPO_ACCESS_TOKENand the redundant explicitreffor the checkout in the privileged job.Best concrete change with minimal functional impact:
formatjob:if: github.event.pull_request.head.repo.full_name == github.repository.actions/checkout@v3step so it:GITHUB_TOKENimplicitly (by removing thetoken:override).ref(which is the PR’s merge commit / event SHA), by removing the explicitref: ${{ github.head_ref }}. This avoids explicitly pinning the checkout to the PR head ref while still working correctly for formatting and committing against the PR’s branch, sinceEndBug/add-and-commitwill commit to the checked-out branch.verifyandalt-verifyjobs regarding security; they already only read and verify formatting.Concretely, in
.github/workflows/format.yml, edit the checkout step in theformatjob to:with:block (lines 27–29).uses: actions/checkout@v3line alone so that defaults apply.No new imports or external methods are needed; this is purely a workflow configuration change.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.