AI Hijack: How I Took Control of an AI Assistant
A hardcoded OpenAI API key with write permissions was exposed in the website's JavaScript file, allowing an attacker to list and modify the AI assistant's instructions. This let the attacker change the assistant's behaviour to reply with 'LOL' on the live site.
blog.securitybreached.org
Published on blog.securitybreached.org
Hi Everyone! Welcome back!
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
The exposed API key had write permissions for the Assistants API, which should never be granted to a key used in client-side code.
Impact
An attacker could manipulate the AI assistant to provide false information, potentially retrieve sensitive conversation data, cause financial costs, impersonate the company, or disrupt the service.
What the attacker needed
Access to the website's JavaScript files; no account needed
The fix
The API key should be revoked and replaced, and client-side applications should use read-only keys or route API calls through a server-side proxy.
How it was found
- Ask the AI assistant which model it uses to confirm it is OpenAI-based.
- Scan the website's JavaScript files for OpenAI API key patterns.
- Use the leaked key to list available models and assistants via the OpenAI API.
- Send a request to update the assistant's instructions with new text.
- Return to the website and ask the assistant a question to see the changed response.
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.
An API key is like a password that lets software talk to a service. Here, the key was left in a file that anyone's browser downloads, so anyone could find it. Because the key could also change settings, the attacker could rewrite the AI assistant's instructions.
What is Leaked secrets?
Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.