Abusing url handling in iTerm2 and Hyper for code execution
iTerm2 and Hyper terminal emulators mishandled custom URL schemes (x-man-page:// and ssh://), allowing argument injection when a user clicks a crafted hyperlink. An attacker could achieve code execution or arbitrary file write on the victim's machine.
Modern terminals are very capable tools with quite extended support for various escape sequences. These escape sequences are specially treated by terminal emulators to generate colors, cursor styles, cliboard access and even wink hyperlinks!
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 the terminal emulators passed user-controlled URL content directly to command-line programs without sanitising arguments, enabling argument injection.
Impact
An attacker could achieve code execution or arbitrary file write on the victim's machine, though the file write requires the victim to later source the modified profile.
What the attacker needed
Victim uses iTerm2 or Hyper; victim clicks a crafted hyperlink
The fix
The vulnerabilities were fixed in iTerm2 version 3.5.0 and Hyper via a pull request.
How it was found
- Craft a malicious URL using the x-man-page:// or ssh:// scheme with injected arguments.
- Generate a terminal hyperlink (OSC 8) that points to the malicious URL.
- Convince the victim to click the hyperlink in their terminal.
- The terminal opens the URL with the registered handler, executing the injected command.
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.
Terminal emulators can create clickable links using special escape sequences. If a terminal opens a link with a custom scheme like ssh:// without checking the arguments, an attacker can sneak in extra commands that run on your computer when you click the link.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.