Skip to main content
Vulnerability Database/CVE-2026-77474

CVE-2026-77474: destructive_command_guard DOS Vulnerability

CVE-2026-77474 is a denial of service flaw in destructive_command_guard that causes exponential-time work through nested substitutions. This post explains its impact, affected versions, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-77474 Overview

destructive_command_guard (dcg) is a command-line safety tool that blocks destructive shell commands before AI coding agents execute them. Versions prior to 0.6.6 contain an algorithmic complexity flaw in the command segment scanner. Nested or unclosed $( and $(( substitutions trigger recursive rescanning of the remaining command suffix, producing exponential-time work. The scanner is reached through split_command_segments in src/packs/mod.rs. When the PreToolUse hook hangs, dcg fails open and the destructive command proceeds unblocked [CWE-400].

Critical Impact

Attackers can bypass the dcg safety guard by appending nested or unclosed substitution sequences to a destructive command, allowing AI coding agents to execute commands that would otherwise be blocked.

Affected Products

  • destructive_command_guard (dcg) versions prior to 0.6.6
  • AI coding agent integrations relying on the PreToolUse hook for command safety validation
  • Environments where dcg is the enforcement layer protecting shell execution by autonomous agents

Discovery Timeline

  • 2026-10-16 - CVE-2026-77474 published to NVD
  • 2026-10-19 - Last updated in NVD database
  • v0.6.6 - Patch released in GitHub Release v0.6.6

Technical Details for CVE-2026-77474

Vulnerability Analysis

The flaw is an algorithmic complexity vulnerability in the command parsing path. split_command_segments in src/packs/mod.rs invokes scanners that recursively descend into shell substitution constructs. When an inner scan returns an unterminated marker, the outer scanner rescans the remaining suffix instead of terminating. Each layer of nesting repeats the work, producing exponential blowup over the input size. The affected code path is unauthenticated at the hook interface — any command dcg evaluates reaches the vulnerable scanner.

Because dcg runs as the PreToolUse hook in front of AI coding agents, the hang does not simply degrade performance. Agent frameworks interpret a stalled or timed-out hook as a non-blocking result and allow the pending shell command to proceed. The guard effectively fails open on crafted input.

Root Cause

The scanner lacks a bounded recursion or depth guard for nested $( and $(( constructs. Unterminated substitutions re-enter the scan loop with overlapping ranges, so time grows exponentially with the number of nested or unclosed sequences. See GitHub Issue #189 Discussion for the maintainer's analysis.

Attack Vector

An adversary who can influence the shell command an AI coding agent attempts to run supplies a destructive command followed by nested or unclosed $( or $(( sequences. dcg enters an exponential scan, the PreToolUse hook times out, and the agent proceeds to execute the destructive command (for example, recursive deletion against the project workspace).

rust
// Patch excerpt from src/cli.rs — thread an authoritative project path
// into evaluation so path-scoped allowlists cannot silently apply globally.
let project_path = std::env::current_dir().ok();
let eval_result = evaluate_command_with_pack_order_deadline_at_path(
    &command,
    enabled_keywords,
    // ...
);
// Source: https://github.com/Dicklesworthstone/destructive_command_guard/commit/ba16bdd074b045329dc0ca6ec9a08c44403cfe1b
rust
// Patch excerpt from src/evaluator.rs — honor an explicit working directory
// for ALL path-aware allowlist matching, not only heredoc content allowlists.
if let Some(path) = project_path {
    return Some(path.to_path_buf());
}

if heredoc_settings
    .content_allowlist
    .as_ref()
// Source: https://github.com/Dicklesworthstone/destructive_command_guard/commit/ba16bdd074b045329dc0ca6ec9a08c44403cfe1b

The commit ships the broader triage batch described as "exponential-hang guard bypass, path-scoped allowlists, heredoc" fixes.

Detection Methods for CVE-2026-77474

Indicators of Compromise

  • PreToolUse hook invocations of dcg that exceed the agent's configured timeout, followed by shell execution of a destructive command (for example rm -rf, dd, mkfs).
  • Shell command strings submitted to the agent containing deeply nested or unclosed $( or $(( sequences, especially appended to known destructive binaries.
  • Spikes in dcg CPU usage correlated with single-command evaluation.

Detection Strategies

  • Alert on PreToolUse hook exit codes indicating timeout or signal termination while a destructive command is in the pending tool call payload.
  • Scan agent prompt and tool-call logs for commands containing unbalanced $( / $(( counts.
  • Compare dcg version strings reported by agent telemetry against 0.6.6 and flag older builds.

Monitoring Recommendations

  • Centralize AI coding agent tool-call logs and PreToolUse hook results for retention and search.
  • Add a wall-clock watchdog around dcg invocations and record every timeout as a security event, not a performance event.
  • Monitor filesystem change rates on project workspaces where coding agents operate for anomalous bulk delete or rewrite activity.

How to Mitigate CVE-2026-77474

Immediate Actions Required

  • Upgrade destructive_command_guard to version 0.6.6 or later on every host where AI coding agents run.
  • Audit agent configurations to ensure the PreToolUse hook is wired to the upgraded binary and not a cached older version.
  • Change the hook policy so that a dcg timeout fails closed — the pending tool call must be denied, not permitted.

Patch Information

The fix is available in version 0.6.6. See the GitHub Security Advisory GHSA-4cfr-w3v5-w5j5 and the GitHub Commit Update for implementation details.

Workarounds

  • If immediate upgrade is not possible, configure the agent to treat any PreToolUse timeout as a blocking failure.
  • Pre-filter candidate shell commands with a lightweight check that rejects strings containing unbalanced $( or $(( sequences before invoking dcg.
  • Restrict the AI coding agent's execution environment with filesystem and capability constraints so a bypass cannot reach high-value paths.
bash
# Upgrade dcg to the patched release
cargo install --locked --version 0.6.6 destructive_command_guard

# Verify the installed version
dcg --version

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.