/

CVE-2026-28484

Severity:

CRITICAL RISK

(9.8)

Command Injection / Argument Injection in OpenClaw git

CVE-2026-28484

Received

Vulnerability type

Category:

Command Injection / Argument Injection

CWE:

CWE-77

Impact:

Exposure of Sensitive Files in Git History

Severity:

CRITICAL RISK

(9.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

OpenClaw versions prior to 2026.2.15 contain a command option injection flaw in the git-hooks/pre-commit script, where filenames are passed through xargs to git add without a -- separator.

An attacker who can create files whose names begin with dashes can inject git flags, causing ignored files such as .env or other sensitive artifacts to be staged and committed into repository history.

Affected context

This vulnerability appears in development environments that use OpenClaw's provided git pre-commit hook.

The issue is triggered when the hook:

  • Collects filenames and pipes them through xargs
  • Invokes git add without a protective -- argument
  • Operates in repositories where sensitive files are intentionally ignored (e.g., via .gitignore)

It primarily affects workflows where developers routinely rely on the pre-commit hook to control what gets staged and trust it to exclude ignored or sensitive files.

Exploit preconditions

  • Attack surface: Local development repository using OpenClaw's git-hooks/pre-commit script
  • Required access: Ability to create or rename files in the repository working directory (e.g., a contributor, malicious dependency writing files, or a shared workspace user)
  • Trigger point: Running git commit (or any workflow that executes the OpenClaw pre-commit hook)
  • Why exploitation is possible: The hook passes filenames directly to xargs and into git add without a -- separator, so filenames beginning with - are interpreted as additional git add options instead of literal paths. This allows crafted filenames to alter git's behavior and stage files that should remain ignored.

Why this happens

At its core, this is an argument/option injection bug in a shell-based workflow, mapping to CWE-77: Command Injection via improper command invocation.

The pre-commit hook composes a shell pipeline where untrusted filenames are treated as part of the command line:

  • Filenames are collected and piped through xargs without robust quoting/escaping.
  • git add is invoked without the conventional -- separator that signals the end of options.

When filenames start with dash characters, command-line parsers treat them as flags, not data.

This pattern is a common pitfall in shell scripting: failing to distinguish between user-controlled data (filenames) and command options, leading to unintended behavior or security-sensitive side effects.

Potential impact

  • Sensitive environment files (e.g., .env) could be staged and committed into the repository history.
  • Secrets, API keys, credentials, or tokens stored in ignored files may be exposed to all repository users.
  • Internal configuration, debug logs, or temporary artifacts that were meant to stay local could be committed.
  • Regulatory or compliance issues if confidential data or personal information is accidentally checked into version control.
  • Increased risk of downstream compromise if leaked secrets are reused in production systems or other services.

General mitigation guidance

Effective mitigation focuses on robust command construction and defensive handling of filenames inside scripts:

  • Treat filenames as untrusted input and ensure they are passed to tools as data, not parsed as options.
  • Use -- to terminate option parsing when calling git add and similar commands, so subsequent tokens are always interpreted as paths.
  • Prefer safe invocation patterns such as:
  • Using null-delimited filenames with xargs -0 (paired with find -print0 or similar producers).
  • Avoiding complex shell pipelines where quoting and escaping are hard to reason about.
  • Reduce reliance on hooks for security boundaries; assume that pre-commit automation can fail and back it up with additional review policies.
  • Encourage developers to externalize secrets from working directories entirely (e.g., environment managers, secure secret stores) to minimize damage if staging controls fail.

These patterns help ensure that automation scripts behave safely even in the presence of unexpected or adversarial filenames.

How teams detect issues like this

Detection typically combines code-centric review with repository analysis:

  • Static analysis / script review:
  • Scan shell scripts and hooks for uses of xargs, git add, rm, mv, or similar commands that lack a -- terminator.
  • Flag patterns where filenames are piped or expanded directly into command lines without robust quoting or null-delimited handling.
  • Use linters or custom CI checks focused on shell safety (e.g., enforcing safe xargs usage).
  • Policy enforcement:
  • Enforce repository policies that require manual review of changes to git hooks or automation scripts.
  • Maintain security baselines for pre-commit hooks and reject scripts that violate safe command-construction rules.
  • Repository monitoring:
  • Periodically scan git history for sensitive file patterns (e.g., .env, private keys, secrets) and alert on newly introduced sensitive content.
  • Use secret-scanning tools in CI/CD to catch leaked credentials early.

Automated code review and security tooling can help surface these issues before they make it into widely adopted hooks or templates.

Sources

SourceLink
github.comgithub.com/openclaw/openclaw/commit/b88f37762f5b6d7ec0f589eb761815e466e4ef4b
github.comgithub.com/openclaw/openclaw/commit/ba84b1253967143692166023f9e174c149b6f2ed
github.comgithub.com/openclaw/openclaw/security/advisories/GHSA-mmpf-jwf4-h3qv
vulncheck.comvulncheck.com/advisories/openclaw-option-injection-in-pre-commit-hook-via-malicious-filenames

Frequently asked

questions

Not in the traditional network sense. Exploitation happens in the local development environment when the vulnerable pre-commit hook runs. However, if an attacker can influence the working tree (for example, through a compromised project template, malicious dependency writing files, or shared environment), they may cause other developers to unknowingly stage sensitive files.

The attacker needs the ability to create or rename files in the repository's working directory. In many collaborative or scripted environments, this may be achievable by any contributor, a malicious tool in the toolchain, or a process running as the developer.

The safest fix is to ensure that all command invocations treat filenames purely as data:

  • Always include -- before filename lists in git commands.
  • Use robust quoting and consider null-delimited pipelines for filenames.
  • Refactor the hook so that it does not assemble command lines from raw filenames where possible.

Adopt defensive shell scripting practices and security-focused review for all automation:

  • Treat filenames and other external inputs as untrusted.
  • Standardize patterns like git add -- and xargs -0 in internal guidelines.
  • Integrate linting or static checks for shell and hook scripts into CI.
  • Combine these with secret-scanning and policies that discourage keeping secrets in the repository tree at all.
Find out what's already
exploitable in your codebase.