/

CVE-2026-45311

Severity:

CRITICAL RISK

(9.6)

Arbitrary Code Execution via Untrusted Project Code

CVE-2026-45311

Deferred

Vulnerability type

Category:

Arbitrary Code Execution via Untrusted Project Code

CWE:

CWE-94

Impact:

Local Arbitrary Code Execution and Environment Compromise

Severity:

CRITICAL RISK

(9.6)

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

CodeWhale's run_tests tool automatically runs cargo test in a repository workspace without asking the user for confirmation, effectively treating the repository's test suite as trusted code.

In a malicious or untrusted repository, test binaries, build scripts, or procedural macros can execute arbitrary shell commands, steal secrets, or establish persistence with zero user approval, especially when combined with auto-loaded prompts that encourage running tests on startup.

Affected context

This issue affects CodeWhale installations using versions 0.3.0 through 0.8.23 where:

  • The run_tests tool is available and configured with ApprovalRequirement::Auto.
  • The agent is used against repositories that may contain untrusted or third-party code.
  • The environment in which CodeWhale runs has access to developer credentials, SSH keys, API tokens, or other sensitive data.

The risk is heightened when AGENTS.md or similar configuration files are auto-loaded into the system prompt and instruct the agent to proactively invoke run_tests at session start, turning test execution into an implicit background action.

Exploit preconditions

  • Attack surface: Local developer or CI environment where CodeWhale operates.
  • Required access: Ability to supply or influence the repository contents that CodeWhale is pointed at (e.g., cloning a malicious repo, opening an untrusted pull request, or editing AGENTS.md).
  • Trigger point: Invocation of the run_tests tool, which in turn runs cargo test in the workspace with no approval prompt.
  • Why exploitation is possible:
  • cargo test compiles and executes arbitrary Rust code, including test functions, build.rs scripts, and procedural macros.
  • CodeWhale treats test execution as a safe, auto-approved action, collapsing the boundary between "viewing code" and "running code".
  • AGENTS.md can nudge or instruct the agent to run tests automatically, so execution may occur without explicit user intent at that moment.

Why this happens

The root cause is a design-level trust boundary failure: CodeWhale's run_tests tool assumes that project test code is safe to execute and configures ApprovalRequirement::Auto, eliminating human-in-the-loop confirmation for running cargo test.

This maps to CWE-94: Improper Control of Generation of Code ('Code Injection') in the sense that untrusted repository content is treated as trustworthy executable logic. The tooling effectively allows external code (tests, build scripts, macros) to be introduced via repository files and then compiled and executed automatically, without proper validation, sandboxing, or explicit user consent. The problem is not a single input parsing bug, but the unsafe pattern of granting arbitrary project code an execution path under an "auto-approve" policy.

Potential impact

  • Local execution of arbitrary OS commands under the user's account.
  • Exfiltration of SSH keys, API tokens, cloud credentials, or configuration files accessible to the environment.
  • Tampering with local source trees, Git metadata, or developer tooling configuration.
  • Establishment of persistence via modified shell profiles, editor configs, or scheduled tasks.
  • Abuse of the developer's machine to pivot into internal networks or CI environments.

General mitigation guidance

Effective mitigation focuses on restoring a clear and conservative execution boundary between "reading code" and "running code":

  • Require explicit user approval before executing any test, build, or arbitrary command in a repository, especially for cargo test-like operations that compile and run project code.
  • Treat all repository content as untrusted by default; adopt least privilege when invoking compilers, test runners, or build systems.
  • Provide configuration options or policies to disable or strictly restrict auto-execution behaviors (including actions suggested by AGENTS.md or similar prompt files).
  • Where execution of untrusted code is necessary, prefer sandboxed or containerized environments with constrained permissions and limited access to host secrets.
  • Encourage workflows where sensitive credentials are not directly exposed to tools that might automatically execute repository code.

How teams detect issues like this

Detection centers on identifying unsafe auto-execution pathways and monitoring how tools treat repository content:

  • Review agent and tooling code for patterns where external project files can trigger automatic command execution, particularly test runners or build steps configured with auto-approval.
  • Use static analysis or policy checks to flag code paths that run shell commands, compilers, or test frameworks without explicit user confirmation or without trust checks on the source.
  • In deployment and CI configurations, instrument logging around test and build invocations to detect unexpected cargo test runs or similar commands initiated by agents.
  • Incorporate security reviews into the design of developer-assistance tools, focusing on where they cross from "analyzing" to "executing" project artifacts.

Sources

SourceLink
github.comgithub.com/Hmbown/CodeWhale/security/advisories/GHSA-wx44-2q6h-j6p8

Frequently asked

questions

It is not directly remote in the traditional network sense, but it becomes exploitable whenever a user opens or clones an untrusted repository with CodeWhale and allows the agent to run tests. An attacker can publish or share a malicious repository that, once opened, causes CodeWhale to execute harmful test code locally.

The attacker needs control or influence over the repository contents that the user works with. This could be a public repo, a pull request, or any shared project. No additional OS-level permissions are necessary beyond what the developer's environment already grants to CodeWhale and cargo.

The safest pattern is to reintroduce explicit user consent for executing any repository code, including tests and build scripts, and to treat such operations as potentially dangerous. Tools should default to non-execution or sandboxed execution and require a deliberate opt-in from the user before running tests.

Design developer tools with a clear security boundary between code inspection and code execution. Avoid auto-approval for commands that compile or run project code, provide hard controls for auto-run behaviors like AGENTS.md instructions, and consider sandboxing or isolation for any operation that executes untrusted repository artifacts.

Find out what's already
exploitable in your codebase.