fix(hooks): prevent SSRF via URL scheme validation and extend disable mechanism to HTTP hooks
- Restrict HTTP hook URLs to http: and https: schemes only (blocks file://, data://, ftp://) - Extend hook disable config to cover HTTP hooks by matching against hook URL identifier - Update all 5 hook executors (pre-tool-use, post-tool-use, stop, pre-compact, user-prompt-submit) - Add 6 new tests for URL scheme validation (file, data, ftp rejection + http, https, invalid URL)
This commit is contained in:
@@ -4,7 +4,7 @@ import type {
|
||||
ClaudeHooksConfig,
|
||||
} from "./types"
|
||||
import { findMatchingHooks, log } from "../../shared"
|
||||
import { dispatchHook } from "./dispatch-hook"
|
||||
import { dispatchHook, getHookIdentifier } from "./dispatch-hook"
|
||||
import { getTodoPath } from "./todo"
|
||||
import { isHookCommandDisabled, type PluginExtendedConfig } from "./config-loader"
|
||||
|
||||
@@ -70,8 +70,9 @@ export async function executeStopHooks(
|
||||
for (const hook of matcher.hooks) {
|
||||
if (hook.type !== "command" && hook.type !== "http") continue
|
||||
|
||||
if (hook.type === "command" && isHookCommandDisabled("Stop", hook.command, extendedConfig ?? null)) {
|
||||
log("Stop hook command skipped (disabled by config)", { command: hook.command })
|
||||
const hookName = getHookIdentifier(hook)
|
||||
if (isHookCommandDisabled("Stop", hookName, extendedConfig ?? null)) {
|
||||
log("Stop hook command skipped (disabled by config)", { command: hookName })
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user