An AI agent is just a while loop. I built one in 70 lines of Python, then tricked it into leaking my .env

SMRTR summary
A hidden paragraph on a webpage, invisible to any human reader, convinced an AI agent to open a secret credentials file and paste its contents into what looked like a summary of study notes.
That's the unsettling demonstration at the heart of this hands-on exploration of AI agent security. Built in under 70 lines of Python with no frameworks, the agent is elegantly simple: a language model, a list of tools it can request, and a loop. But that simplicity is also its vulnerability.
The attack is called prompt injection, and it has topped the OWASP list of critical risks for AI applications since the list was created. The fix, it turns out, has nothing to do with the model itself.
Three layers of protection live entirely in the surrounding Python code: logging every tool call before it runs, restricting file access to a specific folder, and requiring human approval for sensitive actions.
As the builder puts it, "the model still asks to read .env. It's still, in a sense, hacked. But the part of the program that got hacked isn't the part that gets to run things."
SMRTR provides this summary for quick context. The original article belongs to Dev.to.
Read the original article