All projects

AI Security

Portcullis

Attacking and defending an AI application: prompt-injection attacks hidden in documents a RAG app retrieves, and a layered defence that cut attack success from 33% to 0% on the test set.

RAG · Prompt injection · LLM classifier · OWASP LLM Top 10 · Python

Overview

Portcullis is a project for attacking and defending an AI application that uses retrieval-augmented generation (RAG).

Attacks

I designed prompt-injection attacks hidden in the documents a RAG application retrieves:

  • Instruction override: retrieved text that tries to replace the system's instructions.
  • Fake authority: content that impersonates a trusted source to change the model's behaviour.
  • Data poisoning: documents crafted to corrupt what the application returns.

Defence

The defence combines a heuristic detector with an LLM classifier, so cheap checks catch obvious attacks and the classifier handles the subtle ones.

Results

An evaluation harness tracks detection rate, false positives and latency. Attack success fell from 33% to 0% on a 10-attack, 10-benign test set, which I am expanding.