
블랙박스 공격 프레임워크로, 에이전트 기반 검색 증강 생성(RAG) 시스템에서 추론을 탈취하기 위해 오염된 문서를 주입하며, 여러 공격 방법과 데이터셋을 지원합니다.
클론한 KidnapRAG 저장소의 상위 디렉터리에서 다음 명령어를 실행하세요.
cd KidnapRAG
conda create -n KidnapRAG python=3.10
conda activate KidnapRAG
pip install -r requirements.txt
그런 다음, 말뭉치 데이터셋 📄을 다운로드하고 ReAct 데이터셋을 /KidnapRAG/ReAct로, WebThinker 데이터셋을 /KidnapRAG/WebThinker로 이동하세요.
Llama 모델을 사용한 HotpotQA 예시입니다.
cd ReAct/ReAct
CUDA_VISIBLE_DEVICES=0,1,2,3 python attack_react.py --attack_method clean --model_path meta-llama/Llama-3.3-70B-Instruct --seed 1 --dataset hotpotqa
--model_path는 Llama-3.3-70B-Instruct와 Qwen/Qwen2.5-32B-Instruct를 지원합니다.
--dataset은 hotpotqa, musique, 2wikimultihopqa를 지원합니다.
CUDA_VISIBLE_DEVICES=0,1 python generate_attack_doc_kill.py --input_path /KidnapRAG/ReAct/results/adv_targeted_results/hotpotqa_seed1_clean_llama70b.json --gpu_num 2 --dataset hotpotqa --type ours
--type은 다음 공격 방법을 추가로 지원합니다: Naive Attack용 naive, Ignore Attack용 ignore, Fake Completion Attack용 completion_real, Combined Attack용 completion_realcmb, TopicAttack용 topicattack, PoisonedRAG용 poisonedRAG, RAG Paradox용 paradox.
BM, BCM, BCCM, BCCCM, BCCCCM)cd ..
python concat.py --dataset hotpotqa --gen_model llama70b
--gen_model은 Llama-3.3-70B-Instruct용 llama70b와 Qwen/Qwen2.5-32B-Instruct용 qwen25를 지원합니다.
CUDA_VISIBLE_DEVICES=0 python scripts/build_index.py \
--corpus_path /KidnapRAG/ReAct/datasets/hotpotqa/REACT_BM_llama70b.jsonl \
--output_dir /KidnapRAG/ReAct/datasets/hotpotqa/REACT_BM_llama70b \
--model_name intfloat/e5-large-v2
cd ReAct
CUDA_VISIBLE_DEVICES=0,1,2,3 python attack_react.py --attack_method BM --model_path meta-llama/Llama-3.3-70B-Instruct --seed 1 --dataset hotpotqa
QwQ 모델을 사용한 HotpotQA 예시입니다.
이 섹션은 KidnapRAG 저장소 루트에서 실행하세요.
cd Webthinker
bash scripts/webthinker/qwq_clean.sh \
./datasets/hotpotqa/hotpotqa_promptinject_select.json \
./datasets/hotpotqa_corpus/hotpotqa_corpus.jsonl \
./results/hotpotqa/clean_qwq.json
인자:
./datasets/hotpotqa/hotpotqa_promptinject_select.json: 쿼리 경로./datasets/hotpotqa_corpus/hotpotqa_corpus.jsonl: 말뭉치 경로./results/hotpotqa/clean_qwq.json: 결과 경로cd scripts
CUDA_VISIBLE_DEVICES=0,1 python generate_attack_doc_kill.py --input_path /KidnapRAG/Webthinker/results/hotpotqa/clean_qwq.json --gpu_num 2 --dataset hotpotqa --type ours
BM, BCM, BCCM, BCCCM, BCCCCM)cd ..
python concat.py --dataset hotpotqa --gen_model qwq
--gen_model은 lixiaoxi45/WebThinker-R1-32B용 deepseek_32b와 Qwen/QwQ-32B용 qwq를 지원합니다.
bash scripts/webthinker/qwq_attack.sh \
./datasets/hotpotqa/hotpotqa_promptinject_select.json \
./datasets/hotpotqa_corpus/hotpotqa_corpus.jsonl \
./datasets/hotpotqa_poisoned_corpus/WEBTHINKER_BM_qwq.jsonl \
./results/hotpotqa/BM.json
인자:
./datasets/hotpotqa/hotpotqa_promptinject_select.json: 쿼리 경로./datasets/hotpotqa_corpus/hotpotqa_corpus.jsonl: 말뭉치 경로./datasets/hotpotqa_poisoned_corpus/WEBTHINKER_BM_qwq.jsonl: 오염된 말뭉치 경로./results/hotpotqa/BM.json: 결과 경로@misc{
}