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

•29 minutes ago•CVE-2026-118740
9.1

CVE-2026-118740: Missing Authorization in Microsoft Aspire Dashboard Blazor Router

CVE-2026-118740 is a Missing Authorization (CWE-862) vulnerability in the Microsoft Aspire Dashboard and Aspire.Dashboard.Sdk.linux-x64 packages. In versions 13.6.1 prior to 13.6.5, an architectural flaw in the Blazor routing configuration (Routes.razor) causes unmapped (404 / Not-Found) routes to bypass the AuthorizeRouteView component. By navigating to an arbitrary non-existent route, an unauthenticated remote attacker forces the application into the NotFound template, which unconditionally renders the primary MainLayout component and initializes global user interface services, interaction providers, and underlying SignalR/Blazor circuits without verifying authentication credentials.

Alon Barad
Alon Barad
1 views•9 min read
•about 23 hours ago•CVE-2026-120006
7.5

CVE-2026-120006: Elevation of Privilege in .NET Aspire via Unintended Dashboard Endpoint Tunneling

An elevation of privilege vulnerability exists in .NET Aspire versions prior to 13.6.5 due to the insertion of sensitive information into sent data (CWE-201). When the Developer Control Plane (DCP) container tunneling feature is enabled, the orchestration engine implicitly exposes all endpoints of the Aspire Dashboard—including its administrative frontend and management APIs—to containerized workloads instead of restricting tunnel access solely to OpenTelemetry Protocol (OTLP) collection endpoints. This exposure allows an attacker operating within a compromised or untrusted container to query the dashboard frontend, extract sensitive environment variables and connection strings, and elevate privileges across the host orchestration boundary.

Amit Schendel
Amit Schendel
5 views•10 min read
•about 23 hours ago•CVE-2026-118750
7.5

CVE-2026-118750: Uncontrolled Resource Allocation in ASP.NET Core FileBufferingReadStream

CVE-2026-118750 is an uncontrolled resource allocation vulnerability (CWE-770) affecting the Microsoft.AspNetCore.WebUtilities component in ASP.NET Core. Specifically, the FileBufferingReadStream class eagerly allocates large memory buffers from the shared ArrayPool<byte> inside its constructor prior to reading any incoming request payload data. An unauthenticated remote attacker can exploit this behavior by opening numerous concurrent connections and stalling or omitting request body transmission, exhausting shared memory pools and causing a server-wide Denial of Service (DoS).

Amit Schendel
Amit Schendel
6 views•10 min read
•1 day ago•CVE-2026-114155
7.5

CVE-2026-114155: Local Elevation of Privilege via TOCTOU Race Condition in Microsoft .NET dotnet-watch

CVE-2026-114155 is a local elevation of privilege vulnerability affecting Microsoft .NET on Linux and macOS platforms. The vulnerability exists within the dotnet-watch (Hot Reload) component and is caused by a Time-of-Check Time-of-Use (TOCTOU) race condition (CWE-367) during the generation and execution of temporary XML solution files (.slnx) in shared system temporary directories. A local attacker with low privileges can intercept and modify the temporary solution file before MSBuild evaluates it, achieving arbitrary code execution in the security context of the user running dotnet-watch.

Alon Barad
Alon Barad
6 views•9 min read
•1 day ago•CVE-2026-118748
7.5

CVE-2026-118748: Unbounded Memory Allocation Denial of Service in ASP.NET Core Blazor Static-SSR

CVE-2026-118748 is a remote Denial of Service (DoS) vulnerability in Microsoft ASP.NET Core (.NET 11.0 preview releases prior to 11.0.0) and Microsoft Visual Studio 2026 (prior to 18.12.0). The flaw originates from unbounded resource allocation (CWE-770) within the Blazor static server-side rendering (static-SSR) validation pipeline, where dynamic or attacker-supplied form field identifiers are cached in a singleton-scoped memory structure without size limits or eviction policies. Unauthenticated remote attackers can exploit this condition over the network by sending repeated HTTP requests with unique field names, exhausting heap memory and terminating the host process via an unhandled OutOfMemoryException.

Alon Barad
Alon Barad
11 views•9 min read
•1 day ago•CVE-2026-114150
5.9

CVE-2026-114150: Remote Information Disclosure via Uninitialized Pooled Memory in ASP.NET Core Response Buffering

CVE-2026-114150 is a network-accessible information disclosure vulnerability affecting Microsoft ASP.NET Core in .NET 11.0 preview releases and Microsoft Visual Studio 2026 prior to version 18.12.0. The flaw stems from the use of uninitialized resources (CWE-908) within response buffering components, specifically ResponseBufferingStream used by middleware such as HTTP Logging and Output Caching. Because rented memory segments from ArrayPool<byte> or MemoryPool<byte> are not cleared upon return or strictly bounded to the exact written byte count during subsequent reads, residual response payloads from earlier HTTP requests remain in the buffer tail. Downstream consumers or log sinks reading these buffers expose confidential cross-session data, including authentication tokens and personally identifiable information.

Amit Schendel
Amit Schendel
4 views•11 min read