AI coding agent startup hook abuse - Claude Code / Gemini CLI executing script or download at session start
Detects AI coding agents (Claude Code, Gemini CLI) running a script from an agent or repository folder (.claude, .gemini, .github, .vscode), or a download one-liner, within 30 seconds of the agent starting - the signature of a SessionStart hook firing before the user types a prompt. Correlates with writes to .claude/.gemini settings.json by another process (e.g. git clone, npm postinstall). Verdicts: High (settings.json planted, then executed at session start), Medium (planted, then agent ran script/download), Medium (executed at session start from a pre-existing hook). Covers the technique GTIG reported in its November 2026 AI Threat Tracker (MIDNIGHT NEPTUNE abusing .claude/settings.json to deliver the SOMBERMEME backdoor) and the Mini Shai-Hulud and Miasma worm hooks. Tested in a KQL lab: 3/3 malicious cases detected with correct verdicts, 0 false positives across 5 benign events. Submitted to Microsoft Azure-Sentinel (PR #15755).
Microsoft Sentinel (KQL)
