Skip to content

Security Risk: Aider silently bypasses pre-commit hooks by default (--no-verify) #5376

Description

@QiuYucheng2003

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions