Skip to content
AI / LLM Write-up Intermediate

*Chat History Poisoning in LLM Applications: Persistent Prompt Injection via Untrusted JSON Context*

An LLM chat application took the conversation history straight from the client's JSON request body instead of storing it server-side, so a user could rewrite past messages and fake assistant replies. By poisoning that history an attacker could steer the model past a system-prompt restriction and get a restricted command executed through the model's tool.

Serhat ÇİÇEK Follow

Published on infosecwriteups.com

As LLM-based applications continue to evolve, their implementation patterns within software systems are also constantly changing and being improved. In this article, we will explore a vulnerable LLM implementation and highlight a critical security risk.

Serhat ÇİÇEK, on infosecwriteups.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

The application trusted client-supplied chat history and appended it to the model context without server-side storage or validation of message roles.

Impact

An attacker could make the model treat fabricated turns as genuine and carry out a command the system prompt forbade; the author notes the same restriction could also be bypassed with ordinary prompt injection, so the history flaw mainly makes the manipulation persistent and harder to spot.

What the attacker needed

Access to the lab application; ability to intercept and edit requests; model has a tool that runs commands

The fix

Chat history should be stored and validated server-side, and request schemas should restrict the role field to allowed values such as user only.

How it was found

  1. Set up the deliberately vulnerable lab application and its environment file.
  2. Watch the terminal logs to see the chat history being sent with each request.
  3. Intercept the request with a proxy and inspect the JSON body.
  4. Replace the history array with fabricated user and assistant messages.
  5. Forward the modified request and observe the model acting on the fake history.
  6. Send a follow-up message asking the model to repeat the earlier action.

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 chat app usually remembers earlier messages so the model has context. Here the app asked the browser to send that memory back with every request, so anyone could edit it before it reached the model. The model then treated the fake memories as real and obeyed them, even though its instructions said not to run a certain command.

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 Serhat ÇİÇEK

View all

2 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.