v1.6.2 Phase E live: self-hosted Streamable HTTP MCP, inline SEP-1865 MCP App & weekly sidecar. Read the guide

Fail-Safe PreToolUse Hooks

Coldpin ships 3 default-enabled PreToolUse hook groups in root hooks.json backed by pure ES2020 src/hook-core.ts + src/hook.ts → ./lib/hook.mjs. The exact same engine powers the browser Interactive Policy Lab.

AVAILABLE ON: Antigravity >= v1.5.13 Node 18/20/22/24/26 (ES2020)
On this page

Binary-Verified Antigravity Hook Contract

  • Explicit allow pass-through: Benign commands emit {"decision":"allow"} (exit 0) — emitting {} is rewritten to deny by Antigravity's applyPreToolHooks, whereas allow delegates cleanly to default policy without auto-approval.
  • Zero auto-approval tokens: SS-08-HOOK-LEAST-PRIV forbids auto_approve, permissionOverrides, overwrite, allowTool, and any network/subprocess API in both src/hook.ts and src/hook-core.ts.
  • Exit 0 in 100% of paths: Top-level uncaughtException, unhandledRejection, empty stdin, and malformed JSON all emit {"decision":"force_ask",...} and exit 0 to neutralize host fail-open on non-zero exit.
  • Bounded stdin + fast-path edits: Commands over 256 KiB fail closed with deny; legitimate file edits over 256 KiB (up to 8 MiB) scan the first 16 KiB JSON header linearly so large source-code writes never trigger false prompts.

Root hooks.json Configuration

hooks.json (3 enabled PreToolUse groups)
{
  "coldpin-npx-guard": {
    "enabled": true,
    "PreToolUse": [
      {
        "matcher": "run_command|manage_task",
        "hooks": [
          {
            "type": "command",
            "command": "node --no-warnings ./lib/hook.mjs",
            "timeout": 5
          }
        ]
      }
    ]
  },
  "coldpin-config-guard": {
    "enabled": true,
    "PreToolUse": [
      {
        "matcher": "write_to_file|replace_file_content|multi_replace_file_content|write_file|edit_file|sed_file",
        "hooks": [
          {
            "type": "command",
            "command": "node --no-warnings ./lib/hook.mjs",
            "timeout": 5
          }
        ]
      }
    ]
  },
  "coldpin-delegation-guard": {
    "enabled": true,
    "PreToolUse": [
      {
        "matcher": "define_subagent",
        "hooks": [
          {
            "type": "command",
            "command": "node --no-warnings ./lib/hook.mjs",
            "timeout": 5
          }
        ]
      }
    ]
  }
}

Multi-Shell Evasion & Config Tamper Matrix

Mobile view
Vector / CategoryExample InputHook DecisionHook Group
Quoted / escaped / backtick / path-qualified npxn""px evil-pkg, n`px evil, C:\nodejs\npx.cmd evildenycoldpin-npx-guard
Shell wrappers & subshellssh -c "npx evil", cmd /c npx evil, echo $(npx evil)denycoldpin-npx-guard
Alternative runners & remote initializerspnpm dlx, yarn dlx, bunx, corepack, npm init create-xdenycoldpin-npx-guard
Download-and-execute pipes & interactive stdincurl https://... | sh, irm ... | iex, manage_task(send_input)denycoldpin-npx-guard
Exact-pinned Coldpin --ignore-scripts standalonenpx --ignore-scripts coldpin@1.6.2 mcp, npx --yes --ignore-scripts --package=semver@7.7.1 -- semverforce_askcoldpin-npx-guard
Sensitive config edits (all 6 file-edit tools + shell).npmrc, .coldpin.policy.json, hooks.json, mcp_config.json, lib/hook.mjs, agy plugin disableforce_askcoldpin-config-guard
Writable dynamic subagent requestsdefine_subagent({ EnableWriteTools: true })force_askcoldpin-delegation-guard
↑ ↓ Navigate Enter Open Home / End Jump Esc Close