Skip to main content

Common Misconfiguration

Secrets accidentally committed to Git history, stored in Git configuration files, or exposed through Git hooks and submodules.

Vulnerable Example

Secure Example

Detection Patterns

  • Git credentials URL: https?://[^:]+:[^@]+@.
  • Git config headers: extraHeader\s*=.*Authorization.
  • Credential helpers: helper\s*=\s*store.
  • Submodule URLs with credentials: url\s*=\s*https?://[^:]+:[^@]+@.

Prevention Best Practices

  1. Use SSH keys instead of HTTPS with passwords.
  2. Implement git-secrets or similar tools.
  3. Use credential managers, not credential store.
  4. Scan Git history for secrets before pushing.
  5. Setup pre-commit hooks for secret detection.
  6. Use .gitignore properly.
  7. Implement branch protection rules.
  8. Regular audit of Git configuration.
  9. Use signed commits.
  10. Clean Git history when secrets are found.