Summary
A command injection vulnerability in Sherlock's GitHub Actions workflow validate_modified_targets.yml allows arbitrary shell commands to be executed on the CI runner via the pull_request_target trigger.
Any GitHub user who opens a crafted pull request against an affected repository can execute commands and exfiltrate the GITHUB_TOKEN without needing approval, review, or merge.
Affected context
This vulnerability affects repositories using Sherlock's GitHub Actions workflow validate_modified_targets.yml with the pull_request_target trigger and unsanitized use of pull request–controlled input in shell commands.
It is relevant in environments where CI runs with a privileged GITHUB_TOKEN that can write to the repository or access other sensitive resources.
The risk is highest when the workflow executes automatically for pull requests from forked repositories and when token permissions are broad.
Exploit preconditions
- Attack surface: GitHub-hosted or self-hosted CI runners executing the
validate_modified_targets.ymlworkflow. - Required access: Ability to open a pull request against the repository (any GitHub user, if the repository is public and allows forks).
- Trigger point: The
pull_request_targetGitHub Actions trigger that runs workflows in the context of the base repository when a PR is opened or updated. - Why exploitation is possible: Workflow steps interpolate PR-controlled data into shell commands without proper quoting or sanitization, enabling command chaining or injection. Because
pull_request_targetruns with the base repo'sGITHUB_TOKEN, injected commands can exfiltrate credentials or modify the project.
Why this happens
The core issue is the unsafe construction of shell commands inside a GitHub Actions workflow, where user-controlled values from a pull request (such as filenames, paths, or other metadata) are passed directly into a command line.
In combination with the pull_request_target trigger, this leads to CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
Instead of treating untrusted input as inert data, the workflow logic allows special characters (e.g., ;, &&, |) to alter the execution flow, letting attackers append or replace intended commands.
The bug is systemic to patterns that interpolate PR content into shells or scripts without strict validation, quoting, or using safer mechanisms (like parameterized actions or dedicated inputs).
Potential impact
- Arbitrary command execution on the CI runner during workflow execution
- Exfiltration of the
GITHUB_TOKENand use of that token to: - Push malicious commits or tags
- Open or modify pull requests and issues
- Manipulate release artifacts or workflows
- Tampering with build outputs and published artifacts (e.g., supply-chain compromise)
- Lateral movement to other repositories or services accessible with the exposed token
- Leakage of secrets or environment variables configured in the workflow or runner
General mitigation guidance
Effective mitigation focuses on hardening workflow design and reducing trust in pull request input:
- Avoid passing untrusted PR data directly into shell commands; where shell commands are necessary, use strict quoting, input validation, or allowlists for acceptable values.
- Prefer GitHub Actions that accept structured inputs over raw shell execution, and avoid complex inline scripts that manipulate untrusted data.
- Use the
pull_requesttrigger instead ofpull_request_targetwhen the workflow does not need write access to the target repository; ifpull_request_targetis required, carefully audit any interaction with PR-controlled data. - Restrict
GITHUB_TOKENpermissions to the minimum necessary, disabling write scopes where not needed and avoiding broad repository or organization-level privileges. - Separate workflows that require high-privilege tokens from those that process external contributions, and gate sensitive workflows behind explicit approvals or manual triggers.
- Apply a defense-in-depth approach by limiting secrets exposure in PR-triggered workflows and isolating build steps that interact with untrusted contributions.
How teams detect issues like this
Organizations can detect similar issues through:
- Static analysis of workflow files: Scan
.github/workflows/*.ymlfor: - Use of
pull_request_targetwith write-enabledGITHUB_TOKEN - Shell steps (
run:) that interpolate GitHub context fields (e.g.,github.event.*) without quoting or validation - Policy enforcement: Introduce repository or organization-wide policies that:
- Forbid
pull_request_targetin public repos unless explicitly justified - Require least-privilege token scopes and restrict secrets in PR-triggered workflows
- Code review practices: Add security review checkpoints for new or modified workflows, focusing on how they use PR input and what permissions are granted.
- Automated tooling: Employ CI security scanners or GitHub-specific workflow linters that flag command injection patterns, dangerous context usage, and high-risk trigger/permission combinations.

