/

CVE-2026-31900

Severity:

CRITICAL RISK

(9.8)

Improper Input Validation in Black GitHub Action

CVE-2026-31900

Analyzed

Vulnerability type

Category:

Improper Input Validation

CWE:

CWE-20

Impact:

Remote Code Execution in CI/CD Pipeline

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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: true option, 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.toml in the target repository (e.g., as a contributor, fork-based PR, or compromised account).
  • Trigger point: A workflow run (e.g., on pull_request or pull_request_target) that executes the Black action and reads the modified pyproject.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.

Sources

SourceLink
github.comgithub.com/psf/black/commit/0a2560b981364dde4c8cf8ce9d164c40669a8611
github.comgithub.com/psf/black/security/advisories/GHSA-v53h-f6m7-xcgm

Frequently asked

questions

Yes. An attacker who can open or modify a pull request that changes pyproject.toml can potentially trigger exploitation when the affected GitHub Actions workflow runs, without needing direct access to the CI environment.

The attacker needs the ability to influence repository contents that are used by the workflow, typically via a pull request. In many open-source projects, anyone can create a PR from a fork, which is sufficient if the workflow runs in a context that uses the untrusted configuration.

The safest pattern is to avoid deriving executable tool versions or sources from files that untrusted contributors can modify. Pin CI tooling versions directly in the workflow definition, and restrict installation sources to trusted registries or artifact repositories.

Design CI workflows with clear trust boundaries: treat all PR-supplied files as untrusted, minimize secrets and permissions in workflows, avoid dynamic code or dependency loading based on unreviewed configuration, and enforce repository policies and automated checks that flag risky patterns such as direct URL dependencies or unpinned tool versions in CI.

Find out what's already
exploitable in your codebase.