GO KALI FREE

TruffleHog

Vulnerability Analysis

Intermediatelow risk

TruffleHog is an open-source secrets discovery, classification, verification and analysis tool by Truffle Security. It scans Git history, GitHub, filesystems, Docker images, cloud storage and other supported sources for API keys, passwords, private keys and related machine credentials.

Installation

sudo apt install trufflehog

Basic Syntax

trufflehog git <repository-url> --results=verified

Quick Facts

Full Name
TruffleHog
License
AGPL-3.0
Language
Go (v3)
Category
Secret Scanning
Type
Secrets Discovery & Verification
First Released
2017

Tool Overview

TruffleHog v3 is an open-source secrets discovery, classification, verification and analysis tool maintained by Truffle Security. It looks for machine credentials such as API keys, database passwords and private keys across Git repositories, GitHub, GitLab, filesystems, Docker images, S3, Google Cloud Storage and other supported sources. The project classifies more than 800 secret types and has more than 700 detectors capable of checking credentials against real APIs. Use that capability only on assets you own or have explicit permission to assess, because verification may contact the service associated with a discovered credential.

Results are divided into verified, unverified and unknown states. Verified means a live check confirmed that the credential worked, unverified means a candidate was classified but not confirmed, and unknown means verification was attempted but failed because of a network, API or related problem. The default output includes all three states, while `--results` can select the states relevant to a workflow. JSON, legacy JSON for selected repository sources, SARIF and GitHub Actions output support automation, and `--fail` returns exit code 183 when findings are present.

Kali Linux provides TruffleHog through `sudo apt install trufflehog`, and the project also documents Homebrew, Docker, release binaries, an official install script and installation from Go source. A safe first scan uses the public `trufflesecurity/test_keys` demonstration repository rather than an unrelated project. Production use should combine scanning with token protection, scoped authorization, rotation and revocation procedures, output retention controls and repeatable CI checks. TruffleHog discovers exposure; it does not replace the operational response needed to invalidate a leaked credential.

Quick Reference Commands

Verified quick-reference commands for TruffleHog
CommandPurpose
trufflehog git https://github.com/trufflesecurity/test_keys --results=verifiedScan the official demo repo and report only verified live secrets.
trufflehog github --org=<org> --results=verifiedScan every repo in a GitHub org for verified secrets.Add --token to raise GitHub rate limits on large orgs.
trufflehog filesystem <path>Scan files and directories for leaked credentials.
trufflehog docker --image <image> --results=verifiedScan a container image for verified secrets.
trufflehog s3 --bucket=<bucket> --results=verified,unknownScan an S3 bucket for verified and unknown secrets.
trufflehog git file://. --since-commit main --branch feature-1 --results=verified,unknown --failScan only new commits on a branch in CI and fail the build (exit 183) if secrets are found.
TruffleHog READMETruffleHog on Kali Linux

Common Commands

sudo apt install trufflehogInstall the official Kali Linux TruffleHog package.
brew install trufflehogInstall TruffleHog through Homebrew on macOS or Linux.
curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh -s -- -b /usr/local/binInstall the release binary into /usr/local/bin with the official project script.
curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh -s -- -v -b /usr/local/binInstall TruffleHog while verifying the checksum signature with cosign.
git clone https://github.com/trufflesecurity/trufflehog.git && cd trufflehog && go installClone the official source repository and install TruffleHog with Go.
trufflehog --versionPrint the installed TruffleHog version for setup and audit records.
trufflehog --helpDisplay the available TruffleHog sources and global options.
trufflehog git https://github.com/trufflesecurity/test_keys --results=verifiedScan the official authorized demo repository and report secrets verified against their services.
trufflehog git https://github.com/trufflesecurity/test_keys --results=verified --jsonScan the official authorized demo repository and emit one JSON object for each verified result.
trufflehog git file://test_keys --results=verified,unknownScan a local clone of the authorized demo repository and retain verified and unknown results.
trufflehog git file://. --since-commit main --branch feature-1 --results=verified,unknown --failScan an authorized feature branch since main and return exit code 183 when matching results are found.
trufflehog github --org=trufflesecurity --results=verifiedScan repositories in the public Truffle Security organization and report verified results.
trufflehog github --org=trufflesecurity --exclude-archived --results=verifiedScan the public Truffle Security organization while skipping archived repositories.
trufflehog github --repo=https://github.com/trufflesecurity/test_keys --issue-comments --pr-commentsScan the official authorized demo repository together with its issue and pull-request comments.
trufflehog github-experimental --repo https://github.com/trufflesecurity/test_keys.git --object-discoveryRun alpha object discovery against the official authorized demo repository to enumerate hidden or deleted commit objects.
trufflehog gitlab --token=<token>Scan an authorized GitLab scope using the required GitLab token.
trufflehog filesystem path/to/file1.txt path/to/file2.txt path/to/dirScan authorized files and directories, including supported documents, binaries and archives.
trufflehog filesystem . --sarif --no-verification > results.sarifScan the authorized current workspace without live verification and write SARIF output for code-scanning ingestion.
trufflehog docker --image trufflesecurity/secrets --results=verifiedScan the official demonstration image from a remote registry and report verified secrets.
trufflehog docker --image docker://new_image:tagScan an authorized image available through the local Docker daemon.
trufflehog docker --image file://path_to_image.tarScan an authorized Docker image stored as a local tarball.
trufflehog s3 --bucket=<bucket name> --results=verified,unknownScan an authorized S3 bucket and retain verified and unknown findings.
trufflehog s3 --bucket=<bucket name> --role-arn=<iam role arn> --results=verifiedAssume an authorized IAM role while scanning an S3 bucket for verified secrets.
trufflehog s3 --bucket=<bucket name> --include-prefix=src/ --include-extension=envLimit an authorized S3 scan to a literal object prefix and files whose extension is env.
trufflehog gcs --project-id=<project-ID> --cloud-environment --results=verifiedScan an authorized Google Cloud project using its cloud environment and report verified findings.
trufflehog postman --token=<postman api token> --workspace-id=<workspace id>Scan an authorized Postman workspace using its API token and workspace identifier.
trufflehog jenkins --url https://jenkins.example.com --username admin --password adminScan an authorized Jenkins service using credentials supplied for the assessment.
trufflehog elasticsearch --nodes 192.168.14.3 192.168.14.4 --username truffle --password hogScan authorized Elasticsearch nodes with the provided account credentials.
trufflehog huggingface --model <model_id> --dataset <dataset_id> --space <space_id> --bucket <bucket_id>Scan authorized Hugging Face models, datasets, spaces and buckets by identifier.
aws s3 cp s3://example/gzipped/data.gz - | gunzip -c | trufflehog stdinStream authorized decompressed S3 data into TruffleHog through standard input.

Step-by-Step Guide

  1. 1Confirm that the repository, image, bucket or service is yours or is explicitly included in written authorization before scanning it.
  2. 2Install TruffleHog with Kali APT, Homebrew, the official install script, Docker, a release binary or the documented Go source route.
  3. 3Run trufflehog --version and trufflehog --help so your notes match the installed build and its supported sources.
  4. 4Begin with the official trufflesecurity/test_keys demo repository and request verified results before scanning an internal source.
  5. 5Choose the source subcommand that matches the asset, such as git, github, filesystem, docker, s3 or gcs.
  6. 6Select result statuses deliberately because verified, unverified and unknown findings represent different levels of confirmation.
  7. 7Use JSON, SARIF or GitHub Actions output for automation, and use --fail when a pipeline must return exit code 183 after finding a result.
  8. 8Revoke or rotate exposed credentials, remove them from active systems and history where appropriate, then rescan the authorized source.

Use Cases

Git History Secret Scanning

Inspect the full history of a repository you own or are authorized to assess for committed API keys, passwords and private keys. Commit, file and line metadata helps responders locate the exposure and begin rotation.

GitHub Organization Review

Scan authorized GitHub organizations or repositories and optionally include issue and pull-request comments. Authentication reduces rate-limit pressure and allows access appropriate to the approved scope.

Docker Image Scanning

Inspect authorized remote images, local-daemon images or image tarballs for credentials copied into layers or application content. Verified findings should trigger credential rotation and an image rebuild.

Cloud Storage Auditing

Search approved S3 buckets and Google Cloud projects for secrets stored in objects, archives and environment files. Prefix and extension controls can narrow an S3 review to the agreed data set.

CI/CD Secret Detection

Run TruffleHog in GitHub Actions, GitLab CI or another authorized pipeline and use exit code 183 to block changes containing findings. JSON or SARIF can feed review and code-scanning systems.

Credential Incident Response

Use verified status and supported credential analysis to prioritize exposed credentials that are still live. Responders can revoke or rotate the credential, remove its exposure and rescan the authorized source.

Key Features

Best Practices

Common Errors

GitHub rate limits during an unauthenticated scan
Use a protected personal access token with the documented --token option when authenticated scanning is authorized.
Exit code 183 when results are found
Treat 183 as a findings-detected condition; reserve exit code 1 for an error and 0 for no errors with no results.
Banner only and then exit
Confirm the authorized source selection and test the installation against the official trufflesecurity/test_keys demo repository.
Invalid GitHub token
Replace it with a valid personal access token authorized for the intended GitHub scope and keep it out of logs.
GitLab token required
Supply a valid authorized token with trufflehog gitlab --token=<token>.
Mounted path is not available in the Docker container
Use the documented -v "$PWD:/pwd" volume mount and confirm that the authorized files are referenced through the mounted location.
Secret omitted because of trufflehog:ignore
Review the suppression and use --no-ignore-tag during an authorized audit when ignored findings must be reported.
Verification status is unknown
Retain the finding for triage and repeat verification only when the service is reachable and the assessment permits it.

People Also Ask

What is TruffleHog used for?

TruffleHog finds and classifies machine credentials such as API keys, database passwords and private keys across Git, Docker, filesystems, cloud storage and other supported sources.

How do I install TruffleHog on Kali Linux?

Install the official Kali package with sudo apt install trufflehog, then verify the executable with trufflehog --version.

How does TruffleHog verify secrets?

TruffleHog can test supported credentials against their real APIs; accepted credentials are verified, detected but unconfirmed candidates are unverified, and failed verification attempts are unknown.

How do I scan Git history with TruffleHog?

Use the Git source on the official demo repository or a repository you own or are authorized to scan, and select the required result states with --results.

What does TruffleHog exit code 183 mean?

Exit code 183 means --fail was enabled and results were found without a scan error; it should be handled as a secret-detection outcome in CI.

Is TruffleHog better than Gitleaks?

TruffleHog offers broader source coverage and live verification, while Gitleaks is a lighter Git-focused option often suited to pre-commit checks.

Related Tools

Nuclei

Vulnerability Analysis

Nuclei is used to send requests across targets based on templates, allowing zero false positives and providing rapid scanning over large infrastructure footprints.

theHarvester

Information Gathering

theHarvester is a comprehensive OSINT tool for gathering email addresses, subdomains, employee names, open ports, and banners from public sources including search engines, PGP key servers, Shodan, and DNS databases for passive reconnaissance and attack surface mapping.

Hashcat

Password Attacks

Hashcat is the world's fastest and most advanced password recovery utility, supporting five unique modes of attack for over 300 highly optimized hashing algorithms. It leverages GPU power for incredible speed.

OpenVAS

Vulnerability Analysis

OpenVAS (Open Vulnerability Assessment System) is a full-featured vulnerability scanner providing a comprehensive architectural network engine that checks endpoints against thousands of active vulnerability feeds.

SSLScan

Vulnerability Analysis

SSLScan queries SSL/TLS services (such as HTTPS) to determine supported ciphers, key exchanges, and security flaws like Heartbleed or broken protocol configurations.

Lynis

Vulnerability Analysis

Lynis is a battle-tested security auditing tool for systems running Linux, macOS, or Unix-based operating systems. It performs an in-depth local scan to discover security weaknesses, configuration flaws, and system hardening opportunities.

Related Cybersecurity Guides

OSINT · Intermediate

Amass Guide: Open Source Attack Surface Mapping

Learn to use Amass for comprehensive attack surface mapping including DNS enumeration, subdomain discovery, integration with APIs, and visualizations.

Active Directory · Advanced

BloodHound Guide: Mapping Active Directory Relationships

Learn how to use BloodHound and SharpHound for Active Directory reconnaissance, attack path analysis, privilege escalation detection, and security assessment.

Tools · Beginner

Dirb Guide: Web Content Scanner

Learn Dirb for web content discovery and directory brute-forcing with wordlist-based scanning, file extension detection, and security assessment.

OSINT · Beginner

DNS Enumeration Guide: Complete Domain Reconnaissance

Master DNS enumeration techniques from basic queries to advanced zone transfers, subdomain brute forcing, and DNS security assessment using Kali Linux tools.

Frequently Asked Questions

What is TruffleHog used for?

TruffleHog is a secrets discovery, classification, verification and analysis tool. It searches authorized Git history, GitHub organizations and repositories, filesystems, Docker images, cloud storage and other supported systems for machine credentials such as API keys, database passwords and private keys. It classifies more than 800 secret types and uses more than 700 detectors that can verify many findings against their real APIs. Its main security use is finding exposed credentials early enough to revoke, rotate and remove them.

How do I install TruffleHog on Kali Linux?

On Kali Linux, install the official package with `sudo apt install trufflehog`, then confirm the executable with `trufflehog --version`. Homebrew, Docker, the official installation script, GitHub release binaries and a Go source installation are also documented options. Use one managed route where possible so the binary found on PATH is predictable. Before the first internal scan, test the setup against the official `trufflesecurity/test_keys` demo repository.

How does TruffleHog verify secrets?

For a classified secret, TruffleHog can contact the associated service and attempt authentication to determine whether the credential is live. A successful check produces a verified result. If a candidate is detected but not confirmed, it is unverified; if verification was attempted but failed because of a network or API problem, it is unknown. Live verification sends credential material to the relevant verifier, so only scan assets and credentials you are authorized to test.

What is the difference between verified, unverified and unknown results?

Verified means the relevant API or authentication mechanism accepted the credential. Unverified means a detector classified a candidate but TruffleHog did not confirm that it was usable. Unknown means verification was attempted but could not be completed, commonly because of a network or API failure. The default result selection includes all three statuses, while a command such as `--results=verified` requests only confirmed findings.

How do I scan Git history with TruffleHog?

Use the `git` source on a repository you own or are authorized to assess. The official safe example is `trufflehog git https://github.com/trufflesecurity/test_keys --results=verified`. For an authorized change range in CI, `trufflehog git file://. --since-commit main --branch feature-1 --results=verified,unknown --fail` compares the feature branch with main. Local repositories are cloned to a temporary directory first for safety unless the documented trusted-local configuration behavior is deliberately selected.

Why does a TruffleHog GitHub scan hit rate limits?

GitHub permits unauthenticated access, but broader scans can hit API rate limits. Supply a valid personal access token with the documented `--token` option when scanning an authorized GitHub scope that needs authenticated API access. Keep the token out of command logs, screenshots and CI output, and grant only the access required by the approved scan. An invalid token must be replaced before authenticated collection can continue.

Why does TruffleHog show only the banner and no findings?

If TruffleHog displays its banner and then exits, the documented explanation is that no secrets were detected. Confirm that the intended source and path were supplied, and verify that a Docker run mounted the host directory into the container when scanning local files. Do not interpret an empty result as proof that a repository is safe, because detector coverage and source selection still matter. Test the installation against the official authorized demo repository before troubleshooting an internal scan.

What does TruffleHog exit code 183 mean?

Exit code 183 is expected only when `--fail` is enabled and the scan finds one or more results without otherwise failing. It lets CI distinguish a detected secret from both a clean scan and an execution error. Exit code 0 means there were no errors and no results, while exit code 1 means an error occurred. Configure the pipeline to treat 183 as a secret-detection condition rather than mislabeling it as a scanner crash.

TruffleHog vs Gitleaks — which should I use?

Gitleaks is the closest alternative secret scanner. TruffleHog verifies secrets live against APIs and covers more sources, including cloud services, Docker images and service integrations, while Gitleaks is lighter and often faster for pre-commit or Git-only scanning. Choose TruffleHog when live verification and broad source coverage matter, and consider Gitleaks when a compact Git-focused check is the priority. Some teams use both at different stages, but either tool still requires authorization and a credential-response process.

How do I scan a Docker image with TruffleHog?

Use the `docker` source to inspect an authorized image from a registry, local daemon or tarball. The official demonstration command is `trufflehog docker --image trufflesecurity/secrets --results=verified`; local-daemon and tarball forms use `docker://new_image:tag` and `file://path_to_image.tar`. This source scans image content rather than merely running TruffleHog inside a container. When the scanner itself runs in Docker, mount the host directory correctly or local files will not be visible inside the container.

How do I use TruffleHog in CI or GitHub Actions?

In CI, scan the authorized checkout with `trufflehog git file://. --since-commit main --branch feature-1 --results=verified,unknown --fail`. A GitHub Actions checkout needs `fetch-depth: 0` so the relevant history is present, and the official action accepts `extra_args: --results=verified,unknown`. For code-scanning ingestion, generate SARIF with `trufflehog filesystem . --sarif --no-verification > results.sarif` and upload it through the platform's SARIF workflow. Protect output artifacts and teach the job that exit code 183 means findings were detected.

How does the trufflehog:ignore comment work?

A `trufflehog:ignore` comment on the same line tells TruffleHog to ignore that secret. This can be useful for a reviewed test fixture, but it should not be used to conceal a real credential. The `--no-ignore-tag` flag reports findings even when that comment is present, which is useful for an authorized audit of suppression usage. Document every accepted suppression and periodically confirm that the ignored value cannot authenticate.

What does a verified private key mean in TruffleHog?

For private keys, verified means the key was confirmed usable for SSH or SSL authentication. TruffleHog uses Driftwood technology to verify private keys against GitHub users and TLS certificates. That status is stronger than merely recognizing PEM-like text, but it does not establish who intentionally placed the key in the source. Treat a verified private key as an urgent credential exposure and follow the owner's approved revocation or replacement process.

Is TruffleHog safe and legal to use?

TruffleHog is a legitimate defensive security tool, but a scan can read sensitive history and may send candidate credentials to real services for verification. Use it only on repositories, cloud accounts, images and services you own or have explicit authorization to assess. Define whether live verification is permitted before scanning; use `--no-verification` when policy forbids those checks. Minimize access, protect findings and rotate confirmed credentials instead of attempting any activity beyond the approved validation.

Tags

#secret-scanning#leaked-credentials#git-security#devsecops#ci-cd#api-keys#vulnerability-analysis

Output Explanation

TruffleHog prints a result for each classified credential candidate found in the authorized source. The detector identifies the secret type, while source metadata can identify the repository, commit, file and line that exposed it. A verified result means TruffleHog tested the credential against the relevant service and confirmed that it was accepted. An unverified result matched a detector but was not confirmed as valid, while unknown means verification was attempted but could not be completed because of a network, API or similar verification problem. By default, TruffleHog includes verified, unverified and unknown results; `--results` narrows that set. JSON output emits one object per result, which is convenient for pipelines, while SARIF is designed for code-scanning systems. With `--no-verification`, detection still runs but live API validation is disabled, so the output must not be described as confirmed. A private key marked verified was confirmed usable for SSH or SSL authentication through TruffleHog's private-key verification process. If the tool displays only its banner and exits, no secrets were detected. When `--fail` is present, exit code 183 means the scan completed without an error but found results; exit code 0 means no errors and no results, and exit code 1 means an error occurred. Treat every output artifact as sensitive because it can contain credentials, source locations and repository metadata.

Ethical Usage Notice

This tool is designed for authorized security testing, educational purposes, and legitimate network administration only. Unauthorized access to computer systems is illegal.