/

CVE-2026-102697

Severity:

HIGH RISK

(7.8)

Command Authorization Bypass (CWE-863) in Ollama Agent

CVE-2026-102697

Awaiting Analysis

Vulnerability type

Category:

Incorrect Authorization

CWE:

CWE-863

Impact:

Unauthorized Command Execution

Severity:

HIGH RISK

(7.8)

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

A high-severity authorization flaw in Ollama's experimental agent-mode Bash tool can allow shell commands to run without the required session approval. The issue becomes risky when an attacker can influence model output through prompt injection and cause the tool to misinterpret an approved command's shell syntax.

Affected context

The vulnerability occurs in Ollama versions 0.14.0 before 0.31.2 when experimental agent mode uses the Bash tool approval mechanism. It requires a deployment in which model output can influence tool invocation and the approval logic does not correctly account for shell control syntax appended to an otherwise approved command.

Exploit preconditions

  • Attack surface: Experimental agent-mode Bash tool
  • Required access: Ability to influence model behavior or output, typically through prompt injection or untrusted agent context
  • Trigger point: Authorization and approval processing for a proposed shell command
  • Why exploitation is possible: The approval mechanism may validate only part of the command and fail to enforce authorization for additional shell operations represented in the same input

Why this happens

The underlying bug is an authorization decision that does not faithfully represent the complete operation eventually interpreted by the shell. Because shell syntax is parsed incompletely, an input that appears to match an approved command may include additional operations that fall outside the approved scope. This maps to CWE-863: Incorrect Authorization, where access-control checks fail to enforce the intended permissions for the requested action.

Potential impact

  • An attacker may execute unauthorized shell commands in the Ollama runtime
  • Sensitive files, environment variables, or credentials could be exposed
  • The host or container could be modified or disrupted
  • Compromised runtime access could enable further lateral movement, depending on privileges

General mitigation guidance

Mitigation generally focuses on making authorization decisions over a structured, fully parsed representation of the requested action rather than over ambiguous command text.

Common defensive patterns include:

  • Separating command approval from shell interpretation and avoiding implicit shell evaluation
  • Allowing only narrowly defined commands and arguments through a secure-by-default policy
  • Treating model-generated tool requests and all surrounding context as untrusted
  • Requiring explicit approval for each distinct operation rather than approving a command prefix
  • Running agent processes with least privilege, restricted filesystem access, and limited network permissions
  • Applying containment controls so a compromised tool process cannot access unnecessary host resources

How teams detect issues like this

Organizations can look for:

  • Static analysis findings involving partial command matching, shell invocation, or authorization checks performed before complete parsing
  • Code-review signals such as prefix-based allowlists, string comparisons for shell commands, and approval logic that differs from execution logic
  • Policy enforcement that blocks unrestricted shell interpreters in agent tools or requires structured command schemas
  • Runtime monitoring for agent-issued commands that differ from approved command records or contain unexpected control syntax
  • Automated security review tools configured to identify command injection and authorization-boundary weaknesses

Sources

SourceLink
github.comgithub.com/ollama/ollama
github.comgithub.com/ollama/ollama/blob/v0.31.1/x/agent/approval.go#L204-L206
github.comgithub.com/ollama/ollama/blob/v0.31.1/x/agent/approval.go#L389
github.comgithub.com/ollama/ollama/commit/a2b3a5e9a3956bc0700a8505580c11faf4da09b5
github.comgithub.com/ollama/ollama/releases/tag/v0.31.2
vulncheck.comvulncheck.com/advisories/ollama-0.14.0-before-0.31.2-experimental-agent-bash-approval-bypass-via-prefix-based-authorization

Frequently asked

questions

Exploitability depends on how Ollama is deployed and exposed. An attacker generally needs a way to influence model output or agent context, while the agent must also have access to the vulnerable Bash tool.

It depends on the application's access controls and integration. The important prerequisites are access to an agent interaction path and the ability to influence the command proposed for execution.

Authorize a fully parsed, structured command against a narrow allowlist, and avoid passing model-generated text directly to a shell interpreter.

Treat model output as untrusted input, test authorization against complete command semantics, require approval for each operation, and limit the privileges and resources available to agent tools.

Find out what's already
exploitable in your codebase.