Trusted hook, untrusted code: git pre-commit can execute agent-modified package.json scripts
izgorodin · reddit · 2026-10-31
A DEV discussion on letting agents commit without write access to shared Git config exposed a deeper problem: a trusted hook file doesn't make the code it launches trusted.
- A pre-commit hook can live outside the checkout, but npm test pulls its script from the checkout's package.json — which the agent may have modified, along with the tests.
- Moving the commit outside the agent's environment can therefore move execution of those changes outside it too.
- Demonstrated with stock Git for Windows 2.52.0 and 2.56.0 (test scripts stood in for the agent; no coding-agent sandbox tested). The discussion also corrected an earlier claim that using main's hooks would close the issue.
- Takeaway: when reviewing an agent's diff, trace the commit hook into package scripts and executable config, not just the hook file itself.
More from coding & agent
- Lean 4-derived C code takes #1 in $12 server challenge, beating Rust and assembly — hargup13 · 2026-10-31
- Factory ditches .ai, snags factory.com to pitch agent-native software development — matanSF · 2026-10-31
- Turning Real Jobs into Repeatable AI Pipelines: Think Flowcharts, Then Decision Trees — bytebot · 2026-10-31
- Wild App Lets You Chat With Claude Over Peer-to-Peer Connections, New Build in Review — nathanborror · 2026-10-31
- Replit's autofix turns hosted apps into self-maintaining software — cem2ran · 2026-10-31
- Vibe-coded tools need maintenance: a new 'SaaS' business of managing AI-built software — AccBalanced · 2026-10-31