REDCODER: multi-turn automated red team testing framework that precisely uncovers security vulnerabilities in code large models
The paper proposes REDCODER, a red team testing agent that conducts multi-turn conversations with code large models and induces them to generate vulnerable code. The framework first uses a multi-agent game involving an attacker, a defender, an evaluator and a strategy analyst to generate 2098 prototype conversations, extracts a reusable attack strategy library, then fine-tunes Llama3-8B-Instruct as the red team agent; at test time, it retrieves strategies by local interaction similarity via RAG to guide the next round of conversation. On 170 coding tasks covering 43 CWE vulnerability types, the vulnerability rates of CodeLlama-7B, CodeGemma-7B, Qwen2.5-Coder-7B and DeepSeek-R1-Distill-Llama-8B range from 39.41% to 65.29%, higher than baselines such as AutoDAN, GCG, CoA-Feedback and ActorAttack. In defense experiments, single-turn guardrails hardly change the attack results, while multi-turn guardrails reduce the vulnerability rates of the first three models to 20.20%, 25.00% and 54.69% respectively.