/

CVE-2026-27487

Severity:

HIGH RISK

(7.6)

OS Command Injection in OpenClaw macOS Claude CLI Keychain

CVE-2026-27487

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Arbitrary OS Command Execution on macOS

Severity:

HIGH RISK

(7.6)

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

OpenClaw's macOS Claude CLI keychain credential refresh logic constructed a shell command that embedded user-controlled OAuth token data directly into a security add-generic-password invocation.

If an attacker could influence the stored OAuth token value, they could inject additional shell syntax and execute arbitrary commands on the user's macOS system during keychain updates.

Affected context

This vulnerability appears in OpenClaw on macOS when the application refreshes Claude CLI credentials and updates them in the Keychain.

The risky behavior occurs in versions 2026.2.13 and below, where the code builds a security add-generic-password -w ... command line by interpolating the OAuth token (a user-controlled value) directly into a shell command.

The issue is relevant in any environment where OAuth token content can be influenced or tampered with before being passed into the keychain refresh path.

Exploit preconditions

  • Attack surface: Local OpenClaw runtime on macOS during Claude CLI keychain refresh operations.
  • Required access: Ability to control or modify the OAuth token value used by OpenClaw (e.g., via a compromised auth flow, malicious configuration, or local tampering with stored credentials).
  • Trigger point: Execution of the credential refresh path that invokes security add-generic-password through a shell command constructed from string concatenation.
  • Why exploitation is possible: The code interpolates untrusted token data into a command string that is executed by a shell without strict quoting or argument separation, enabling additional shell metacharacters to be interpreted as separate commands or arguments.

Why this happens

The core bug is an OS command injection issue consistent with CWE-78, where external input is incorporated into command-line strings executed by a shell.

Instead of invoking the security binary via a parameterized API or passing arguments as a structured list, the implementation builds a single shell command string (including -w with the OAuth token) and executes it.

Because the OAuth token is user-controlled or externally influenced data, any shell metacharacters embedded in the token can break out of the intended argument context.

This pattern reflects a broader anti-pattern: concatenating untrusted input into shell commands instead of using safe process spawning mechanisms and rigorous argument escaping.

Potential impact

  • Execution of arbitrary OS commands under the current user's context on macOS.
  • Reading, modifying, or exfiltrating sensitive local files accessible to the user, including other credentials or tokens.
  • Installing or launching additional malware or persistence mechanisms on the affected system.
  • Tampering with local configuration for OpenClaw or other developer tools.
  • Pivoting to other accounts or services by abusing access granted to the compromised user environment.

General mitigation guidance

Effective mitigation focuses on eliminating command-string construction with untrusted input and reducing trust in credential values:

  • Prefer direct process invocation using APIs that pass arguments as arrays (e.g., posix_spawn, execve, or high-level wrappers that avoid involving a shell).
  • Treat OAuth tokens and other credentials as untrusted input for command invocation purposes, applying strict escaping or avoiding their inclusion in shell commands entirely.
  • Where an external tool like security must be used, construct arguments using safe, non-shell APIs and ensure that sensitive values are passed via stdin or environment variables when supported, not interpolated into shell strings.
  • Apply least-privilege principles, ensuring the process running these operations has only the minimum required permissions on the system and keychain.
  • Build defensive defaults into credential handling flows, such as input validation and whitelist-based character policies for tokens where compatible with protocol constraints.
  • Incorporate threat modeling for any flow that combines user-derived data with system utilities, especially credential management and OS tooling.

How teams detect issues like this

Detecting similar vulnerabilities usually involves a combination of static checks, code review practices, and security testing:

  • Static analysis: Configure rules to flag uses of shell-executing APIs (e.g., system, popen, backticks, subprocess with shell=True) where arguments include variables derived from user or network input.
  • Code review signals: Require explicit review of any code that:
  • Calls platform utilities like security, ssh, curl, or package managers.
  • Constructs command-line strings via concatenation or interpolation, especially when credentials or tokens are involved.
  • Policy enforcement: Establish internal guidelines that discourage shell usage for system interactions when language-native APIs exist; enforce these via linters or pre-commit hooks.
  • Dynamic testing: Include fuzzing or focused tests that feed special shell metacharacters into OAuth tokens or similar credential fields, verifying that they cannot alter command behavior.
  • Use automated security code scanning tools that recognize shell injection patterns and flag them in CI pipelines before release.

Sources

SourceLink
github.comgithub.com/openclaw/openclaw/commit/66d7178f2d6f9d60abad35797f97f3e61389b70c
github.comgithub.com/openclaw/openclaw/commit/9dce3d8bf83f13c067bc3c32291643d2f1f10a06
github.comgithub.com/openclaw/openclaw/commit/b908388245764fb3586859f44d1dff5372b19caf
github.comgithub.com/openclaw/openclaw/pull/15924
github.comgithub.com/openclaw/openclaw/releases/tag/v2026.2.14
github.comgithub.com/openclaw/openclaw/security/advisories/GHSA-4564-pvr2-qq4h

Frequently asked

questions

It can be remotely triggered if an attacker can control the OAuth token value that OpenClaw later uses in the keychain refresh path. For example, a compromised authorization server or manipulated login flow could supply a crafted token. The actual command execution occurs locally on the user's macOS system.

The attacker must be able to influence or set the OAuth token value that is subsequently processed by OpenClaw for keychain updates. This might come from controlling the auth backend, intercepting or injecting credentials, or manipulating local storage where the token is read from.

Replace shell-based command construction with direct process execution APIs that accept argument lists and do not invoke a shell. Ensure that sensitive values like tokens are passed as structured arguments or via supported secure channels (stdin, environment variables), never via string interpolation in a shell command.

Adopt a "no untrusted input in shell commands" policy, supported by static analysis and code review checklists. Whenever system utilities are needed, prefer native bindings or safe process invocation patterns, and treat credential-related code paths as high-risk, subject to dedicated security review and automated testing.

Find out what's already
exploitable in your codebase.