T06 · System Persistence
- Location
references/04-emergency.md:120- Finding
Persistent Git Hook Automatically Pushes Repository Content
- Content
View full analysis
/dev/null || true' > .git/hooks/post-commit chmod +x .git/hooks/post-commit ``` ### Technical Analysis The documented command creates an executable Git `post-commit` hook. The hook persists in the repository metadata after the current skill or agent session ends and runs automatically after every subsequent commit. Each invocation pushes the current branch to the repository's configured `origin`. The command redirects standard error and uses `|| true`, concealing transmission failures and making the behavior less visible to the user. Although the destination is not hard-coded and the stated purpose is recovery, the mechanism creates persistent automated behavior and initiates network transmission without requiring confirmation for each push. If the remote is incorrectly configured, compromised, or later changed, repository content could be sent to an unintended destination. ### Attack Path 1. A user or agent follows the disaster-recovery instructions. 2. The command writes an executable hook to `.git/hooks/post-commit`. 3. The hook remains active across future sessions. 4. A developer creates a later commit containing source code, configuration, or accidentally committed credentials. 5. Git automatically invokes the hook. 6. The hook pushes the current branch to the configured `origin` without a separate confirmation. 7. If `origin` is controlled by an unauthorized party, the committed data is disclosed to that party. ### Impact Assessment The hook executes with the privileges of the user performing the commit and inherits that user's Git credentials and network access. It does not independently elevate system privileges, but it can use existing re ...[truncated 271 chars]- Remediation
View remediation
/dev/null || true`; preserve errors so users can detect unexpected behavior. - Restrict automated pushes to a dedicated backup remote and protected branch rather than implicitly trusting `origin`. - Provide a cleanup command for existing installations: ```bash rm -f .git/hooks/post-commit ``` ]]>
