/

CVE-2026-57586

Severity:

HIGH RISK

(8.6)

OS Command Injection (CWE-78) in CodeRAG Gradle Sync

CVE-2026-57586

Deferred

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Arbitrary Code Execution

Severity:

HIGH RISK

(8.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

CodeRAG can execute a repository-controlled Gradle wrapper when synchronizing dependencies for an indexed project. If a victim indexes an attacker-controlled Gradle repository, the attacker may run code with the victim's operating-system privileges.

Affected context

The vulnerability occurs in CodeRAG's default agent-coderag synchronization flow when an indexed directory contains a Gradle build file. The synchronization logic may prefer a repository-provided gradlew or gradlew.bat executable, while directory validation limits only the path location and does not establish that the executable is trusted or unmodified.

Exploit preconditions

  • Attack surface: Local execution of CodeRAG's dependency synchronization workflow
  • Required access: The victim must index or process an attacker-controlled repository
  • Trigger point: Dependency synchronization for a repository containing build.gradle or build.gradle.kts
  • Why exploitation is possible: A repository-controlled Gradle wrapper is executed as a subprocess from the repository root without sufficient executable-content or integrity validation

Why this happens

The underlying flaw is a failure to distinguish repository data from trusted executable code. When the presence of a Gradle build file is treated as sufficient authorization to run a repository-controlled wrapper, an attacker can influence the command executed by the application. This behavior maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command, because untrusted repository content reaches an operating-system process execution path without adequate trust or integrity controls.

Potential impact

  • An attacker may execute arbitrary code with the victim process's operating-system privileges
  • Sensitive files, credentials, or source code may be disclosed
  • Repository or local user data could be modified or destroyed
  • Malicious changes may establish persistence in the user environment
  • The victim environment could experience denial of service

General mitigation guidance

Mitigation generally focuses on preventing untrusted repositories from selecting executable tools implicitly.

Common defensive patterns include:

  • Do not execute repository-provided wrappers by default
  • Require explicit user consent before running build or dependency commands
  • Prefer trusted, centrally managed Gradle tooling over project-controlled executables
  • Verify executable provenance, integrity, and allowed locations before invocation
  • Isolate repository processing in a restricted sandbox with minimal filesystem, network, and credential access
  • Apply least-privilege execution and avoid inheriting sensitive environment variables
  • Treat indexed repository content as untrusted input throughout the synchronization workflow

How teams detect issues like this

Organizations can identify similar risks through:

  • Static analysis rules for subprocess APIs that execute paths derived from repositories or user-controlled input
  • Code review checks for automatic execution of build wrappers, scripts, or project hooks
  • Policies requiring explicit approval for build-tool execution during indexing or analysis
  • Runtime logging of selected executables, working directories, and parent workflows
  • Monitoring for unexpected child processes, network connections, or file changes from code-indexing tools
  • Automated security review tools that flag untrusted path-to-process execution flows

Sources

SourceLink
github.comgithub.com/naranor/agent-coderag/commit/1d917513cd95209bab9cbb5fe00df84989805e7d
github.comgithub.com/naranor/agent-coderag/releases/tag/v1.3.1
github.comgithub.com/naranor/agent-coderag/security/advisories/GHSA-wg5p-8h9p-3mr7

Frequently asked

questions

It is not typically a direct network attack. Exploitation generally occurs when a victim locally indexes or synchronizes an attacker-controlled repository.

The attacker needs to provide or influence a repository that the victim processes with CodeRAG. The attacker does not necessarily need access to the victim's machine beforehand.

Avoid automatically executing repository-controlled wrappers. Use trusted tooling, require explicit approval, and validate executable provenance and integrity before any process is started.

Treat build files and project scripts as untrusted, sandbox repository analysis, apply least privilege, and enforce review policies for subprocesses whose paths originate from project content.

Find out what's already
exploitable in your codebase.