Security Risk: Aider silently bypasses pre-commit hooks by default (--no-verify)
### Issue
Description:
Aider currently bypasses all local pre-commit hooks (such as SAST scanners, secret leakage detectors, and code formatters) when automatically committing code. This behavior is silent and defaults to bypassing, which poses a security risk for repositories relying on pre-commit checks.
Root Cause Analysis:
Upon reviewing the source code, the issue stems from the default configuration in aider/args.py:
group.add_argument(
"--git-commit-verify",
action=argparse.BooleanOptionalAction,
default=False, # <--- Defaults to bypassing hooks
help="Enable/disable git pre-commit hooks with --no-verify (default: False)",
)
This False value is passed to GitRepo during initialization. Consequently, in aider/repo.py (within GitRepo.commit), the --no-verify flag is unconditionally appended to the underlying git command:
if not self.git_commit_verify:
cmd.append("--no-verify")
Security Impact:
If the LLM generates flawed or malicious code (e.g., via prompt injection from a parsed GitHub Issue or URL) or accidentally includes hardcoded API keys, Aider will bypass the repository's preset security defenses. The harmful code is then pushed directly into the git history without warning.
Proposed Solution:
Change the default value of --git-commit-verify to True in aider/args.py. Bypassing security hooks should be an explicit user opt-in, rather than the default behavior.
### Version and model info
Aider version: Latest `main` branch (Identified via static source code analysis)
Model: N/A (Static Code Analysis)
Git repo: N/A
Repo-map: N/A
0 条评论