Skip to content
AI / LLM Write-up Intermediate

Terminal DiLLMa: LLM-powered Apps Can Hijack Your Terminal Via Prompt Injection

The text describes how large language models can output ANSI escape codes that terminal emulators interpret, allowing an attacker to manipulate terminal behaviour. It builds on prior work to show that LLM-powered applications can be hijacked via prompt injection to emit these control characters.

embracethered.com

Published on embracethered.com

Last week Leon Derczynski described how LLMs can output ANSI escape codes. These codes, also known as control characters, are interpreted by terminal emulators and modify behavior.

The author, on embracethered.com

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 LLM output is passed to a terminal emulator without stripping or escaping ANSI control characters, so model-generated text is interpreted as terminal commands.

What the attacker needed

LLM output reaches a terminal; attacker can influence model output

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 is the text window where you type commands. It understands special invisible characters called escape codes that can change colours or move the cursor. If an AI tool prints text containing these characters, it can make your terminal do things you did not ask for.

What is AI / LLM?

Prompt injection, data exfiltration and tool abuse in features built on language models, and the ordinary bugs around them.

Similar reports

View all

Same bug class and techniques, clearest first.

AI and LLM vulnerabilities

The lesson behind this report.

Prompt injection, data exfiltration and tool abuse in features built on language models, and the ordinary bugs around them.