Severity:

HIGH RISK

(7.3)

Code Injection in MetaGPT HumanEval/MBPP Benchmarks

CVE-2026-5970

Analyzed

Vulnerability type

Category:

Code Injection

CWE:

CWE-74, CWE-94

Impact:

Remote Code Execution

Severity:

HIGH RISK

(7.3)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

MetaGPT up to version 0.8.1 contains a code injection vulnerability in the check_solution function used by the HumanEvalBenchmark and MBPPBenchmark components.

When attacker-controlled content is incorporated into dynamically evaluated code, a remote attacker may execute arbitrary code in the environment running the benchmarks.

Affected context

The issue arises in environments running MetaGPT's HumanEval and MBPP benchmark components where:

  • User- or model-generated solutions are programmatically evaluated by check_solution
  • The benchmark framework constructs and executes code based on dynamic inputs
  • There is insufficient neutralization or validation of content that becomes part of executable code

This typically impacts systems that automatically run code for evaluation or testing of generated solutions.

Exploit preconditions

  • Attack surface: Remote interface or workflow that accepts code or solution submissions processed by MetaGPT benchmarks.
  • Required access: Ability to supply or manipulate the solution or related input that check_solution incorporates into executable code.
  • Trigger point: Execution of the benchmark evaluation process, where check_solution builds and runs code to assess correctness.
  • Why exploitation is possible: Untrusted input is interpolated into code strings or evaluation contexts without proper escaping, isolation, or policy enforcement, enabling injection of arbitrary statements.

Why this happens

The root cause is the construction and execution of dynamic code that incorporates untrusted content without sufficient neutralization or confinement.

In the context of check_solution for HumanEval/MBPP, attacker-controlled data is likely concatenated into source code or passed to an evaluator (such as exec, eval, or equivalent dynamic execution mechanisms).

This aligns with:

  • CWE-94: Improper Control of Generation of Code, where external input influences generated code that is then executed.
  • CWE-74: Improper Neutralization of Special Elements, where special characters or tokens in the input are not escaped, allowing them to break out of the intended structure and inject new behavior.

The insecure pattern is treating evaluation-time input as trusted and executable, instead of treating it as data subject to strict validation and sandboxing.

Potential impact

  • Execution of arbitrary code in the context of the process running MetaGPT benchmarks
  • Access to sensitive data available to the evaluation environment (e.g., environment variables, local files, credentials)
  • Lateral movement within the host or CI agent running the benchmark suite
  • Tampering with benchmark results, logs, or artifacts
  • Potential use of the compromised environment as a pivot point for broader infrastructure attacks

General mitigation guidance

Risk reduction focuses on eliminating direct code execution paths from untrusted input and constraining evaluation environments:

  • Avoid dynamically constructing code strings from user- or model-controlled input; prefer explicit, parameterized calling patterns instead of eval/exec-style evaluation.
  • If dynamic execution is unavoidable, use strict whitelisting and structural validation to ensure input matches expected patterns (e.g., function bodies without imports or system calls).
  • Introduce sandboxed execution environments with strong process-level isolation, restricted file system access, and minimal privileges for any code being evaluated.
  • Treat benchmark input as untrusted: sanitize or neutralize special characters that can alter control flow or break out of expected code templates.
  • Apply least-privilege principles so that the benchmark process has only the access it strictly needs, reducing impact if injected code runs.
  • Separate evaluation infrastructure from production systems to prevent cross-environment compromise.

How teams detect issues like this

Detection can combine code-level analysis and runtime monitoring:

  • Use static analysis to flag calls to dynamic execution APIs (e.g., exec, eval, compile, ast.literal_eval misuse) where arguments are derived from external or model-generated input.
  • Incorporate secure coding checks in code review to identify string concatenation or f-string interpolation that builds executable code from untrusted data.
  • Enforce secure coding policies in CI that fail builds when prohibited patterns (e.g., unguarded exec on variable content) are detected.
  • Apply runtime monitoring or sandbox auditing to detect unexpected system calls, file operations, or network activity originating from benchmark evaluation processes.
  • Use automated review tools that understand data flow to trace untrusted inputs from interfaces (APIs, CLI, files) into dynamic code execution sinks.

Sources

SourceLink
github.comgithub.com/FoundationAgents/MetaGPT/
github.comgithub.com/FoundationAgents/MetaGPT/issues/1942
github.comgithub.com/FoundationAgents/MetaGPT/pull/1988
vuldb.comvuldb.com/submit/791693
vuldb.comvuldb.com/vuln/356524
vuldb.comvuldb.com/vuln/356524/cti

Frequently asked

questions

Exploitability depends on how the MetaGPT benchmark components are exposed. If external users, services, or models can supply code or solution content that is evaluated by check_solution, then remote exploitation is possible; isolated, local-only use with trusted inputs significantly reduces practical risk.

An attacker needs the ability to influence the inputs that are transformed into executable code by the benchmark evaluation logic—typically through an API, job queue, or pipeline that feeds solutions into HumanEval/MBPP check_solution.

The safest pattern is to remove direct dynamic code execution of untrusted content: avoid building code strings from input and executing them, and instead use controlled, parameterized invocation or pre-defined harnesses that do not allow arbitrary statements, imports, or system interaction.

Prevention involves adopting design patterns that treat all external or model-generated content as untrusted, banning or tightly restricting dynamic execution primitives, performing rigorous code reviews focused on data-to-code transitions, and running any necessary code evaluation in strongly isolated sandboxes with least privilege and clear security policies.

Find out what's already
exploitable in your codebase.