CVE-2026-50642

Terminal Escape Injection in diff‑so‑fancy

Published Jul 29, 2026 CVSS 4.0 · 4.8 Medium EPSS < 1% KEV · Not listed
Description
diff‑so‑fancy does not properly sanitize non‑SGR terminal control sequences before outputting diff data. The application only strips ANSI SGR sequences while allowing other control characters, including carriage return (\r) and escape sequences (e.g., OSC, CSI), to pass through unsanitized.

An attacker can embed malicious control sequences in filenames, diff metadata, or file content that are rendered directly in the terminal during diff viewing. This can lead to output manipulation, including filename spoofing, terminal screen clearing, and clipboard injection via supported escape sequences.

Successful exploitation may mislead users during code review, alter terminal state, or result in unintended command execution through clipboard hijacking.

This issue has been fixed in the commit 9c81294

Analysis

AI-generated

Technical impact

diff-so-fancy fails to sanitize non-ANSI SGR control sequences, allowing malicious carriage return and escape characters to survive in filenames, metadata or file contents; when displayed, these sequences are interpreted by the terminal, enabling output manipulation such as filename spoofing, screen clearing, and clipboard injection, which can mislead users during code review or lead to unintended command execution via clipboard hijacking.

Affected Systems

The flaw affects all versions of so-fancy:diff-so-fancy that have not incorporated the fix present in commit 9c81294; no specific version range is disclosed, so any unpatched installation may be vulnerable.

Risk and Exploitability

The CVSS score of 4.8 indicates moderate severity, while the EPSS score of less than 1 % implies a very low likelihood of exploitation; the vulnerability is not listed in the CISA KEV catalog. Likely attack requires local use of the diff-so-fancy CLI where the diff is rendered in a terminal that processes escape sequences; although remote code execution is not directly supported, an attacker can manipulate terminal state or hijack clipboard content.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade diff-so-fancy to a version that includes commit 9c81294 or later, ensuring that unsanitized control sequences are removed prior to terminal output.
  • If an immediate upgrade is not possible, run diff-so-fancy through a wrapper script that strips carriage return, OSC, and CSI escape characters from the output before it reaches the terminal.
  • Validate file names and content for unexpected control characters before generating a diff, and refrain from diffing untrusted inputs in a terminal environment lacking sequence filtering.

Generated by OpenCVE AI on August 3, 2026 at 13:29 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories available
History
Type Values Removed Values Added
Weaknesses CWE-94
References
Metrics threat_severity

None

cvssV3_1

{'score': 4.4, 'vector': 'CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:L'}

threat_severity

Moderate

Type Values Removed Values Added
First Time appeared So-fancy
So-fancy diff-so-fancy
Vendors & Products So-fancy
So-fancy diff-so-fancy
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'none', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
Description diff‑so‑fancy does not properly sanitize non‑SGR terminal control sequences before outputting diff data. The application only strips ANSI SGR sequences while allowing other control characters, including carriage return (\r) and escape sequences (e.g., OSC, CSI), to pass through unsanitized. An attacker can embed malicious control sequences in filenames, diff metadata, or file content that are rendered directly in the terminal during diff viewing. This can lead to output manipulation, including filename spoofing, terminal screen clearing, and clipboard injection via supported escape sequences. Successful exploitation may mislead users during code review, alter terminal state, or result in unintended command execution through clipboard hijacking. This issue has been fixed in the commit 9c81294
Title Terminal Escape Injection in diff‑so‑fancy
Weaknesses CWE-116
References
Metrics cvssV4_0

{'score': 4.8, 'vector': 'CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:L/SC:N/SI:L/SA:N'}

Weaknesses
  • CWE-116

    Improper Encoding or Escaping of Output

  • CWE-94

    Improper Control of Generation of Code ('Code Injection')

Sources

Status
PUBLISHED
Assigner
CERT-PL
Published
Updated
Jul 29, 2026, 12:13 PM
Reserved
Jun 5, 2026, 1:27 PM
Status
Deferred
Published
Jul 29, 2026, 11:16 AM
Modified
Oct 23, 2026, 11:10 PM
Severity
Moderate
Public date
Jul 29, 2026, 9:46 AM