fix: enforce trusted-before-project ordering for hooks
Closed
VI
6mo ago+540+540+012345678901234567890123456789-26-26-01234567890123456789
Summary
- execute trust-sensitive hook events in trust-precedence tiers so non-project hooks run before project hooks for
PreToolUse,SessionStart, andUserPromptSubmit - preserve parallel execution within each trust tier while skipping lower-precedence project hooks once a higher-precedence hook blocks or stops processing
- add regression coverage for prompt/session hook data exposure so project hooks cannot observe those payloads before higher-trust hooks have a chance to stop processing
Security
- closes the
PreToolUserace where a project hook could observe or exfiltrate a tool invocation before a higher-precedence non-project hook denied it - closes the analogous prompt/session leak where project
UserPromptSubmitorSessionStarthooks could observe prompt or startup data before a higher-precedence hook stopped processing - keeps project hook execution aligned with the trust boundary established by #14718, which prevents untrusted project-local hook config from loading before trust is granted
Stack
- Builds on the #14718 trust-gate work now in
main - This PR enforces trust precedence at hook execution time for hook events that can block or stop downstream processing
- Managed hook policy and enterprise lockdown behavior remain covered by the follow-up managed-hooks PR, not this one
Test
cargo test -p codex-hookscargo test -p codex-hooks higher_precedence_stop_skips_lower_precedence_handlerscargo clippy -p codex-hooks --tests -- -D warningsjust argument-comment-lint -p codex-hooks -- --tests