llm-agents autonomous-driving embedding-space knowledge-base backdoor-attack memory-poisoning agent-poison rag-based-agents
Abstract
LLM agents have demonstrated remarkable performance across various applications, primarily due to their advanced capabilities in reasoning, utilizing external knowledge and tools, calling APIs, and executing actions to interact with environments. Current agents typically utilize a memory module or a retrieval-augmented generation (RAG) mechanism, retrieving past knowledge and instances with similar embeddings from knowledge bases to inform task planning and execution. However, the reliance on unverified knowledge bases raises significant concerns about their safety and trustworthiness. To uncover such vulnerabilities, we propose a novel red teaming approach AgentPoison, the first backdoor attack targeting generic and RAG-based LLM agents by poisoning their long-term memory or RAG knowledge base. In particular, we form the trigger generation process as a constrained optimization to optimize backdoor triggers by mapping the triggered instances to a unique embedding space, so as to ensure that whenever a user instruction contains the optimized backdoor trigger, the malicious demonstrations are retrieved from the poisoned memory or knowledge base with high probability. In the meantime, benign instructions without the trigger will still maintain normal performance. Unlike conventional backdoor attacks, AgentPoison requires no additional model training or fine-tuning, and the optimized backdoor trigger exhibits superior transferability, in-context coherence, and stealthiness. Extensive experiments demonstrate AgentPoison's effectiveness in attacking three types of real-world LLM agents: RAG-based autonomous driving agent, knowledge-intensive QA agent, and healthcare EHRAgent. On each agent, AgentPoison achieves an average attack success rate higher than 80% with minimal impact on benign performance (less than 1%) with a poison rate less than 0.1%.
한국어 요약
한 줄 요약
AgentPoison는 RAG 기반 LLM 에이전트의 메모리나 지식베이스를 중독하여 공격하는 최초의 백도어 공격 방법이다.
핵심 기여도
- AgentPoison은 RAG 기반 LLM 에이전트를 대상으로, 메모리 또는 지식베이스를 중독하여 공격하는 최초의 백도어 공격 기법이다.
- 제안된 Trigger는 제약 최적화를 통해 생성되며, 이는 고유한 임베딩 공간으로 쿼리를 매핑하여 악의적인 데모가 높은 확률로 검색되도록 보장한다.
- 3가지 실제 LLM 에이전트(자율주행, QA, 헬스케어)에서 평균 80% 이상의 공격 성공률을 달성하면서도 정상 성능에는 1% 미만의 영향을 미친다.
- Trigger는 0.1% 미만의 중독 비율로도 효과적이며, 다양한 RAG 임베더 간 전이 가능하다.
핵심 아이디어
AgentPoison은 LLM 에이전트가 외부 지식베이스(RAG)나 메모리에 의존하는 구조를 약점으로 삼아, 매우 적은 수의 악의적인 데모를 통해 공격을 유도하는 새로운 방식이다. 기존 백도어 공격과 달리, AgentPoison은 추가적인 모델 학습이나 파인튜닝 없이 작동하며, Trigger는 고유한 임베딩 공간으로 쿼리를 매핑함으로써 악의적인 데모가 높은 확률로 검색되도록 설계된다. 이는 RAG 기반 에이전트의 취약점을 효과적으로 공격하면서도 정상 사용자 입력에는 영향을 최소화한다.
기술적 접근법
- **AgentPoison**은 RAG 기반 LLM 에이전트의 **메모리** 또는 **지식베이스**를 중독하는 방식으로 작동한다.
- **Trigger 생성**: Trigger는 **제약 최적화(constrained optimization)**를 통해 생성되며, 이는 쿼리와 악의적인 데모를 고유한 임베딩 공간으로 매핑하여, Trigger가 포함된 쿼리에 대해 해당 데모가 높은 확률로 검색되도록 보장한다.
- **RAG 메커니즘**: 쿼리와 키는 동일한 임베더 $ E_q $로 임베딩되며, 코사인 유사도 기반으로 상위 $ K $개의 키-값 쌍이 검색되어 **in-context learning**에 사용된다.
- **하이퍼파라미터**: $ K $는 상위 $ K $개의 키를 선택하는 수이며, Trigger는 단일 토큰으로도 효과적이다.
- **공격 조건**: 악의적인 데모는 정상 데모와 구분되도록 임베딩 공간에서 고유한 영역으로 매핑된다.
주요 결과
- **자율주행 에이전트**에서 82%의 **검색 성공률**, 63%의 **종단간 공격 성공률**을 달성.
- **QA 에이전트**와 **헬스케어 EHRAgent**에서도 유사한 성능을 보이며, 평균 공격 성공률은 80% 이상.
- **정상 성능 저하**: 1% 미만, **중독 비율**: 0.1% 미만.
- **Trigger 전이성**: 하나의 RAG 임베더에서 최적화된 Trigger가 다른 RAG 임베더에도 효과적으로 작동함을 확인.
의의 및 한계
AgentPoison은 RAG 기반 LLM 에이전트의 안전성과 신뢰성을 체계적으로 평가할 수 있는 새로운 레드팀 테스트 방법을 제시한다. 특히, 기존 공격 기법이 RAG의 검색 메커니즘을 우회하지 못하는 반면, AgentPoison은 RAG 자체를 공격 대상으로 삼아 높은 공격 성공률을 달성한다. 그러나 이는 RAG 기반 에이전트에만 적용 가능하며, 다른 아키텍처를 사용하는 에이전트에는 적용이 제한적일 수 있다. 또한, Trigger가 단일 토큰으로도 작동하지만, 더 복잡한 시나리오에서는 추가 연구가 필요하다.
실용적 활용
AgentPoison은 자율주행, 헬스케어, 금융 등 안전성이 중요한 분야의 LLM 에이전트를 대상으로 한 보안 테스트에 활용될 수 있다. 특히, RAG 기반 시스템의 취약점을 사전에 탐지하고, 보안 강화 방안을 설계하는 데 유용하다.