Skip to content
HighSecrets & credentialsBLWK-CRED-002

Git stores passwords and tokens in plain text ​

What this means ​

Git is saving your passwords and access tokens in a plain text file (‹path›). Any program running as you can read it, and a GitHub token usually lets someone push code to your repositories or publish packages in your name.

How to fix it ​

Let Git keep your tokens in your computer's keychain instead of a plain file.

  1. For GitHub, run gh auth setup-git. Git then uses the GitHub CLI's login, which is stored in your keychain.
  2. For other Git hosts, install Git Credential Manager. It works on Linux, macOS and Windows and uses the system keychain.
  3. Stop using the plain-file store: git config --global --unset credential.helper.
  4. Delete ~/.git-credentials and revoke the tokens it contained, in case they were already copied.

Even better: use SSH keys for Git, protected by a passphrase or a hardware key.

Check it yourself ​

Run a scan and look for BLWK-CRED-002 in the results:

sh
bulwark scan

Installed the standalone CLI package instead of the app? The command is bulwarkctl.

How Bulwark decides

Bulwark reads credential_stores and reports this check when:

text
(kind == "git_credentials" and stored_entries > 0) or (kind == "git_config" and helper_store == true)

If a value can't be read, Bulwark reports the check as undetermined rather than passing it. View the rule source.

References ​

Released under the Apache License 2.0.