/

CVE-2026-95168

Severity:

HIGH RISK

(7.8)

Code Injection (CWE-94) in thefuck CLI Rule Loading

CVE-2026-95168

Deferred

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Arbitrary Code Execution

Severity:

HIGH RISK

(7.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

A code injection vulnerability in thefuck v3.32 allows a local attacker to execute arbitrary code through rule import and loading functionality.

The issue becomes risky when an attacker can influence rule paths or the files resolved by get_rules_import_paths and Rule.from_path.

A code injection vulnerability in thefuck v3.32 allows a local attacker to execute arbitrary code through rule import and loading functionality.

The issue becomes risky when an attacker can influence rule paths or the files resolved by get_rules_import_paths and Rule.from_path.

Affected context

The vulnerability occurs in thefuck's rule-discovery and rule-loading paths, specifically around get_rules_import_paths in thefuck/corrector.py and Rule.from_path in thefuck/types.py.

It may affect environments where locally accessible rule files, import paths, or related configuration inputs can be modified or supplied by an untrusted user.

The vulnerability occurs in thefuck's rule-discovery and rule-loading paths, specifically around get_rules_import_paths in thefuck/corrector.py and Rule.from_path in thefuck/types.py.

It may affect environments where locally accessible rule files, import paths, or related configuration inputs can be modified or supplied by an untrusted user.

Exploit preconditions

  • Attack surface: Local rule discovery and loading functionality in the thefuck command-line application
  • Required access: Local access sufficient to influence rule files, import paths, or associated input
  • Trigger point: Processing of attacker-controlled rule paths by the corrector or rule-loading logic
  • Why exploitation is possible: Input associated with rule loading can reach code execution behavior rather than being treated strictly as inert data
  • Attack surface: Local rule discovery and loading functionality in the thefuck command-line application
  • Required access: Local access sufficient to influence rule files, import paths, or associated input
  • Trigger point: Processing of attacker-controlled rule paths by the corrector or rule-loading logic
  • Why exploitation is possible: Input associated with rule loading can reach code execution behavior rather than being treated strictly as inert data

Why this happens

The underlying issue is an unsafe code-loading pattern in which attacker-influenced rule locations are processed in a way that permits executable content to run.

This behavior maps to CWE-94: Improper Control of Generation of Code ('Code Injection'), because data supplied through rule discovery or loading is not sufficiently constrained before being interpreted as executable Python logic.

The underlying issue is an unsafe code-loading pattern in which attacker-influenced rule locations are processed in a way that permits executable content to run.

This behavior maps to CWE-94: Improper Control of Generation of Code ('Code Injection'), because data supplied through rule discovery or loading is not sufficiently constrained before being interpreted as executable Python logic.

Potential impact

  • An attacker could execute arbitrary code with the privileges of thefuck
  • Local files, credentials, or environment variables could be accessed
  • User-level application data could be modified or deleted
  • The compromised account could be used for further local privilege escalation or lateral movement
  • An attacker could execute arbitrary code with the privileges of thefuck
  • Local files, credentials, or environment variables could be accessed
  • User-level application data could be modified or deleted
  • The compromised account could be used for further local privilege escalation or lateral movement

General mitigation guidance

Mitigation generally focuses on ensuring that rule discovery and loading treat external inputs as data rather than executable logic.

Common defensive patterns include:

  • Restricting rule loading to trusted, fixed directories and approved modules
  • Avoiding dynamic evaluation or unrestricted execution of rule content
  • Applying allowlists and canonical-path checks before loading rules
  • Reducing the privileges and filesystem access available to the application
  • Separating user-writable locations from executable rule paths
  • Validating rule metadata and enforcing secure-by-default loading behavior

Mitigation generally focuses on ensuring that rule discovery and loading treat external inputs as data rather than executable logic.

Common defensive patterns include:

  • Restricting rule loading to trusted, fixed directories and approved modules
  • Avoiding dynamic evaluation or unrestricted execution of rule content
  • Applying allowlists and canonical-path checks before loading rules
  • Reducing the privileges and filesystem access available to the application
  • Separating user-writable locations from executable rule paths
  • Validating rule metadata and enforcing secure-by-default loading behavior

How teams detect issues like this

Organizations can look for this class of issue through:

  • Static analysis targeting dynamic imports, evaluation, execution, and unrestricted path-based loading
  • Code review checks for user-controlled values reaching module or rule loading functions
  • Monitoring unexpected rule files, import paths, or child processes launched by thefuck
  • Policy enforcement that prevents executable content from being loaded from user-writable directories
  • Automated security review tools that flag untrusted input flowing into code-generation or code-loading APIs

Organizations can look for this class of issue through:

  • Static analysis targeting dynamic imports, evaluation, execution, and unrestricted path-based loading
  • Code review checks for user-controlled values reaching module or rule loading functions
  • Monitoring unexpected rule files, import paths, or child processes launched by thefuck
  • Policy enforcement that prevents executable content from being loaded from user-writable directories
  • Automated security review tools that flag untrusted input flowing into code-generation or code-loading APIs

Sources

SourceLink
github.comgithub.com/REYu6/python-vuln/blob/main/reports-v2/thefuck/03-contrib-pregate-exec.md
github.comgithub.com/nvbn/thefuck/issues/1623

Frequently asked

questions

It is primarily a local vulnerability. Remote exploitation would generally require a separate condition that allows an attacker to influence the vulnerable user's rule files, paths, or execution environment.

The attacker needs local access or another trusted-path compromise that allows control over inputs used during rule discovery or loading.

Use a restricted, allowlisted rule-loading mechanism that does not execute attacker-controlled content and only permits trusted, validated modules.

Keep executable rule directories non-writable by untrusted users, apply least privilege, validate paths and module identities, and use static analysis to identify unsafe dynamic loading patterns.

It is primarily a local vulnerability. Remote exploitation would generally require a separate condition that allows an attacker to influence the vulnerable user's rule files, paths, or execution environment.

The attacker needs local access or another trusted-path compromise that allows control over inputs used during rule discovery or loading.

Use a restricted, allowlisted rule-loading mechanism that does not execute attacker-controlled content and only permits trusted, validated modules.

Keep executable rule directories non-writable by untrusted users, apply least privilege, validate paths and module identities, and use static analysis to identify unsafe dynamic loading patterns.

Find out what's already
exploitable in your codebase.