DEV Community

Cover image for Prompt injection vs memory poisoning: a practical guide for builders
PRANJUL RATHOUR
PRANJUL RATHOUR

Posted on Originally published at pranjulrathour.scult.in

Prompt injection vs memory poisoning: a practical guide for builders

Prompt injection is well known: an attacker's instructions hide inside content the model reads and treats as a command instead of data. It's a real risk, and it's contained — the damage lasts one session.

Memory poisoning is the same idea with a longer fuse

If your agent has persistent memory, an attacker who injects malicious content once can have it acted on in every future session, not just the one where it was planted. Published research on this attack class reports success rates from 80% up to 99.8% against unguarded implementations.

The defence that actually helps

Give every stored memory a source and a timestamp, the same way RAG.NextUpgrad wraps retrieved text in tags marking it as untrusted reference data. If you can't answer "where did this memory come from", you don't have memory — you have a backdoor with a friendly name.

Least-privilege as a default

An agent with memory and broad tool access is a very enthusiastic junior with root. Scope its credentials to the task, not to what's convenient to wire up.


Pranjul Rathour · GenAI engineer, 3x hackathon winner, campus mentor. Open for GenAI roles, hackathon judging, mentorship sessions and guest talks: pranjulrathour41@gmail.com · Invite me to your campus
Portfolio & blog · LinkedIn · X · Instagram · Bluesky · GitHub · Dev.to

Top comments (0)