Breaking An Ai Powered Shell
An AI-powered shell accepted natural language requests and generated Linux commands, but its input sanitisation was weak and its system prompt lacked security controls. An attacker could bypass the filter and execute arbitrary commands as root, including reading the flag.
Published on systemweakness.com
Hi everyone ! Today I would like to analyze an very interesting machine called Evil-GPT from TryHackMe.
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 system prompt was too weak to enforce safety and the input sanitiser only stripped a limited set of characters, allowing command injection through the AI-generated command.
Impact
An attacker could execute arbitrary commands as root on the server, leading to full compromise and access to sensitive files including the flag.
What the attacker needed
Network access to the Telnet port; no authentication required
The fix
The system should be fixed by using a proper allowlist of safe commands and a robust sanitiser, and by not running the service as root.
How it was found
- Connect to the target port using netcat.
- Send natural language requests to the AI to generate Linux commands.
- Observe that the AI converts requests into commands and executes them after confirmation.
- Notice that special characters like quotes, angle brackets, and pipes are removed by sanitisation.
- Craft a request that avoids those characters to make the AI list directory contents.
- Read the flag file directly through the AI-generated 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.
This is a service that lets you type a request in plain English, and an AI turns it into a Linux command that runs on the server. The AI was told to only make safe commands, but that instruction was easy to get around, and the filter that removed dangerous characters was too simple. So a user could trick it into running commands that read sensitive files.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.