Abusing title reporting and tmux integration in iTerm2 for code execution
A regression in iTerm2 3.5.0 and 3.5.1 re-enabled window title reporting, so an escape sequence could place the window title into stdin. Combined with a weakness in native tmux integration, an attacker could get arbitrary code from the title to run when the user pressed Enter.
I am skipping an introduction to escape sequences here as I recently wrote more about them in my previous post. From a security perspective, they are to terminal emulators what XSS is to browsers.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a regression re-enabled window title reporting by default, and tmux integration allowed the reported title to contain newlines, so title text could reach stdin as commands.
Impact
An attacker could get arbitrary code executed on the user's machine, but only on iTerm2 3.5.0 and 3.5.1 and only if the user presses Enter.
What the attacker needed
ITerm2 3.5.0 or 3.5.1; victim opens the crafted file or output; victim presses Enter
The fix
It was fixed in iTerm2 3.5.2, and users are advised to think twice before enabling the window title reporting setting.
How it was found
- Run the provided container or open the proof-of-concept file in iTerm2 3.5.0 or 3.5.1.
- The escape sequence sets a window title containing a command.
- The title is retrieved back into stdin.
- The user presses Enter and the command in the title executes.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A terminal emulator is the app that shows a command line. It understands special invisible codes called escape sequences, which can set or read things like the window title. Here a setting that should have stayed off was turned back on, so text from the title could be fed into the command line and run as a command.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.