Skip to content
Detectors

Scanner deep dive

Overview

Private keys are used for securely connecting and authenticating to various systems and services. Exposure of private keys can lead to unauthorized access and data breaches.
From the detector’s Description() in source

Needs a person to check

Provider and detector details

Summary

ProviderNo provider details added yet.

Runs on any connection. Triggered by keywords in the content, after decoding.How TruffleHog works

How detection works

The Private Key detector looks for a single value in text that resembles a credential. It uses the word “private key” to narrow its search.

Runs by default

Matching rules and source
Keywords
  • private key

Regex

  • RegexkeyPat

    (?i)-----\s*?BEGIN[ A-Z0-9_-]*?PRIVATE KEY\s*?-----[\s\S]*?----\s*?END[ A-Z0-9_-]*? PRIVATE KEY\s*?-----

How it works

  1. Skips any text that doesn’t contain “private key”. This keeps scanning fast.
  2. Looks for text matching its pattern.
  3. Values are trimmed before use.
  4. Drops matches that look like known non-secrets (1 rule).
  5. Reports each remaining match as a possible Private Key credential. It isn’t known to work until it’s verified.
MustCompile
One value
Guards against false matches
Not found in source

Known false positives:

  • aaron1234567890123
  • encrypted
  • cracked_encryption_passphrase
Pairing and normalization
  • values are trimmed before use

How it behaves

What this detector does at each step of the TruffleHog pipeline.

pkg/detectors/privatekey · Scanner

Keywords

Any one of these in the decoded text wakes the detector.

  • private key

privatekey.go line 48 (opens TruffleHog source on GitHub)

Behavior

Multi-part
No
Match window
512 bytes before and 4096 after a keyword
privatekey.go line 54 (opens TruffleHog source on GitHub)
Custom endpoints
No
Cloud endpoint
None
Randomness check
None in this detector's own code

Verification. When a scan allows it, TruffleHog tests a match by calling the provider. A scan can turn this off for every detector or for this one. Atlas only describes this; it never tests credentials. How the verify decision works

Analyzer.Privatekey Analyzer

In short

Wakes on “private key”, reads 512 bytes before and 4096 after each hit and tests matches with the provider. A default scan runs it.

How verification works

What it means

Sends GET to keychecker.trufflesecurity.com.

The detection and verification evidence on this page comes from the Open Source implementation. Check the Enterprise coverage guide for product availability.

Does checking a key change anything at the provider?

Not expected to: it’s a GET request, which reads without changing anything, and the source declares no changes.

Source says: GET as declared in source; mutating side effects not declared

Verification walkthrough

How it works

  1. Sends a GET to keychecker.trufflesecurity.com.
  2. Puts the found credential in the request: the parsed private key is used as an SSH public-key auth method.
  3. If the request can’t reach the provider, the result is an error, not a rejection.

Evidence from source

Endpoint

https://keychecker.trufflesecurity.com/fingerprint/%s

privatekey.go:225 (opens TruffleHog source on GitHub)

Key is sent as

SSH public key

How responses are judged

Not found in source

Troubleshoot this check

If a result looks wrong, work through these steps. They’re built from the request and status rules above. The Atlas doesn’t send anything.

1. Send the same request yourself

No command for this check. How the key is sent isn't recorded in a form that can be turned into a command.

Rule: unknown-auth. Key placement as recorded: SSH public key.

2. Likely causes

  • The scanner couldn't reach the provider. The scanner needs outbound HTTPS access to keychecker.trufflesecurity.com. A firewall, proxy or DNS problem is reported as an error, not a rejection, and the key can be checked again.

3. Check the provider’s docs

4. Still stuck

Report it to TruffleHog

Include the status code and response you got. Never include the key.

Errors, timeouts and rate limits
Not found in source
Not found in source
SetVerificationError

transport errors return a verification error

All URLs found in source

  • https://crt.sh/?q=%s
  • https://keychecker.trufflesecurity.com/fingerprint/%s
  • https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints
  • https://docs.gitlab.com/ee/user/gitlab_com/index.html#ssh-host-keys-fingerprints
Provider response documentation

Verified findings

Open Source · Standard output (stdout)

The CLI prints verified findings to stdout. Use --json for structured output.

Example scan output · credential redacted

✅ Found verified result 🐷🔑
Detector Type: PrivateKey
Decoder Type: PLAIN
Raw result: [redacted]
Terminal printer source
CI formats

With --github-actions, GitHub Actions displays this workflow command as a warning on the indicated file and line.

::warning file=config/example.env,line=8,endLine=8::Found verified PrivateKey result 🐷🔑
GitHub Actions printer source

Legacy compatibility. --json-legacy writes pre-v3 JSON for Git, GitLab, and GitHub sources only.

Enterprise alerts

When Enterprise verifies that a secret is live, a configured notifier can alert your team. The finding is also available through the Enterprise API.

Optional analysis

What the analyzer checks

In Open Source, run trufflehog analyze separately from the scan. Enterprise runs enabled self-discovery analyzers on first discovery of a supported live secret.

pkg/analyzer/cli.go registers this detector key to the analyzer package.

How it works

  1. Runs after the detector reports the match as verified.
  2. Evaluates what the credential may be able to access using the analyzer’s own checks or rules.
  3. Reports what it finds. Its source lists 17 permissions in 1 group and 2 resource types.

Rotation resources

Atlas has no rotation guide for this detector.

Token types

TruffleHog’s source doesn’t name a token type or require a fixed prefix for this detector.

Pages TruffleHog’s source links to (2)

Coverage in other scanners

4 scanners have a confirmed match.

Changes

1 recorded change since Sep 18, 2026; 1 still needs review.

  1. What this change means

    Source files changed. The change could not be classified.

    pkg/detectors/privatekey/cracker.go+28−2View file
    @@ -2,9 +2,11 @@ package privatekey
    22
    33import (
    44 "bytes"
    5added: "context"
    56 "crypto/x509"
    67 _ "embed"
    78 "errors"
    9added: "fmt"
    810
    911 "golang.org/x/crypto/ssh"
    1012)
    @@ -19,10 +21,34 @@ func init() {
    1921
    2022var (
    2123 ErrUncrackable = errors.New("unable to crack encryption")
    24added: // ErrKDFTooExpensive is returned without attempting any passphrase when a
    25added: // key's KDF is more expensive than the crack budget allows.
    26added: ErrKDFTooExpensive = errors.New("key KDF is too expensive to crack")
    2227)
    2328
    24removed: func Crack(in []byte) (any, string, error) {
    25removed: for _, passphrase := range passphrases {
    29added: // maxCrackRounds caps the bcrypt KDF round count this detector will attempt
    30added: // to crack. The round count is chosen by whoever created the key and the KDF
    31added: // cost is linear in rounds; OpenSSH's default is 16. 256 is 16x that default:
    32added: // a single wrong guess on a key at the cap costs on the order of a second of
    33added: // CPU, so a wordlist crack is hopeless within any bounded budget. x/crypto
    34added: // refuses round counts above 2048 on its own; this lower cap keeps
    35added: // hardened-but-legal keys from making each attempt that expensive. Division
    36added: // of labor: the cap bounds what one attempt can cost, and the context check
    37added: // below bounds the total, where the caller sets a deadline at all.
    38added: const maxCrackRounds = 256
    39added:
    40added: func Crack(ctx context.Context, in []byte) (any, string, error) {
    41added: if rounds, ok := opensshBcryptRounds(in); ok && rounds > maxCrackRounds {
    42added: return nil, "", fmt.Errorf("%w: %d rounds exceeds cap of %d", ErrKDFTooExpensive, rounds, maxCrackRounds)
    43added: }
    44added: for i, passphrase := range passphrases {
    45added: // A wrong passphrase costs a full KDF run whose cost is set by the
    46added: // key's author, so stop between attempts once the caller's context is
    47added: // done. The in-flight attempt cannot be interrupted:
    48added: // ssh.ParseRawPrivateKeyWithPassphrase takes no context.
    49added: if err := ctx.Err(); err != nil {
    50added: return nil, "", fmt.Errorf("stopped cracking after %d of %d passphrase attempts: %w", i, len(passphrases), err)
    51added: }
    2652 parsed, err := ssh.ParseRawPrivateKeyWithPassphrase(in, passphrase)
    2753 if err != nil {
    2854 if errors.Is(err, x509.IncorrectPasswordError) {
    pkg/detectors/privatekey/openssh.go+83−0View file
    @@ -0,0 +1,83 @@
    1added: package privatekey
    2added:
    3added: import (
    4added: "encoding/pem"
    5added: "math"
    6added:
    7added: "golang.org/x/crypto/ssh"
    8added: )
    9added:
    10added: // privateKeyAuthMagic starts the decoded body of every key in the OpenSSH
    11added: // private key format (see PROTOCOL.key in the OpenSSH source distribution).
    12added: const privateKeyAuthMagic = "openssh-key-v1\x00"
    13added:
    14added: // openSSHEncryptedPrivateKey and kdfOpts mirror the wire structs x/crypto
    15added: // parses the same bytes with in ssh/keys.go, so the round count read here is
    16added: // the round count the KDF will actually run at. Keep them in sync with
    17added: // x/crypto's private structs: if the parses ever diverge, the count read
    18added: // here silently stops matching the KDF's cost and keys are over- or
    19added: // under-refused. x/crypto exports no way to read the KDF options, so the
    20added: // header is read in the detector.
    21added: type openSSHEncryptedPrivateKey struct {
    22added: CipherName string
    23added: KdfName string
    24added: KdfOpts string
    25added: NumKeys uint32
    26added: PubKey []byte
    27added: PrivKeyBlock []byte
    28added: // Rest swallows trailing bytes the way x/crypto's copy of this struct
    29added: // does. Without the tag, a key with bytes after PrivKeyBlock would fail
    30added: // to parse here, read as ok=false, and skip the cap check that
    31added: // x/crypto would still apply.
    32added: Rest []byte `ssh:"rest"`
    33added: }
    34added:
    35added: // kdfOpts deliberately has no ssh:"rest" field: that is what makes
    36added: // ssh.Unmarshal reject options blobs carrying trailing bytes, which is the
    37added: // fail-closed path below. Adding one for forward compatibility would
    38added: // silently disarm it.
    39added: type kdfOpts struct {
    40added: Salt string
    41added: Rounds uint32
    42added: }
    43added:
    44added: // opensshBcryptRounds reads the bcrypt round count from an OpenSSH key's
    45added: // header. The decoded key stores the cipher name, KDF name, and KDF options
    46added: // before the encrypted section, so the round count is readable without the
    47added: // passphrase; Crack uses it to refuse keys whose KDF exceeds maxCrackRounds
    48added: // before spending any passphrase attempt.
    49added: //
    50added: // ok=false means the key is not an OpenSSH bcrypt key, and it should be
    51added: // cracked exactly as before. ok=true means the round count is binding,
    52added: // including fail-closed: a bcrypt key whose options blob does not parse
    53added: // returns the maximum round count rather than ok=false, because the key is
    54added: // a bcrypt key and should be refused, not silently cracked. ssh.Unmarshal
    55added: // rejects such a blob as well, so the key could not have been decrypted at
    56added: // any round count.
    57added: func opensshBcryptRounds(pemBytes []byte) (rounds uint32, ok bool) {
    58added: block, _ := pem.Decode(pemBytes)
    59added: if block == nil || block.Type != "OPENSSH PRIVATE KEY" ||
    60added: len(block.Bytes) < len(privateKeyAuthMagic) ||
    61added: string(block.Bytes[:len(privateKeyAuthMagic)]) != privateKeyAuthMagic {
    62added: return 0, false
    63added: }
    64added:
    65added: var w openSSHEncryptedPrivateKey
    66added: if err := ssh.Unmarshal(block.Bytes[len(privateKeyAuthMagic):], &w); err != nil {
    67added: return 0, false
    68added: }
    69added: if w.KdfName != "bcrypt" {
    70added: return 0, false
    71added: }
    72added:
    73added: ok = true
    74added:
    75added: var opts kdfOpts
    76added: if err := ssh.Unmarshal([]byte(w.KdfOpts), &opts); err != nil {
    77added: rounds = math.MaxUint32
    78added: } else {
    79added: rounds = opts.Rounds
    80added: }
    81added:
    82added: return rounds, ok
    83added: }
    pkg/detectors/privatekey/privatekey.go+8−6View file
    @@ -79,13 +79,15 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
    7979 parsedKey, err := ssh.ParseRawPrivateKey([]byte(token))
    8080 if err != nil && strings.Contains(err.Error(), "private key is passphrase protected") {
    8181 s1.ExtraData["encrypted"] = "true"
    82removed: parsedKey, passphrase, err = Crack([]byte(token))
    82added: parsedKey, passphrase, err = Crack(ctx, []byte(token))
    8383 if err != nil {
    84removed: // The key is encrypted and the passphrase could not be
    85removed: // recovered from the wordlist. It still represents a real
    86removed: // exposure (offline-crackable, weak/legacy KDFs, passphrase
    87removed: // often reused or committed nearby), so surface it as an
    88removed: // unverified finding instead of dropping it silently.
    84added: // The key is encrypted but could not be cracked: the
    85added: // passphrase is not in the wordlist, the key's KDF exceeded
    86added: // the crack budget, or the scan context ended first. It still
    87added: // represents a real exposure (offline-crackable, weak/legacy
    88added: // KDFs, passphrase often reused or committed nearby), so
    89added: // surface it as an unverified finding instead of dropping it
    90added: // silently.
    8991 s1.SetVerificationError(err, token)
    9092 results = append(results, s1)
    9193 continue

Source

Every fact on this page was parsed from trufflesecurity/trufflehog at 2325546, unless a row below says otherwise.

2325546
2921dcc
Parser
trufflehog-detectors-analyzers-v12
Extraction
intel-detector-v7

14 of 28 evidence rows need attention

Evidence rows that need attention
FieldStatusValueSource
lastSeenAt2026-11-25T16:33:44.855ZNo citation
rotationGuideNone extractedFile
verify.httpMethodsNone extractedFile
verify.statusCodesNone extractedFile
timeoutNone extractedFile
rateLimitNone extractedFile
verification.authenticationMethodssh loginParser confidence: mediumFile
verification.expectedStatuses.verified{"statuses":[],"names":["ssh"],"outcome":"verified"}Parser confidence: mediumFile
verification.authenticationMethodssh loginParser confidence: mediumFile
verification.expectedStatuses.verified{"statuses":[],"names":["ssh"],"outcome":"verified"}Parser confidence: mediumFile
verification.authenticationMethodssh loginParser confidence: mediumFile
verification.expectedStatuses.verified{"statuses":[],"names":["ssh"],"outcome":"verified"}Parser confidence: mediumFile
verification.authenticationMethodssh loginParser confidence: mediumFile
verification.expectedStatuses.verified{"statuses":[],"names":["ssh"],"outcome":"verified"}Parser confidence: mediumFile
All 28 evidence rows
All evidence rows
FieldStatusValueSource
descriptionPrivate keys are used for securely connecting and authenticating to various systems and services. Exposure of private keys can lead to unauthorized access and data breaches.File
keywordsprivate keyFile
detectorTypesPrivateKeyFile
filescracker.go, fingerprint.go, normalize.go, openssh.go, privatekey.go, ssh_integration.goFile
patterns(?i)-----\s*?BEGIN[ A-Z0-9_-]*?PRIVATE KEY\s*?-----[\s\S]*?----\s*?END[ A-Z0-9_-]*? PRIVATE KEY\s*?-----File
patternTypemust_compileFile
statusactiveFile
lastSeenAt2026-11-25T16:33:44.855ZNo citation
rotationGuideNone extractedFile
verify.hasVerifyYesFile
verify.httpMethodsNone extractedFile
verify.statusCodesNone extractedFile
allowlistRulesliteral false positive: aaron1234567890123File
timeoutNone extractedFile
rateLimitNone extractedFile
errorHandlingSetVerificationErrorFile
verify.urlshttps://crt.sh/?q=%s, https://keychecker.trufflesecurity.com/fingerprint/%s, https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/githubs-ssh-key-fingerprints, https://docs.gitlab.com/ee/user/gitlab_com/index.html#ssh-host-keys-fingerprintsFile
detection.keywordsprivate keyLines 47–47
verification.authenticationMethodssh loginParser confidence: mediumFile
verification.expectedStatuses.verified{"statuses":[],"names":["ssh"],"outcome":"verified"}Parser confidence: mediumFile
verification.authenticationMethodssh loginParser confidence: mediumFile
verification.expectedStatuses.verified{"statuses":[],"names":["ssh"],"outcome":"verified"}Parser confidence: mediumFile
verification.authenticationMethodssh loginParser confidence: mediumFile
verification.expectedStatuses.verified{"statuses":[],"names":["ssh"],"outcome":"verified"}Parser confidence: mediumFile
verification.endpointhttps://keychecker.trufflesecurity.com/fingerprint/%sLines 225–225
verification.httpMethodGETLines 225–225
verification.authenticationMethodssh loginParser confidence: mediumFile
verification.expectedStatuses.verified{"statuses":[],"names":["ssh"],"outcome":"verified"}Parser confidence: mediumFile
Parser completeness
  • Field status: Extracted
  • Field status: Extracted
  • Field status: Extracted
  • Field status: Extracted
  • Field status: Unknown
  • Field status: Extracted
  • Field status: Extracted
  • Field status: Extracted
  • Field status: Extracted
  • Field status: Unknown
  • Field status: Not scanned
Package files (6)
  • cracker.go
  • fingerprint.go
  • normalize.go
  • openssh.go
  • privatekey.go
  • ssh_integration.go