CVEReports
CVEReports

Automated vulnerability intelligence platform. Comprehensive reports for high-severity CVEs generated by AI.

Product

  • Home
  • Sitemap
  • RSS Feed

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CVEReports. All rights reserved.

Made with love by Amit Schendel & Alon Barad



GHSA-456V-XQ2P-R4CJ

GHSA-456V-XQ2P-R4CJ: OS Command Injection in code-ollama grep_search Tool

Amit Schendel
Amit Schendel
Senior Security Researcher

Sep 28, 2026·5 min read·16 visits

Executive Summary (TL;DR)

A command injection vulnerability in the code-ollama grep_search tool allows compromised LLM backends to run arbitrary local commands without user interaction.

An OS command injection vulnerability in the grep_search tool of the code-ollama package allows remote code execution. This vulnerability is triggered when a local client executes the CLI against a malicious or compromised Ollama server. Due to grep_search being classified as a read-only tool, the CLI executes it automatically in Plan mode without human-in-the-loop validation, leading to zero-interaction local system compromise.

Vulnerability Overview

The code-ollama library is a command-line utility designed to integrate local large language models (LLMs) with software development workflows. This tool allows models to interact with the local filesystem through a suite of registered operations. These operations facilitate actions such as reading files, writing files, and searching directory structures.\n\nTo optimize directory search capabilities, the utility includes a grep_search tool. This component utilizes the system's ripgrep (rg) binary to perform fast, indexed searches of user-specified patterns within a target directory path.\n\nBecause grep_search is designated as a read-only tool within the code-ollama constants registry, the application does not prompt the user for execution approval. During plan execution, the CLI automatically runs this command upon receiving a tool call request from the model. This behavior enables a direct command execution pipeline requiring zero manual validation.

Root Cause Analysis

The core vulnerability is located in the grep_search implementation within the file src/utils/tools/filesystem/grep.ts. The application attempts to sanitize user-supplied input parameters using simple regular expression replacements. Specifically, the sanitization replaces all instances of backslashes and double-quotes with escaped counterparts.\n\nWhile this replacement prevents parameter containment breakout in standard string contexts, it fails to account for POSIX shell parsing dynamics within double-quoted arguments. In shell interpreters like bash or sh, command substitution structures such as $() and backticks remain active inside double-quotes. The sanitization logic does not neutralize or escape these characters.\n\nWhen the sanitized pattern is concatenated into a final command string, it is forwarded to Node.js's child_process.exec() API. Because child_process.exec() spawns an intermediate system shell (/bin/sh) to execute the command, the shell evaluates the nested command substitutions prior to executing the primary ripgrep binary, triggering the injection.

Code Analysis

An inspection of the vulnerable implementation in v0.36.0 shows that the shell execution string is dynamically constructed via template literals:\n\ntypescript\n// Vulnerable Code Path (v0.36.0)\nconst escapedPattern = searchPattern\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/\"/g, '\\\\\"');\nconst escapedDirPath = dirPath.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"');\n\nconst { stdout } = await execShell(\n `rg --line-number --no-heading --smart-case \"${escapedPattern}\" \"${escapedDirPath}\"`,\n);\n\n\nThe patch resolves this vulnerability by migrating from shell execution to binary execution. The child_process.execFile() function is used to invoke the binary directly without spawning an intermediary shell interpreter. This eliminates shell syntax parsing entirely.\n\ntypescript\n// Patched Code Path (v0.36.1)\nimport { execFile } from '../../node';\n\nconst RG_EXEC_OPTIONS = { timeout: 30_000, maxBuffer: 1024 * 1024 };\n\nconst { stdout } = await execFile(\n 'rg',\n ['--line-number', '--no-heading', '--smart-case', '--', searchPattern, dirPath],\n RG_EXEC_OPTIONS,\n);\n

Exploitation Methodology

An attacker must compromise or control the Ollama server endpoint queried by the victim's code-ollama client. Alternatively, an attacker could trigger a prompt-injection state where a local or remote model is forced to call the grep_search tool with a malicious pattern.\n\nWhen the target connects to the rogue Ollama instance, the server returns a crafted JSON payload containing tool call instructions. The payload specifies the grep_search function and supplies the command injection string inside the pattern field.\n\nmermaid\ngraph LR\n Server["Rogue Ollama Server"] -->|\"Returns Tool Call: grep_search\"| Client["code-ollama Client"]\n Client -->|\"Checks Read-Only Tool List\"| AutoExecute["Auto-Execution Route (No Prompt)"]\n AutoExecute -->|\"Regex Replacement Fail\"| Escape["Incomplete Sanitization"]\n Escape -->|\"Executes String via Shell\"| System["Target OS Shell Command Executed"]\n\n\nBecause the pattern field contains active command substitution characters, the system shell evaluates the nested command. The command executes with the privileges of the system user running the CLI tool.

Impact Assessment

The successful exploitation of this vulnerability results in full local operating system access within the context of the running developer. Because software development environments typically possess direct read and write permissions to confidential source code, access credentials, and SSH keys, the potential impact is severe.\n\nAn attacker can exfiltrate sensitive environment variables, manipulate source code during development, and modify system configuration files. Additionally, the execution takes place silently in the background because the tool runs automatically during Plan Mode operations.\n\nThe CVSS v3.1 score is calculated at 7.8 (High), with a vector of CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H. This reflects that while local access is required for execution, no special privileges are needed, and the integrity, confidentiality, and availability impacts are elevated.

Remediation and Prevention

The primary remediation action is upgrading the code-ollama npm package to version 0.36.1 or later. This version replaces the insecure string-based child_process.exec() call with child_process.execFile(), preventing the host shell from evaluating parameter arguments.\n\nWhen direct updates are not immediately feasible, operators should configure their network firewalls to restrict local CLI tools to trusted Ollama endpoints. Organizations should block outgoing connections to external, arbitrary LLM server providers.\n\nDevelopers should audit any local AI tools to confirm that shell wrapper functions are not utilized for filesystem queries. Ensure that security policies mandate user validation and approval for all external tool executions, regardless of their read-only designation.

Technical Appendix

CVSS Score
7.8/ 10
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

Affected Systems

code-ollama npm package

Affected Versions Detail

Product
Affected Versions
Fixed Version
code-ollama
ai-action
<= 0.36.00.36.1
AttributeDetail
CWE IDCWE-78
Attack VectorLocal
CVSS Score7.8
ImpactArbitrary OS Command Execution
Exploit Statuspoc
Affected Componentgrep_search tool (grep.ts)

MITRE ATT&CK Mapping

T1059.004Unix Shell
Execution
T1203Exploitation for Client Execution
Execution
CWE-78
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

The application constructs an OS command using externally-influenced input, but it fails to neutralize or incorrectly neutralizes special elements that can alter the intended command when sent to the downstream interpreter.

References & Sources

  • [1]GitHub Security Advisory GHSA-456V-XQ2P-R4CJ
  • [2]Internal Security Advisory Mapping

Attack Flow Diagram

Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.

More Reports

•about 2 hours ago•CVE-2026-9639
6.5

CVE-2026-9639: Authenticated Denial of Service via Nil-Pointer Dereference in Canonical LXD Custom Volume Backup Import

CVE-2026-9639 (GHSA-j93m-3j9p-m5m8) is a null pointer dereference vulnerability in Canonical LXD affecting versions 5.0.0 through 5.21.4 and 6.0 through 6.8. The flaw resides in the (*lxdBackend).CreateCustomVolumeFromBackup method within lxd/storage/backend_lxd.go. An authenticated attacker with the can_create_storage_volumes permission can upload a crafted custom volume backup tarball that omits the expires_at field on a snapshot entry, triggering an unhandled SIGSEGV panic and terminating the LXD daemon.

Amit Schendel
Amit Schendel
5 views•9 min read
•about 3 hours ago•CVE-2026-33050
8.8

CVE-2026-33050: OS Command Injection in GeoNode Vector Upload Handler

An operating system command injection vulnerability (CWE-78) exists in GeoNode versions prior to 5.1.0. The vulnerability occurs in the vector upload processing pipeline when handling user-supplied geospatial files. By supplying a crafted layer name containing shell metacharacters, an authenticated attacker with basic data upload privileges can execute arbitrary commands on the underlying server or container hosting the GeoNode application and Celery worker processes.

Alon Barad
Alon Barad
5 views•9 min read
•about 4 hours ago•CVE-2026-46429
5.5

CVE-2026-46429: Unrestricted File Upload and Validation Bypass in GeoNode

GeoNode versions prior to 5.0.3 contain an unrestricted file upload vulnerability (CWE-434) within the document and dataset ingestion architecture. Authenticated low-privileged users can bypass upload validation via direct REST API interactions, file extension masquerading, metadata mutation via PATCH requests, or malicious archive submissions. This allows attackers to store and serve dangerous file types, alter on-disk file references, or trigger path traversal and resource exhaustion during archive extraction.

Amit Schendel
Amit Schendel
5 views•10 min read
•about 5 hours ago•CVE-2026-55649
6.3

CVE-2026-55649: Stored Cross-Site Scripting in GeoNode Document Metadata Abstract Field

CVE-2026-55649 is a stored Cross-Site Scripting (XSS) vulnerability in GeoNode versions prior to 5.0.3. The flaw exists because document abstract metadata fields are ingested via the metadata management pipeline and stored in the backend database without HTML sanitization or input neutralization. An authenticated attacker with privileges to create or edit document metadata can inject arbitrary HTML and JavaScript payloads into these fields. When another user, such as an administrator, views the affected document page or catalog listing, the unencoded payload is rendered into the Document Object Model (DOM) and executes within the victim's browser session.

Amit Schendel
Amit Schendel
7 views•9 min read
•about 6 hours ago•GHSA-QX75-2P3R-PWM5
7.7

CVE-2026-55622: Cross-Project Instance Copy Authorization Bypass in Canonical LXD and LXC Incus

CVE-2026-55622 (GHSA-qx75-2p3r-pwm5) is an improper access control vulnerability (CWE-284) in Canonical LXD and LXC Incus (tracked as GHSA-c9f5-j9c3-mhrg). In multi-tenant deployments utilizing project-based isolation, the REST API handler for instance creation via POST /1.0/instances verifies that the authenticated user has authorization in the destination project specified by the query parameter, but fails to verify whether the user holds read or view permissions for the source instance when executing a copy operation across projects. Consequently, an authenticated client restricted to a single project can clone instances or snapshots from unauthorized projects into their own project, resulting in complete disclosure of the target instance filesystem and embedded credentials.

Amit Schendel
Amit Schendel
6 views•11 min read
•about 7 hours ago•GHSA-7MR3-28H5-M5VX
7.7

GHSA-7mr3-28h5-m5vx: Authorization Bypass and Cross-Project Volume Copy in Canonical LXD

An authorization bypass vulnerability in Canonical LXD (tracked as GHSA-7mr3-28h5-m5vx and CVE-2026-55621, and as GHSA-64f3-v33m-w89f in Linux Containers Incus) allows an authenticated user with restricted project access to copy custom storage volumes and volume snapshots from unauthorized projects. The flaw resides in the storagePoolVolumesPost REST API handler, which verifies permissions on the destination project but fails to check whether the caller holds view entitlements on the source project or volume specified in the request body.

Alon Barad
Alon Barad
5 views•10 min read