atlas

Research map / Large language models / Agents, code and math

RedCode: Risky Code Execution and Generation Benchmark for Code Agents

NeurIPS 2024 · Large language models › Agents, code and math · approach: Software engineering agents · 10 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Introduces RedCode, a benchmark of 4,050 risky code-execution cases (Python/Bash, multiple input formats, Docker sandbox with deterministic checks) and 160 malware-generation prompts for evaluating code agent safety.

Problem

Safety of LLM-based code agents that execute or generate code in real systems lacks comprehensive evaluation; prior agent safety benchmarks rely on simulated trajectories judged by LLMs.

Approach

Evaluate code agents on executable risky test cases inside Docker containers with deterministic evaluation scripts that check the actual environment state and outputs, rather than LLM judges over simulated trajectories; cover execution (RedCode-Exec) and malicious software generation (RedCode-Gen).

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Add compiler feedback and iterative code refinementCode agents compared with their base LLMs · RedCode-GenAccuracy: 49.4 -> 79.4Helped
Add compiler feedback and iterative code refinementCode agents compared with their base LLMs · RedCode-GenRefusal Rate: 11.3 -> 1.3Hurt
Add compiler feedback and iterative code refinementGPT-4 · RedCode-GenVirusTotal: 4.4 -> 5.6Helped
Use natural-language summaries or descriptions instead of programming-language inputsCode agents on RedCode-Exec · RedCode-ExecAttack Success RateHurt
Use text descriptions instead of text summariesCode agents on RedCode-Exec · RedCode-ExecAttack Success RateHurt
Use Python instead of Bash inputsCode agents on RedCode-Exec · RedCode-ExecRejection RateHelped
Use OpenCodeInterpreter instead of ReAct or CodeActCode agents on RedCode-Exec · RedCode-ExecRejection RateHelped
Use a stronger base LLMReAct agents on RedCode-Exec · RedCode-ExecRejection RateHelped
Use a stronger coding modelBase LLMs on RedCode-Gen · RedCode-GenAccuracy: 0.448 Pearson scoreMixed
Add safety-aware promptsCode agents on RedCode-Exec · RedCode-ExecAttack Success RateNo clear effect

Surprising findings

Limitations

Experimental setup

Datasets: CWE examples R-judge ToolEmu

Benchmarks: RedCode-Exec RedCode-Gen

Metrics: rejection rate attack success rate LLM judge score (0-5) refusal rate VirusTotal detection

Baselines: ToolEmu R-judge AgentMonitor HAICOSYSTEM AgentDojo ASB

Builds on: CodeAct ReAct OpenCodeInterpreter HumanEval R-judge

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy