AGENTCFG-05: Coding Agent Auto-Run Hook Executes Repository Code
๐ด High ยท Coding-Agent Configuration
Detects committed hooks and tasks that run code automatically when a coding agent starts or the folder is opened: Claude Code and Gemini CLI settings hooks (hooks.SessionStart and other events, type "command"), Cursor .cursor/hooks.json, and VS Code .vscode/tasks.json tasks with runOptions.runOn "folderOpen", when the command executes a script stored in the repository (node/bun/python/bash/pwsh on a repo path, or ./script), inline interpreter code (node -e, python -c), or downloads and executes remote code (curl | sh). Hooks that only run installed tools (npx prettier, eslint, echo, git) are not reported, and neither are commands that point at a file the repository does not contain. Severity policy: high for session-start hooks and folder-open tasks (they run before any prompt, with the developer's credentials); medium for hooks on other events (prompt, tool use, stop), which need the developer to use the agent first; critical when the command downloads and executes remote code or the script it runs is a hidden payload (AGENTCFG-06).
Detailsโ
| Field | Value |
|---|---|
| Rule ID | AGENTCFG-05 |
| Severity | High |
| Category | Coding-Agent Configuration |
| Tags | agent-hooks, testmetest, supply-chain |
| Aliases | AGENTHOOK-01, AGENTHOOK-04 |
Remediationโ
Do not run repository scripts from committed session-start hooks or folder-open tasks. Make setup an explicit step (npm run setup, a documented make target), or keep the hook in user-level settings that each developer reviews. Review every hooks entry and .vscode/tasks.json change in code review like CI code, and remove hooks you do not recognise before opening the repository with an agent.
Referencesโ
- Anthropic, Claude Code hooks reference (SessionStart and other hook events)
- Visual Studio Code, Tasks: run behavior (runOptions.runOn "folderOpen")
- GitHub Docs, code search limitations (files larger than 384 KB are not indexed)