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.gradleorbuild.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

