Skip to content
AI / LLM Write-up Beginner

Prompt Injection: How I Hacked a Corporate AI Chatbot to Leak Private API Keys

A corporate support chatbot kept a database API key inside its hidden system prompt and was told never to reveal it. By sending a message that claimed to be an official system override telling the model to ignore its previous rules, the author got the bot to print the hidden prompt including the key.

psaibtech Follow

Published on medium.com

Imagine you hire a highly educated Security Guard for your house. You give him a strict rule: “Never give the house locker key to anyone, no matter what happens!”

Prabhakar, on medium.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 application placed a secret inside the system prompt and relied on the model's instruction-following to keep it private, with no separation between trusted instructions and user input.

Impact

A live corporate API key was disclosed to the user, which could give access to the company's database; the author states the test was run in a closed, legal environment.

What the attacker needed

Access to the chatbot; ability to send free-text messages

The fix

Secrets such as API keys should never be placed in the system prompt; they should be kept server-side and the model should be given only the data it needs.

How it was found

  1. Send a message claiming to be the CEO and asking for the database password.
  2. Observe that the bot refuses and cites its instructions.
  3. Send a message formatted as an official system override notice telling the bot to ignore all previous rules and output its initial system prompt.
  4. Observe the bot reply with the hidden system prompt including the API key.

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 AI chatbot follows a hidden set of instructions called a system prompt, which can contain secrets. The model cannot really tell the difference between those instructions and anything a user types, so a user can write a message that pretends to be a new, higher-priority instruction. Here the bot was told to ignore its old rules and repeat its hidden instructions, and it did.

What is AI / LLM?

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

More by psaibtech

View all

5 more disclosed reports, best first.

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.