Prompt injection vs memory poisoning: a practical guide for builders

Prompt injection resets when a chat ends. Memory poisoning doesn't. If your agent has memory, it needs a different threat model.

Pranjul Rathour
Pranjul Rathour

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.

AI SecurityAgentsGuide
Pranjul Rathour
Pranjul Rathour
GenAI Engineer · Kanpur, Uttar Pradesh, India

GenAI engineer and AI product builder with 2+ years shipping production-grade AI systems: RAG pipelines, fine-tuned LLMs, hybrid retrieval and multi-modal apps across vision, speech and OCR, architected end to end from ingestion to deployment. Leads engineering for SCULT INDIA's 14-member team, founded the 500+ member TechVerse Enclave community and has mentored 200+ students. Three hackathon first prizes: Changethon 2025 (IIT Roorkee), Product Genesis at Vividhotsava 2025 (CSJMU Kanpur) and BYTEBATTLE (MeetKats).

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges. Email pranjulrathour41@gmail.com.

Keep reading

More on Shipping AI

All Shipping AI posts →
Campus talks · hackathon judging · mentoring

Want this as a live session at your college?

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges.

Pranjul Rathour, GenAI engineer in Kanpur