AppSecNews
Secret Scanning Open source Established

git-secrets

by AWS Labs

Shell-based git hook that refuses commits matching a configured set of credential patterns, with built-in rules for AWS access keys.

Visit github.com (leaves AppSecNews, opens in a new tab) Leaves AppSecNews for the vendor's own site.

No endorsements yet

Run git-secrets in production? A named recommendation helps the next team shortlisting it.

Recommend this tool

Endorsers verify their identity through LinkedIn. Titles and companies are self declared, shown as they were when each person signed, and reviewed by an editor before anything is published. Endorsements are never paid for.

What we still need to verify : 2 points in this profile are not yet confirmed against vendor documentation.
  • Current maintenance status and release cadence: confirm against repository activity
  • Windows support details beyond a bash environment: confirm against README

Treat these points as unconfirmed. They are open items in the catalog's verification queue, and this note stays until each is checked against the vendor's documentation.

What it does

git-secrets is a shell script that installs into a repository's git hooks and refuses a commit when the change matches a prohibited pattern. It registers three hooks: pre-commit for the staged diff, commit-msg for the message text, and prepare-commit-msg for merge commits. Matching is plain regular expressions against the added lines, run through git grep, so it is fast and needs no runtime beyond git and a POSIX shell.

Patterns live in git config, per repository or globally, under secrets.patterns, with a parallel secrets.allowed list of exceptions and a secrets.providers mechanism for commands that emit patterns dynamically. The --register-aws command loads a prepared set covering AWS access key IDs, secret key shapes and account identifiers, and can pull the account IDs out of your local credentials file so your own accounts are caught by number. A --scan-history flag runs the same patterns across every commit, which is how you check whether the problem you are now preventing already happened.

Where it fits

This lives entirely on the developer laptop, at the last moment before code leaves the working copy. Developers install it via git secrets --install in each clone, or through a templated git init directory so new clones pick it up. Security teams can ship a standard global pattern file. Nothing central sees the results, so it is a prevention control rather than a reporting one, and it only helps where someone remembered to install it.

Strengths

  • Almost no dependencies. A shell and git are enough, making it deployable in restricted environments where installing a language runtime is a conversation.
  • The AWS provider is useful out of the box, matching your own account identifiers rather than only generic key formats.
  • Configuration is git config, so patterns travel with existing tooling and can be templated across an organization.

Limitations

  • Pure regular expressions with no entropy analysis, so a random credential with no recognizable prefix passes through.
  • Hooks are local and advisory. Any developer can pass --no-verify, and a clone without the hook installed is unprotected, which means you cannot treat it as a control you can evidence.
  • Development has been quiet for a long stretch, so expect to carry your own patterns rather than inherit coverage for newer providers, and expect the allowed-patterns list to become a maintenance burden.

Who it suits

Teams invested in AWS who want a zero-friction local guardrail, and anyone needing a hook that works where a heavier toolchain will not install. It is not sufficient alone for an organization that needs centralized detection, verified findings or an audit trail, and belongs underneath a server-side scan rather than in place of one.

Used git-secrets? Recommend it under your own name and title.

Recommend this tool