Git development
 help / color / mirror / Atom feed
* [RFC/PATCH] Suggestion: Safe Hook Verification for Unzipped/Local Repositories
@ 2026-06-13 21:20 Jamison Phillips
  2026-06-13 21:53 ` brian m. carlson
  0 siblings, 1 reply; 2+ messages in thread
From: Jamison Phillips @ 2026-06-13 21:20 UTC (permalink / raw)
  To: git

Hello Git Community,

I would like to propose a defensive security enhancement regarding how
Git handles hooks in repositories initialized outside of standard 'git
clone' pathways (such as repositories downloaded and extracted via
ZIP/tarball archives).

---
THE PROBLEM:
When a user clones a repository, Git safely excludes the '.git/hooks'
directory. However, if a developer downloads a project as a ZIP
archive from an untrusted third party and extracts it, the archive can
contain a fully formed '.git/hooks' directory populated with
malicious, executable scripts.

The moment the developer runs a standard command like 'git checkout'
or 'git status' inside this unzipped folder, the hooks execute
immediately without user consent or awareness. This is an active
vector for supply-chain malware insertion on developer workstations.

---
PROPOSED FEATURE:
I suggest implementing a "Safe Hook Verification" mechanism with the
following logic:

1. First-Time Intercept: If Git detects executable scripts inside
'.git/hooks' on a repository that does not have an explicit local
clearance, it should halt execution and prompt the user: "Warning:
This repository contains local hooks that have not been approved. Run
them? (y/N)".

2. Out-of-Directory Verification State: If the user approves ('y'),
Git should log this approval by saving a unique cryptographic hash of
the approved hooks to a global state directory outside of the
repository's working tree (e.g., inside
~/.config/git/approved_hooks/).

3. Subsequent Runs: On future commands, Git will check the current
hooks against the global hash map. If they match, they run silently.
If a hook file is modified or a new repository is unzipped, the prompt
appears again.

---
IMPACT:
This would close a massive blind spot for developers interacting with
shared zipped codebases, enforcing a model of explicit consent before
third-party code is executed locally by the VCS.

I look forward to hearing your thoughts on the feasibility or
alternative architectures for this defense-in-depth feature.

Regards,
Jamison Phillips

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-13 21:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-13 21:20 [RFC/PATCH] Suggestion: Safe Hook Verification for Unzipped/Local Repositories Jamison Phillips
2026-06-13 21:53 ` brian m. carlson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox