Add block-no-verify beforeShellExecution hook to .cursor/hooks.json#5839
Add block-no-verify beforeShellExecution hook to .cursor/hooks.json#5839tupe12334 wants to merge 1 commit intoBasedHardware:mainfrom
Conversation
…json Prevents Cursor agents from bypassing git hooks via the hook-skip flag. Closes BasedHardware#5838
Greptile SummaryThis PR adds a Key points:
Confidence Score: 2/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Dev as Developer/Agent
participant Cursor as Cursor IDE
participant Hook as beforeShellExecution Hook
participant npx as npx (npm registry)
participant Shell as Shell
Dev->>Cursor: Run any shell command (e.g. git commit --no-verify)
Cursor->>Hook: Fire beforeShellExecution
Hook->>npx: npx block-no-verify@1.1.2
npx->>npx: Download / resolve package from npm registry
npx->>Hook: Read stdin (command string)
alt --no-verify / -n flag detected in git command
Hook-->>Cursor: exit 2 (block execution)
Cursor-->>Dev: Command blocked
else No flag detected or non-git command
Hook-->>Cursor: exit 0 (allow execution)
Cursor->>Shell: Execute original command
Shell-->>Dev: Command output
end
Last reviewed commit: "feat: add block-no-v..." |
| "hooks": {} | ||
| "hooks": { | ||
| "beforeShellExecution": [ | ||
| { "command": "npx block-no-verify@1.1.2", "event": "beforeShellExecution" } |
There was a problem hiding this comment.
Supply chain risk: self-authored package executed before every shell command
The PR author explicitly discloses they are the maintainer of block-no-verify. This hook runs npx block-no-verify@1.1.2 before every shell execution in Cursor — not just git commands — for all contributors who use Cursor in this repo. This introduces several concerns:
- Conflict of interest: Adding your own npm package as a mandatory hook in a third-party project is a form of self-promotion that deserves extra scrutiny. The package has 1 GitHub star and is maintained solely by the PR author.
- Supply chain risk:
npxdownloads and executes code from the npm registry without a lockfile or integrity hash. A compromised npm account or a malicious package update could execute arbitrary code in every contributor's shell environment. Pinning the version to@1.1.2mitigates version-drift but does not protect against account takeover for the same tag. - Broad execution scope:
beforeShellExecutionfires for every shell command, not justgit commit/git push. This means the npm binary is invoked (and potentially re-fetched) on everyls,echo,python, or other shell call — adding overhead and expanding the attack surface beyond what is necessary.
A safer alternative would be a lightweight, inline shell check that requires no external npm dependency:
{ "command": "sh -c 'echo \"$CURSOR_SHELL_COMMAND\" | grep -qE \"git (commit|push|merge|cherry-pick|rebase|am)\" && echo \"$CURSOR_SHELL_COMMAND\" | grep -qE \"(--no-verify|-n)\" && exit 2 || exit 0'", "event": "beforeShellExecution" }Or, if the team prefers a package-based approach, the package should be vendored/installed locally (added to devDependencies) and run from node_modules/.bin rather than fetched fresh via npx on each invocation.
|
Hey @tupe12334 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! 💜 |
Summary
Fills in the empty
hooksobject in.cursor/hooks.jsonwithblock-no-verify@1.1.2as abeforeShellExecutionhook to prevent Cursor agents from bypassing git hooks.Details
When an agent runs
git commitorgit pushwith the hook-bypass flag, it silently disables pre-commit, commit-msg, and pre-push hooks.block-no-verifyreads the command from the Cursor hook stdin, detects the hook-bypass flag across all git subcommands, and exits 2 to block. Theversion: 1config is preserved unchanged.Closes #5838
Disclosure: I am the author and maintainer of
block-no-verify.