Introduction
Searching for secrets such as passwords, authentication tokens, API keys, AWS keys, etc. in Git repositories is of crucial importance for several reasons linked to IT security and the protection of sensitive data:
Protecting sensitive information: Secrets, such as passwords and API keys, are used to access sensitive resources or specific services. If they are exposed publicly in a Git repository, this can lead to potential security breaches and compromise data confidentiality and integrity.
Attack prevention: Hackers actively seek out secrets exposed in Git repositories to gain illegal access to sensitive systems and data. Proactively searching for these secrets helps prevent potential attacks before they happen.
Security compliance: Numerous security regulations and standards, such as the RGPD (General Data Protection Regulation), require organizations to take steps to protect sensitive information. Detecting and properly managing secrets exposed in Git repositories is essential to comply with these requirements.
Protecting cloud service access keys: Cloud service access keys, such as AWS keys, are used to access an organization’s cloud resources and services. Exposing these keys in Git repositories can result in high costs due to unauthorized use of cloud services.
Securing open source projects: Many open source projects are hosted on version control platforms such as GitHub. Searching for secrets in these projects is essential to ensure their security and prevent malicious actors from exploiting vulnerabilities.
Developer security awareness: By actively searching for secrets in Git repositories, developers are made aware of the risks associated with the accidental inclusion of sensitive information in source code. This encourages them to adopt good secret management practices.
Some tools are used to hunt that kind of secrets. Here are 3 tools on which I will focus :
NoseyParker
NoseyParker is an open source tool designed to search and identify sensitive information and secrets in public code repositories on GitHub. It is primarily a code scanning tool that seeks to detect private information that may be inadvertently exposed in public source code. Although NoseyParker is useful for public repositories, it is not suitable for private repositories or other version control systems.
GitLeaks
GitLeaks is another popular open source tool used to search for secrets and sensitive information in Git repositories. It supports both public and private repositories, making it more versatile than NoseyParker. GitLeaks works by performing a static analysis of Git repositories to detect potentially exposed passwords, API keys, authentication tokens and other sensitive information. Detection rules can also be customized to suit the specific needs of each project.
TruffleHog
TruffleHog is an open source security tool designed specifically to detect sensitive secrets that might be exposed in Git repositories. It performs an in-depth search of the entire repository history, enabling it to find sensitive information even if it has been removed from the current code. TruffleHog is capable of detecting a wide range of sensitive information, including encryption keys, passwords, API keys and other types of secrets. It is particularly useful in collaborative development environments where several people may contribute to the code and accidentally introduce sensitive information.
Installation
All tools are installed by using asdf (TBD). More installations possibities are given in detail, for each applications.
NoseyParker
The installation can be done with pre-built binaries, docker images or from source.
Results are stored in a datastore, a SQLite database.
Scan
| |
An example of output returned by that command
| |
Reporting
Multiple output formats are available : human, json, jsonl and sarif (Static Analysis Results Interchange Format).
| |
The output of the report, in an human format,
| |
Pros / Cons
- Pros:
- Time to scan. Here is an example
| |
- Cons: TBC
Issues I met
TBD
Gitleaks
Pros / Cons
TBD
Issues I met
TBD
TruffleHog
Pros / Cons
TBD
Issues I met
TBD
