iTerm2 Remote Code Execution Flaw Lets Hackers Run Malicious Commands by Displaying Crafted Files

Blog WriterCybersecurity News - Original News Source is cybersecuritynews.com


A security flaw in iTerm2, a macOS terminal emulator, lets attackers run commands when a user displays a specially crafted file in a vulnerable terminal session.

The user does not have to run the file as a script or paste a command supplied by the attacker. Printing the file’s contents is enough to trigger the bug. The developer fixed the issue in iTerm2 3.7.9, a security update built on November 20, 2026.

The reported affected range is 3.6.1 through 3.7.8, and the flaw can affect installations using default settings. iTerm2 credits Minseong Kim of NSHC Red Alert Labs with reporting the issue.

The vendor’s release notes confirm the fix and describe the command execution risk, but do not report attacks using the flaw in the wild.

The flaw sits in iTerm2’s implementation of the Kitty graphics protocol, which lets programs display images inside a terminal. A terminal does more than show text. It also reads escape sequences, which are instructions that can change what it displays or tell it to respond.

iTerm2 Remote Code Execution Flaw

According to reports in a GitHub advisory, iTerm2 processes embedded instructions instead of displaying them as plain text, allowing files to appear as harmless README or log files. The issue stems from failed image request error messages that preserve untrusted text and line breaks.

iTerm2 then sent that reply to the pseudoterminal, the channel that also carries keyboard input to the shell. The shell could treat those line breaks like presses of the Return key and run text from the reply as a command. This was a logic bug, not a memory corruption flaw.

The bug is separate from the earlier iTerm2 SSH integration flaw. However, both show how untrusted terminal output can turn into shell input.

It also differs from macOS ClickFix campaigns, which rely on persuading users to paste and run a command. Here, the risky action looks like reading a file.

The first fix replaces line breaks and other control characters with spaces in Kitty graphics replies before sending them. That keeps the error readable without passing characters the shell could act on.

Bypassed Security Controls :

Security control Status Reason
filenameIsSafe() Bypassed File validation failed for non-existent files.
terminalIsTrusted Missing No terminal trust check in executeAPC:.
Disable insecure escape sequences Not covered Does not protect APC sequences.
Default verbosity Unsafe default .normal mode always sends error responses.

A follow-up change uses the same filter for Kitty drag-and-drop replies and terminal title reports. The developers also added tests to check that unsafe characters are removed without breaking valid replies.

Mac users should check their installed iTerm2 version and update to 3.7.9 or later through the official iTerm2 downloads page. Until the update is in place, avoid printing raw contents from unfamiliar repositories, archives, or attachments into iTerm2.

Instead, use a graphical text editor to inspect suspicious files. For teams managing Macs, check actual installed versions rather than assuming that a centrally deployed update reached every device. The fix is in iTerm2 itself, so changing shells is not a substitute for installing it.

Give your SOC the alert context on the latest threats to stop incidents quickly -> Integrate Threat Intel from 16K SOCs

The post iTerm2 Remote Code Execution Flaw Lets Hackers Run Malicious Commands by Displaying Crafted Files appeared first on Cyber Security News.