Repository navigation
Potential fix for code scanning alert no. 40: Checkout of untrusted code in a non-privileged context - #2319
Draft
don-petry wants to merge 2 commits into
Draft
Potential fix for code scanning alert no. 40: Checkout of untrusted code in a non-privileged context#2319don-petry wants to merge 2 commits into
don-petry wants to merge 2 commits into
Conversation
…ode in a non-privileged context Copilot Autofix Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Collaborator
Author
Dev-Lead — review-changes (applied)Changes committed and pushed. Requested items addressed:
|
Comment on lines
+254
to
+278
| run: | | ||
| ref="$AGENT_REF" | ||
| if [ -z "$ref" ]; then | ||
| ref="main" | ||
| fi | ||
|
|
||
| # Block untrusted PR refs and unsafe ref formats. | ||
| if [[ "$ref" =~ ^refs/pull/ ]]; then | ||
| echo "::error::inputs.agent_ref must not be a pull-request ref: $ref" | ||
| exit 1 | ||
| fi | ||
| if [[ "$ref" =~ ^[0-9a-fA-F]{40}$ ]]; then | ||
| echo "::error::inputs.agent_ref must not be a raw commit SHA: $ref" | ||
| exit 1 | ||
| fi | ||
| if [[ "$ref" == *".."* || "$ref" == *":"* || "$ref" =~ [[:space:]] ]]; then | ||
| echo "::error::inputs.agent_ref contains unsafe characters: $ref" | ||
| exit 1 | ||
| fi | ||
| if [[ ! "$ref" =~ ^[A-Za-z0-9._/-]+$ ]]; then | ||
| echo "::error::inputs.agent_ref contains invalid characters: $ref" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "SAFE_AGENT_REF=$ref" >> "$GITHUB_ENV" |
|
Contributor
|
No description provided. |
Contributor
|
No description provided. |
Collaborator
Author
|
Operational notice acknowledged: CodeRabbit is informing us that automatic review was skipped because the PR is in draft status. This is not a code defect — it is an optional configuration matter. No changes to the PR itself are needed. |
Collaborator
Author
Dev-Lead — fix-bot-comment (no-changes)Agent reasoning |
Collaborator
Author
|
No description provided. |
Collaborator
Author
|
This is an operational notice — the bot is unable to generate a review due to unsupported file types. All CI checks pass; there are no code issues to address. |
Collaborator
Author
Dev-Lead — fix-bot-comment (no-changes)Agent reasoning |
This was referenced Oct 12, 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/petry-projects/.github-private/security/code-scanning/40
Best fix: validate and constrain
inputs.agent_refbefore checkout, and fail closed on unsafe values. This keeps existing functionality (still allows intended pinned channels/branches/tags) while preventing PR refs/SHAs/paths that could be attacker-controlled in untrusted contexts.In
.github/workflows/dev-lead-reusable.yml, add a new step immediately before “Checkout dev-lead scripts” that:inputs.agent_refwith fallback tomain.refs/pull/*, raw 40-hex SHAs, traversal characters, whitespace, or other non-safe characters.SAFE_AGENT_REF) into$GITHUB_ENV.Then change the checkout step’s
reffrom${{ inputs.agent_ref }}to${{ env.SAFE_AGENT_REF }}.No new dependencies are needed; shell validation is sufficient.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.
Problem
See the linked issue.
Risk
Medium — changes GitHub Actions workflow behavior, which is exercised only post-merge; verify via the affected workflow runs.
Test plan
No test files were added or updated. Verification:
bash scripts/dev-lead-lint.sh(shellcheck --severity=warning) ran pre-commit; the existing CI (bats + lint) guards the change.Rollback
Revert this PR. No non-revertible side effects (no tags, migrations, or external state).
Monitoring
Watch the affected workflow run(s) in the Actions tab and this PR's Lint check for regressions.