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"}(exit0) — emitting{}is rewritten todenyby Antigravity'sapplyPreToolHooks, whereasallowdelegates cleanly to default policy without auto-approval. - Zero auto-approval tokens:
SS-08-HOOK-LEAST-PRIVforbidsauto_approve,permissionOverrides,overwrite,allowTool, and any network/subprocess API in bothsrc/hook.tsandsrc/hook-core.ts. - Exit 0 in 100% of paths: Top-level
uncaughtException,unhandledRejection, empty stdin, and malformed JSON all emit{"decision":"force_ask",...}and exit0to neutralize host fail-open on non-zero exit. - Bounded stdin + fast-path edits: Commands over
256 KiBfail closed withdeny; legitimate file edits over256 KiB(up to8 MiB) scan the first16 KiBJSON 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
| Vector / Category | Example Input | Hook Decision | Hook Group |
|---|---|---|---|
Quoted / escaped / backtick / path-qualified npx | n""px evil-pkg, n`px evil, C:\nodejs\npx.cmd evil | deny | coldpin-npx-guard |
| Shell wrappers & subshells | sh -c "npx evil", cmd /c npx evil, echo $(npx evil) | deny | coldpin-npx-guard |
| Alternative runners & remote initializers | pnpm dlx, yarn dlx, bunx, corepack, npm init create-x | deny | coldpin-npx-guard |
| Download-and-execute pipes & interactive stdin | curl https://... | sh, irm ... | iex, manage_task(send_input) | deny | coldpin-npx-guard |
Exact-pinned Coldpin --ignore-scripts standalone | npx --ignore-scripts coldpin@1.6.2 mcp, npx --yes --ignore-scripts --package=semver@7.7.1 -- semver | force_ask | coldpin-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 disable | force_ask | coldpin-config-guard |
| Writable dynamic subagent requests | define_subagent({ EnableWriteTools: true }) | force_ask | coldpin-delegation-guard |