⚠️

Disclaimer & Liability

The content provided on this website is for educational, research, and security awareness purposes only. Any unauthorized, illegal, or abusive use of the information, tools, and techniques discussed is solely the responsibility of the user. The author and publisher assume no liability for any damages, injuries, or consequences resulting from the misuse of this content.

iTerm2 Crafted-File Flaw Enables Command Execution Through Terminal Output | Alireza Bolbolabadi - Red Team Security
LOADING

iTerm2 Crafted-File Flaw Enables Command Execution Through Terminal Output

Executive summary

A recently fixed vulnerability in the macOS terminal emulator iTerm2 could allow a crafted file to execute commands merely because its contents are printed in a vulnerable terminal session. The user does not need to run the file as a script, paste an attacker-provided command, or deliberately activate the image protocol.

The problem lies in iTerm2's handling of invalid Kitty graphics protocol requests. Error responses could preserve untrusted text and line breaks, then send them through the pseudoterminal—the same channel used for keyboard input to the shell. A line break in the response could therefore be interpreted like a Return keystroke, allowing attacker-controlled text to run as a command.

The reported affected versions are iTerm2 3.6.1 through 3.7.8, including installations using default settings. The developer fixed the issue in iTerm2 3.7.9, a security update built on November 20, 2026. The source confirms the command-execution risk but does not report attacks using the flaw in the wild.

How the flaw works

Terminals process more than ordinary text. They also interpret escape sequences, which can alter the display, request graphics, or cause other terminal behavior. iTerm2 supports the Kitty graphics protocol, allowing programs to display images within a terminal window.

When an image request failed, the vulnerable implementation could include untrusted information from the request in an error message. It did not consistently remove line breaks and other control characters before returning that message through the pseudoterminal. Because the pseudoterminal communicates with the shell, those characters could cross a boundary intended for terminal output and become shell input.

This is a logic flaw rather than a memory-corruption vulnerability. Its significance comes from the deceptive delivery method: a file that appears to be a harmless README or log could contain sequences that trigger the vulnerable path when printed.

Security-control gaps

The supplied report identifies several weaknesses in the vulnerable path:

  • filenameIsSafe() was bypassed because file validation failed for non-existent files.

  • terminalIsTrusted was missing; there was no terminal trust check in executeAPC:.

  • The “Disable insecure escape sequences” option did not cover APC sequences.

  • Default verbosity created an unsafe condition because .normal mode always sent error responses.

Together, these gaps show that the issue was not dependent on an unusual configuration. The reported vulnerable range includes default installations.

Technical remediation

The primary fix in iTerm2 3.7.9 replaces line breaks and other control characters with spaces in Kitty graphics replies before they are sent. This keeps error messages readable while removing characters the shell could interpret as input. A follow-up change applies the same filtering to Kitty drag-and-drop replies and terminal title reports.

The developers also added tests designed to confirm that unsafe characters are removed without breaking valid replies. The fix therefore addresses the output-to-input conversion at its source rather than relying only on warnings or user behavior.

Real-world risk

Successful exploitation would provide arbitrary command execution with the privileges of the user operating iTerm2. Depending on what that account can access, consequences could include unauthorized file access or modification, exposure of credentials or tokens available to the session, lateral movement, and follow-on activity.

There is no indication in the supplied intelligence of a separate privilege-escalation path, system-level root execution, a CVE identifier, a CVSS score, or confirmed exploitation. Severity should therefore be assessed as code execution in the user's security context, rather than as automatic full-device compromise.

The trigger remains notable because it requires less interaction than many established social-engineering campaigns. The file does not need to be executed as a script, and the victim is not required to paste a command. Printing the contents is enough to reach the vulnerable behavior in affected versions.

Distinction from related attacks

This issue is separate from the earlier iTerm2 SSH integration flaw. It also differs from macOS ClickFix campaigns, which depend on convincing a user to paste and execute a malicious command. Here, the visible action resembles routine file inspection.

The distinction does not make the flaw harmless. It changes the attack surface: defenders focused only on suspicious copy-and-paste behavior could miss an exploit delivered through terminal output.

Detection and exposure management

Security teams can begin by inventorying iTerm2 versions across managed Macs and identifying installations in the reported 3.6.1–3.7.8 range. Actual endpoint versions are more reliable than assumptions that a centrally deployed update reached every device.

Potentially relevant telemetry includes unusual commands or child processes appearing after a suspicious file is displayed, particularly in sessions involving Kitty graphics or APC-related error handling. The supplied intelligence contains no concrete malicious command lines, persistence artifacts, or confirmed attack telemetry, so detection logic should not depend on a narrow list of known indicators.

Disclosure

iTerm2 credits Minseong Kim of NSHC Red Alert Labs with reporting the issue. The vendor's release notes confirm the fix and the command-execution risk. According to the supplied report, exploitation in the wild has not been observed.

advisory high
·
← Back to Writeups