Skip to content

ci: download the validation artifact with the first-party action - #564

Open
WAHIB-EL-KHADIRI wants to merge 1 commit into
geeksblabla:masterfrom
WAHIB-EL-KHADIRI:ci/harden-episode-validation-comment
Open

WAHIB-EL-KHADIRI wants to merge 1 commit into
geeksblabla:masterfrom
WAHIB-EL-KHADIRI:ci/harden-episode-validation-comment

Conversation

@WAHIB-EL-KHADIRI

Copy link
Copy Markdown

What's wrong

episode-validation-comment.yml runs on workflow_run. That is the privileged context: it runs from master, it holds pull-requests: write, and it runs after a workflow triggered by a pull request — including one from a fork.

It downloaded the artifact with dawidd6/action-download-artifact@v4. That version range is covered by GHSA-5xr6-xhww-33m4 — artifact poisoning, high severity, fixed in 6.

The producing job matters here. validate-episode.yml runs on pull_request and checks out the merge ref, so .github/scripts/validate-episode-markdown.sh and the setup-node-pnpm-install composite action both come from the PR head. A fork PR therefore decides what ends up in pr/NR and pr/validation-report.md. Downstream, number=$(cat pr/NR) was passed straight to sticky-pull-request-comment, so that value chooses which PR gets commented on.

The fix

  • actions/download-artifact@v4 fetches the same artifact by run-id, so the third-party action is removed rather than bumped. This needs actions: read to resolve the run.
  • pr/NR is reduced to digits before use, and an entry with no digits fails the job instead of selecting an unrelated PR.
  • ::set-output is deprecated; the step writes to $GITHUB_OUTPUT.

No behaviour change on a normal PR: the same artifact is downloaded, the same comment is posted on the same PR.

What I checked

  • actions/download-artifact@v4 supports cross-run downloads via run-id + github-token, which is why actions: read is added and the workflow: input is dropped.
  • The artifact name and path are unchanged, so sticky-pull-request-comment still finds pr/validation-report.md.
  • I read the other 13 workflows in this repo and in awesome-morocco while I was here. This is the only one that combines a privileged trigger with an artifact from an unprivileged job — the rest are push/schedule/pull_request only.

I could not execute the workflow end-to-end, since workflow_run only fires from the base repository. Worth a maintainer confirming the first run posts a comment as before.

AI disclosure: I used an AI coding agent while preparing this change. The advisory range, the trigger analysis, and the artifact data-flow above are things I verified myself against the repository and the GitHub Advisory Database.

The PR-comment job runs in the privileged workflow_run context with
pull-requests: write, and pulled the artifact with
dawidd6/action-download-artifact@v4. That range is covered by
GHSA-5xr6-xhww-33m4 (artifact poisoning, fixed in 6).

actions/download-artifact@v4 fetches the same artifact by run-id, so the
third-party dependency goes away instead of being bumped. It needs
actions: read to resolve the run.

The artifact is produced by a job that runs on pull_request, so its
contents are controlled by the PR author. pr/NR is now reduced to digits
before it reaches sticky-pull-request-comment, and an entry that carries
no digits fails the job rather than selecting an unrelated PR.

set-output is deprecated; the step writes to $GITHUB_OUTPUT.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@WAHIB-EL-KHADIRI

Copy link
Copy Markdown
Author

Not chasing a review — just noting that CI Checks is at action_required and has not run, so there is no result attached yet. Whenever someone has a moment to approve the workflow run, it should go green or tell us something useful.

@WAHIB-EL-KHADIRI

Copy link
Copy Markdown
Author

Following up on my own note above: the run did get approved in the end — Code standards & build passed on 12 September, so there is a green result attached now. Ready whenever someone has a moment.

This branch has not been deployed

No deployments
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.

1 participant