Skip to content

Harden pull_request_target workflows against untrusted PR input - #5644

Open
dhruvkb wants to merge 1 commit into
mainfrom
harden-pr-target-workflows
Open

dhruvkb wants to merge 1 commit into
mainfrom
harden-pr-target-workflows

Conversation

@dhruvkb

@dhruvkb dhruvkb commented Oct 15, 2026

Copy link
Copy Markdown
Member

Fixes

Related to #5621 and #5622

Description

This PR hardens the two workflows that run on pull_request_target (and so have access to secrets while being triggered by untrusted PRs).

#5621 and #5622 tried to exploit pr_limit_reminders.yml by replacing count_user_reviewable_prs.js with a script that exfiltrates secrets. The attempt failed because actions/checkout checks out the base branch under pull_request_target, so the PR's code never ran (the run logs show the legitimate script's Slack username not found warning). However, a single ref: line would make the workflow exploitable, so this PR adds defence in depth:

pr_limit_reminders.yml

  • Replaces the ACCESS_TOKEN PAT with the built-in GITHUB_TOKEN, scoped to contents: read and pull-requests: read. The script only reads open PRs and their labels in this public repo, so the PAT is unnecessary, and a future compromise would no longer leak it.
  • Sets persist-credentials: false so the token is not written to .git/config.
  • Sparse-checks out only automations/js/src, which is all the step needs.
  • Adds a warning comment against checking out the PR head.
  • Sets permissions: {} for the Slack job, which needs no token.

pr_ping.yml

  • Sets permissions: {}, as the job makes no GitHub API calls.
  • Escapes &, < and > in the PR title and author before interpolating them into Slack mrkdwn. Currently, a PR titled e.g. <!channel> pings the whole channel, and <https://example.com|text> renders a disguised link.

pr_automations.yml and pr_automations_init.yml were also reviewed and need no changes: the former already checks out main without credentials and validates the PR-built artifacts, and the latter runs on pull_request without secrets.

Testing Instructions

These workflows run from main on pull_request_target, so they can only be fully verified after merging. After merge:

  1. Open a PR (or mark one ready for review) and confirm the "New PR notification" Slack message is unchanged, including for a title containing <, > or &.
  2. Confirm the "Count user's open pull requests" job succeeds and logs the PR count for a maintainer with an entry in GH_SLACK_USERNAME_MAP. If the GraphQL query fails with a permissions error on GITHUB_TOKEN, that is the change to revisit.

Locally, just lint passes on the changed files (actionlint, prettier, codespell) and the escape helper was checked in Node against a malicious title.

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • I ran the DAG documentation generator (ov just catalog/generate-docs for catalog
    PRs) or the media properties generator (ov just catalog/generate-docs media-props
    for the catalog or ov just api/generate-docs for the API) where applicable.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

🤖 Generated with Claude Code

@dhruvkb
dhruvkb requested a review from a team as a code owner October 15, 2026 04:35
Copilot AI balanced review requested due to automatic review settings October 15, 2026 04:35
@dhruvkb dhruvkb added the 🟧 priority: high Stalls work on the project or its dependents label Oct 15, 2026
@dhruvkb
dhruvkb removed the request for review from a team October 15, 2026 04:35
@dhruvkb dhruvkb added 🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🧱 stack: mgmt Related to repo management and automations labels Oct 15, 2026
@dhruvkb
dhruvkb requested review from krysal and obenland and removed request for Copilot October 15, 2026 04:35
@dhruvkb dhruvkb added 🟧 priority: high Stalls work on the project or its dependents 🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🧱 stack: mgmt Related to repo management and automations labels Oct 15, 2026
@openverse-bot openverse-bot moved this to 👀 Needs Review in Openverse PRs Oct 15, 2026

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

🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟧 priority: high Stalls work on the project or its dependents 🧱 stack: mgmt Related to repo management and automations

Projects

Status: 👀 Needs Review

Development

Successfully merging this pull request may close these issues.

2 participants