Cybersecurity Research

Apple Fixes macOS Terminal Behaviour That Let AI Tools Leak Data Through DNS

Embrace The Red · 16 July 2026
Key Takeaway Keep macOS up to date, and be cautious with AI command-line tools that process untrusted content, preferring tools that safely display control characters rather than passing raw output to your terminal.

Apple has fixed a macOS Terminal behaviour that allowed a data theft technique involving AI tools. Security researcher Johann Rehberger, writing for Embrace The Red, reports that special control characters (known as ANSI escape codes) could make the Terminal app issue DNS requests. David Leadbeater first discovered this behaviour, which could be used to carry data out of a system inside those requests.

The risk grew with AI. Researcher Leon Derczynski found that large language models can produce these control characters. Rehberger saw that this could let an attacker hijack AI agents and command-line tools that use LLMs, using indirect prompt injection to trigger the behaviour and send data out. He built an end-to-end demonstration in December 2024 and shared it with Apple, which mitigated the issue and credited him in its release notes.

The wider concern remains. Rehberger notes that LLM-connected command-line applications often pass control characters straight to the terminal. Depending on the terminal's features, this could cause other unwanted behaviour. His recommendation is that tools should safely encode control characters by default, in a similar way to the cat -v command, and only allow raw terminal output when a user explicitly chooses it.

Running AI agents? Eight controls for securing them, mapped to the ISM ->

Summarised by CISO AI from Embrace The Red, written with Claude Sonnet 5.5. We link back to every original so you can read it yourself.