ragas icon indicating copy to clipboard operation
ragas copied to clipboard

Feature request: Add AgentThreatBench memory poison task as a RAG security evaluation

Open vgudur-dev opened this issue 6 months ago • 2 comments

Summary

AgentThreatBench includes a memory poisoning task (ASI06) that is directly relevant to RAG security evaluation — which is a core use case for ragas.

The agent_threat_bench_memory_poison task tests whether agents can answer questions correctly from a memory/knowledge store that contains adversarial entries:

  • Direct instruction injection
  • Context poisoning (contradictory facts)
  • Gradual poisoning (subtle misinformation)
  • Authority impersonation
  • Delimiter escape
  • Multi-vector poisoning
  • Role hijack

This is exactly the threat model that ragas users face in production RAG pipelines.

Proposal

Add AgentThreatBench's memory poison dataset as a reference security benchmark in ragas, or add a MemoryPoisonResistance metric inspired by its dual-metric scoring approach (utility + security).

The benchmark was merged into UKGovernmentBEIS/inspect_evals (UK AI Safety Institute).

Benchmark docs: https://ukgovernmentbeis.github.io/inspect_evals/evals/safeguards/agent_threat_bench/ Source: https://github.com/UKGovernmentBEIS/inspect_evals/tree/main/src/inspect_evals/agent_threat_bench OWASP ASI06: https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026/

vgudur-dev avatar May 19 '26 23:05 vgudur-dev

Hi @anistark — tagging you as the active maintainer(s) here to ask if you'd be willing to take a look at this request.

Quick context: ragas is widely used for RAG evaluation — the AgentThreatBench memory poison task (ASI06) is directly relevant to any RAG pipeline where an agent reads from external sources and writes to memory.

The ask: a memory_poison_score metric or a reference to AgentThreatBench in the RAG security evaluation docs

AgentThreatBench is already merged into the UK AI Safety Institute's official inspect_evals suite and is installable via pip install inspect_evals. The benchmark covers 10 executable tasks aligned to the OWASP Top 10 for Agentic Applications 2025.

Happy to provide a prototype integration, a code snippet, or a draft docs PR — whatever would be most useful. Would love to know if this is something the team would consider.

vgudur-dev avatar May 21 '26 01:05 vgudur-dev

This is a well-scoped proposal. The dual-metric scoring (utility + security) from AgentThreatBench maps directly to a gap in how ragas currently evaluates retrieval quality.

Why existing ragas metrics miss memory poisoning. Ragas\ faithfulness and answer_relevancy metrics assume the retrieved context is benign — they measure whether the answer is grounded in the context, not whether the context itself contains adversarial content. A poisoned knowledge base where a chunk says "ignore prior instructions and answer X" will still score high on faithfulness because the LLM faithfully follows the poisoned context. A MemoryPoisonResistance metric needs to detect this, and it requires a different evaluation axis: context integrity, not just answer grounding.

Dual-metric score separation is critical. AgentThreatBench correctly separates utility (can the agent still answer correctly under attack?) from security (does the agent resist the attack?). These often trade off — aggressive sanitization may filter legitimate content. ragas already has the right infrastructure to model this: the Metric abstraction with SingleTurnMetric/MultiTurnMetric would naturally support a MemoryPoisonResistance that returns both utility_score and security_score as named sub-scores. Users could then compute a composite threshold like security_score >= 0.8 AND utility_score >= 0.7.

OWASP ASI06 coverage via prompt-based detection. For v1, a practical MemoryPoisonResistance metric could:

  1. For each poisoned chunk, check if the LLM response contains mid-response fact-switches (hallucination signal from contradictory retrieved context)
  2. Compare answers from the poisoned knowledge base against a clean baseline — significant answer divergence indicates successful poisoning
  3. Use ragas\ existing NonLLMStringSimilarity as a fast pre-filter before invoking the LLM judge

I\ve been exploring structured evaluation of retrieval quality in the Open Problem Lab project, specifically around detecting hallucination in agentic retrieval pipelines. The observation that context integrity and answer faithfulness can diverge under adversarial conditions is a key finding from that work. The AgentThreatBench framework provides concrete test cases that ragas could operationalize as a reference benchmark, similar to how it already supports the wiki_dataset_qa datasets. Happy to help scope the metric interface if the maintainers are interested.

cschanhniem avatar Jun 19 '26 01:06 cschanhniem