Summary
The Black GitHub Action allows repositories to specify the formatter version via pyproject.toml when use_pyproject: true is enabled.
A malicious pull request can modify pyproject.toml to point to a Black version loaded from an arbitrary URL, leading to execution of attacker-controlled code in the GitHub Actions environment and exposure of workflow secrets and permissions.
Affected context
This vulnerability affects workflows that:
- Use the official Black GitHub Action for Python code formatting, and
- Enable the
use_pyproject: trueoption, and - Run on pull request events or other events where untrusted contributors can influence repository contents.
In these setups, the action trusts the pyproject.toml configuration from the repository to determine which Black version to install, including support for direct URL references without adequate restrictions.
Exploit preconditions
- Attack surface: GitHub Actions workflows using the Black action with
use_pyproject: true. - Required access: Ability to create or modify pull requests that affect
pyproject.tomlin the target repository (e.g., as a contributor, fork-based PR, or compromised account). - Trigger point: A workflow run (e.g., on
pull_requestorpull_request_target) that executes the Black action and reads the modifiedpyproject.toml. - Why exploitation is possible: The action implicitly trusts version and source definitions from
pyproject.toml, allowing direct URL dependencies that can reference arbitrary, attacker-controlled code, which is then executed in the context of the CI runner.
Why this happens
The core issue is improper validation of configuration-sourced input in the CI context, mapped to CWE-20: Improper Input Validation.
The Black GitHub Action accepts the use_pyproject: true setting and then uses fields from pyproject.toml to determine which version of Black to install, including support for direct URL references.
Because this configuration file is under source control and can be modified by untrusted pull requests, treating it as a trusted source for executable packages breaks the trust boundary between contributor-controlled data and the CI/CD runtime, enabling execution of arbitrary code during dependency resolution/installation.
Potential impact
- Execution of arbitrary code within the GitHub Actions runner.
- Theft or misuse of GitHub Actions secrets (API keys, tokens, credentials) available to the workflow.
- Abuse of repository or organizational permissions granted to the workflow token (e.g., modifying code, creating releases, changing settings).
- Lateral movement to other systems or services integrated with the CI/CD pipeline.
- Insertion of backdoors or malicious changes into the codebase via automated tooling.
General mitigation guidance
Effective mitigation focuses on tightening trust boundaries around CI configuration inputs and dependency sources:
- Treat repository configuration files (such as
pyproject.toml) as untrusted when processing unreviewed changes, especially in workflows triggered by pull requests. - Prefer workflow configurations that pin tools to known, vetted versions directly in the workflow file rather than deriving executable versions from user-editable project files.
- Restrict or disable mechanisms that allow direct URL or arbitrary source references for tools executed in CI, favoring only trusted registries and signed artifacts.
- Configure GitHub Actions workflows to minimize available secrets and permissions (principle of least privilege), so that compromise of a single job yields minimal impact.
- Isolate formatting or linting actions that rely on repository configuration into workflows that run only after code review or on trusted branches.
How teams detect issues like this
Organizations can detect and monitor for similar issues using:
- Static analysis and policy checks on workflow definitions to flag actions that execute tools based on repository-controlled config (e.g.,
use_pyproject: true, dynamic version selection, or direct URL installs). - Code review checklists that explicitly consider CI workflows and their trust boundaries, ensuring that configuration files used inside CI are not blindly trusted when modified by untrusted PRs.
- Dependency and supply-chain security tooling that inspects
pyproject.toml(and similar files) for direct URL dependencies and unusual sources, especially when referenced in CI. - Continuous monitoring of workflow runs for anomalous behavior, such as unexpected outbound network connections, unusual commands, or unexpected changes originating from automated jobs.

