Severity:

HIGH RISK

(7.2)

Command Injection in Pallets Click click.edit() Helper

CVE-2026-7246

Modified

Vulnerability type

Category:

Command Injection

CWE:

CWE-77, CWE-78

Impact:

Arbitrary Command Execution

Severity:

HIGH RISK

(7.2)

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

Pallets Click up to version 8.3.2 contains a command injection vulnerability in the click.edit() function, which can be abused to execute arbitrary operating system commands.

When untrusted input is incorporated into the editing command or its environment, an attacker using an unprivileged account may be able to trigger OS-level command execution under the context of the vulnerable process.

Affected context

This vulnerability arises in Python applications that use Pallets Click (versions 8.3.2 and below) and rely on click.edit() to open a text editor, particularly when editor configuration, filenames, or additional arguments are influenced by user-controlled data.

The risk is elevated when:

  • The application runs with higher privileges than the user providing input
  • Environment variables (such as EDITOR or similar) or command-line fragments are not sanitized
  • Shell interpretation is implicitly or explicitly involved in constructing the editor command

In such contexts, the helper's reliance on external editors and command construction can result in unintended OS command execution.

Exploit preconditions

  • Attack surface: Applications or CLIs built with Pallets Click that expose click.edit() functionality or depend on it indirectly.
  • Required access: Ability to supply or influence values used by click.edit(), such as:
  • Environment variables that define the editor command
  • Arguments, filenames, or paths passed into the editing workflow
  • Trigger point: Invocation of click.edit() by the application, typically when prompting a user to edit text, configuration, or commit messages.
  • Why exploitation is possible: The function ultimately constructs and executes an OS-level editor command in a way that allows user-controlled data to affect the command line. When this data is not strictly validated or is passed through a shell, it can break out of the intended context and inject arbitrary commands, matching the pattern of CWE-77: Command Injection.

Why this happens

The root cause is the unsafe construction and execution of OS commands from potentially untrusted input within the click.edit() helper.

Rather than treating editor configuration and filenames as opaque, non-executable values, the implementation combines them into a command string that the operating system interprets.

If this construction allows shell meta-characters or additional tokens to be interpreted, an attacker can extend the command beyond its intended scope.

Conceptually, this is a classic command injection flaw: user-controlled data is incorporated into command execution logic without strict, context-aware validation or safe invocation mechanisms that avoid the shell wherever possible.

Potential impact

  • Execution of arbitrary OS commands under the privileges of the vulnerable application
  • Reading or modification of application data accessible to the process
  • Unauthorized file creation, deletion, or modification on the host system
  • Lateral movement within the environment if additional tools or credentials are accessible
  • Potential escalation from an unprivileged user context to higher-privileged operations performed by the affected application

General mitigation guidance

Effective mitigation focuses on eliminating opportunities for untrusted data to influence command construction and ensuring that editor invocation is non-executable from an attacker's perspective.

Pattern-based mitigations include:

  • Avoid shell-based command construction: Invoke editors using APIs that pass arguments as structured lists rather than interpolated strings, avoiding shell parsing.
  • Constrain configuration sources: Treat environment variables such as EDITOR as untrusted; filter them against an allowlist of known-safe editors or map logical configuration options to fixed, internal commands.
  • Sanitize user-influenced values: Normalize and validate filenames, paths, and additional arguments so that they contain only expected characters (e.g., no shell metacharacters) and refer to allowed locations.
  • Run with least privilege: Ensure applications using click.edit() operate with minimum necessary OS permissions so that, if abused, the impact of command execution is limited.
  • Separate privileges and roles: Avoid running high-privilege administrative tools where unprivileged users can influence editor configuration or inputs to editing workflows.

How teams detect issues like this

Detection efforts should aim to identify unsafe command construction and editor invocation patterns in applications that depend on Pallets Click.

Common strategies include:

  • Static analysis rules: Scan for code paths that call click.edit() and inspect how editor configuration, filenames, and additional parameters are derived, flagging cases where they originate from untrusted input.
  • Code review signals:
  • Use of environment variables (EDITOR, VISUAL, or custom) without validation before passing them to click.edit()
  • String concatenation or formatting that builds command-like values
  • Reliance on shell=True or equivalent behavior when launching editors
  • Policy enforcement: Establish secure coding guidelines that prohibit shell-invoked editors or unvalidated editor configuration in CLI tools, and enforce them through automated checks in CI pipelines.
  • Runtime monitoring: Use OS-level or application-level logging and monitoring to detect anomalous editor invocations or unexpected subprocess executions triggered from editing flows.

Sources

SourceLink
github.comgithub.com/pallets/click/releases/tag/8.3.3
github.comgithub.com/tsigouris007/security-advisories/security/advisories/GHSA-47fr-3ffg-hgmw
access.redhat.comaccess.redhat.com/errata/RHSA-2026:24761
access.redhat.comaccess.redhat.com/errata/RHSA-2026:24762
access.redhat.comaccess.redhat.com/security/cve/CVE-2026-7246
bugzilla.redhat.combugzilla.redhat.com/show_bug.cgi?id=2464121
security.access.redhat.comsecurity.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-7246.json

Frequently asked

questions

It can be, depending on how the application exposes click.edit(). If a remote interface (such as an API, web UI, or remote CLI session) allows an attacker to control editor configuration or the data passed into the editing workflow, remote command execution is possible. In purely local CLI scenarios, exploitation is typically limited to local users of the system.

An attacker needs the ability to influence values that feed into click.edit(), such as environment variables (e.g., EDITOR) or user inputs that affect filenames and arguments. The vulnerability becomes more serious when the vulnerable process runs with higher privileges than the attacker's normal account.

The safest pattern is to ensure that editor invocation never passes untrusted data through a shell. Use structured process execution APIs, restrict editor choices to an allowlist of known-safe binaries, and avoid incorporating unvalidated user-controlled strings into editor commands or arguments.

Prevent them by treating all external command execution as highly sensitive: avoid shell-based commands where possible, strictly validate or constrain all data that influences subprocess execution, define security guidelines for environment-variable handling, and reinforce these practices with static analysis, code review checklists, and CI policies for projects that use command-line helpers like Click.

Find out what's already
exploitable in your codebase.