NeurIPS 2024 | University of Chicago proposes RedCode: the first safety benchmark for comprehensively evaluating the risky execution and generation of code agents
University of Chicago researchers propose the RedCode benchmark at NeurIPS 2024 to evaluate the safety of LLM-based code agents in executing dangerous code and generating malware. The RedCode-Exec module covers 25 dangerous scenarios across 8 domains and more than 4000 test instances, supports Python, Bash and natural language inputs, executes in a Docker sandbox and judges refusal, execution failure or attack success; the RedCode-Gen module uses 160 prompts to test whether agents generate malicious code as instructed, combining VirusTotal to assess maliciousness. Evaluation of 3 agent frameworks based on 19 LLMs shows that the attack success rate of agents executing dangerous code is generally high, that dangerous operations described in natural language are more readily accepted than in code format, that vigilance is higher for system operations such as deleting sensitive files and insufficient for code with technical flaws such as cryptographic predictability; malicious code generated by strong models such as GPT-4 is more complex and effective, and fine-tuning for agent tasks may weaken safety defenses.
The benchmark empirically tests 19 LLM-driven code agents in a Docker sandbox and finds that natural language instructions more easily lead agents to perform dangerous operations than code format, serving as a reference for safety testing.