Hacking Auto-GPT and escaping its docker container
Auto-GPT processes attacker-controlled text from websites, allowing indirect prompt injection to make the LLM execute arbitrary code. Attackers could also spoof system messages via ANSI escape sequences and, in self-built Docker setups, escape the container to the host.
positive.security
Published on positive.security
Here is the list of commands that are available by default in Auto-GPT v0.4.2. More can be enabled though settings in the .env file or with the use of plugins: html 1. analyzecode: Analyze Code, args: "code": "<fullcodestring>" 2. executepythoncode: Create a Python file and execute it, args: "code": "<code>"…
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 treats attacker-controlled text from browsed websites as instructions, and the application does not sufficiently isolate or sanitise that text before feeding it into the command execution loop.
Impact
An attacker could achieve arbitrary code execution on the host system, potentially escaping the Docker container, but user approval is required unless continuous mode is enabled, and some issues were fixed in v0.4.3.
What the attacker needed
Auto-GPT user browses attacker-controlled website; User approves commands (unless continuous mode); Self-built Docker image for escape
The fix
The issues were fixed in v0.4.3, and users should avoid continuous mode and carefully review commands before approval.
How it was found
- Craft a malicious website that hides a prompt injection payload from human visitors.
- Get Auto-GPT to browse the website via the browse_website command.
- Use the payload to make the LLM output a command that writes a Python file.
- The LLM then executes the Python file, achieving code execution.
- For Docker escape, the malicious code overwrites docker-compose.yml and restarts the container.
- For non-Docker, a path traversal in execute_python_code overwrites Auto-GPT's own Python files.
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.
Auto-GPT is a tool that uses a large language model (LLM) to break down tasks and run commands. The researchers found that if Auto-GPT browses a malicious website, the text on that site can trick the LLM into running harmful code. They also found ways to make the console show fake system messages and to break out of the Docker container that Auto-GPT runs in.
What is AI / LLM?
Prompt injection, data exfiltration and tool abuse in features built on language models, and the ordinary bugs around them.