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 { isHookCommandDisabled, type PluginExtendedConfig } from "./config-loader"
|
||||
|
||||
const USER_PROMPT_SUBMIT_TAG_OPEN = "<user-prompt-submit-hook>"
|
||||
@@ -82,8 +82,9 @@ export async function executeUserPromptSubmitHooks(
|
||||
for (const hook of matcher.hooks) {
|
||||
if (hook.type !== "command" && hook.type !== "http") continue
|
||||
|
||||
if (hook.type === "command" && isHookCommandDisabled("UserPromptSubmit", hook.command, extendedConfig ?? null)) {
|
||||
log("UserPromptSubmit hook command skipped (disabled by config)", { command: hook.command })
|
||||
const hookName = getHookIdentifier(hook)
|
||||
if (isHookCommandDisabled("UserPromptSubmit", hookName, extendedConfig ?? null)) {
|
||||
log("UserPromptSubmit hook command skipped (disabled by config)", { command: hookName })
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user