Skip to content
Detectors

Scanner deep dive

Overview

Azure Entra ID refresh tokens provide long-lasting access to an account.
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 Refreshtoken detector checks decoded text containing “0.A” or “1.A” for a possible credential.

Matching rules and source
Detector-wide rules and behavior

How it works

  1. Values below an entropy threshold are skipped. The threshold differs by version; How it behaves lists each one.
  2. Reports each remaining match as a possible Azure Refresh Token credential. It isn’t known to work until it’s verified.
MustCompile
One value
5 regexes shared across variants

Used by more than one variant, or not tied to one variant’s files in what was read from source (shared files: common.go).

  • Regex 1tenantOnMicrosoftPat

    ([\w-]+\.onmicrosoft\.com)
    Show as a diagram
  • Regex 2refreshTokenPat

    \b[01]\.A[\w-]{50,}(?:\.\d)?\.Ag[\w-]{250,}(?:\.A[\w-]{200,})?
    Show as a diagram
  • v1 regex 1clientSecretPat

    (?i)(?:secret|password| -p[ =]).{0,80}?([\w~@[\]:.?*/+=-]{31,34}
  • v1 regex 2secretPat

    (?i)(?:secret|password| -p[ =]).{0,80}[^A-Za-z0-9!#$%&()*+,\-./:;<=>?@[\\\]^_{|}~]([A-Za-z0-9!#$%&()*+,\-./:;<=>?@[\\\]^_{|}~]{31,34})[^A-Za-z0-9!#$%&()*+,\-./:;<=>?@[\\\]^_{|}~]
  • v2 regexSecretPat

    (?:[^a-zA-Z0-9_~.-]|\A)([a-zA-Z0-9_~.-]{3}\dQ~[a-zA-Z0-9_~.-]{31,34})(?:[^a-zA-Z0-9_~.-]|\z)
    Show as a diagram
Guards against false matches
Differs by version; How it behaves lists each threshold
Not found in source

How it behaves

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

pkg/detectors/azure_entra/refreshtoken · Scanner

Keywords

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

  • 0.A
  • 1.A

refreshtoken.go line 45 (opens TruffleHog source on GitHub)

Behavior

Multi-part
Yes, pairs two parts such as an ID and a secret
refreshtoken.go line 26 (opens TruffleHog source on GitHub)
Match window
4096 bytes before and 2048 after a keyword
multi_part_credential_provider.go line 13 (opens TruffleHog source on GitHub)
Custom endpoints
No
Cloud endpoint
None
Randomness check
Skips values with entropy below 4
refreshtoken.go line 301 (opens TruffleHog source on GitHub)
False-positive check
The shared word lists

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.None in the open-source code.

In short

  • Refreshtoken: Wakes on “0.A” or “1.A”, reads 4096 bytes around each hit to pair two parts and tests matches with the provider. A default scan runs it.
  • Serviceprincipal: Wakes on “azure”, “az”, “entra”, “msal”, “login.microsoftonline.com” or “.onmicrosoft.com”, reads 1024 bytes around each hit to pair two parts and tests matches with the provider. A default scan runs it.
  • Serviceprincipal: Wakes on “q~”, reads 1024 bytes around each hit to pair two parts and tests matches with the provider. A default scan runs it.

How verification works

Each variant checks a found key its own way. Compare their requests and how answers are judged below.

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

Files
refreshtoken/refreshtoken.go
Request
POSThttps://login.microsoftonline.com/%s/oauth2/v2.0/tokenrefreshtoken.go:192 (opens TruffleHog source on GitHub)
Key is sent as
OAuth2 client credentials form
How answers are judged
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

Each variant checks keys its own way. Use the one that matches your key’s format (see Detection above).

  • Refreshtoken

    No command for this check. The check first trades the key for a token, so it takes more than one request.

    Rule: oauth. Key placement as recorded: OAuth2 client credentials form.

  • Serviceprincipal

    No command for this check. The check first trades the key for a token, so it takes more than one request.

    Rule: oauth. Key placement as recorded: OAuth2 client credentials form.

2. Likely causes

  • The scanner couldn't reach the provider. The scanner needs outbound HTTPS access to login.microsoftonline.com. A firewall, proxy or DNS problem is reported as an error, not a rejection, and the key can be checked again.
  • The provider rejected the key. TruffleHog counts these as not verified (Refreshtoken: 400 and 401; Serviceprincipal: 400 and 401): usually a revoked, expired or mistyped key.
  • Rate limit or provider problem. TruffleHog counts these as an error, not a rejection (Refreshtoken: any other status; Serviceprincipal: any other status). A rate limit (429) or an outage lands here; the key can be checked again later.
  • The provider changed its API. If the provider answers differently from the table above, its API may have changed since this check was written. Compare against the provider's docs.

3. Check the provider’s docs

No provider doc recorded for this check yet. Look up the API docs for login.microsoftonline.com and compare what they say each status means.

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; unexpected status %d checking tenant; unexpected HTTP response status %d

other statuses: verification error or unknown

transport errors return a verification error

All URLs found in source

  • https://learn.microsoft.com/en-us/partner-center/account-settings/find-ids-and-domain-names#find-the-microsoft-azure-ad-tenant-id-and-primary-domain-name
  • https://learn.microsoft.com/en-us/microsoft-365/admin/setup/domains-faq?view=o365-worldwide#why-do-i-have-an--onmicrosoft-com--domain
  • https://www.codingexplorations.com/blog/understanding-singleflight-in-golang-a-solution-for-eliminating-redundant-work
  • https://login.microsoftonline.com/%s/.well-known/openid-configuration
  • https://learn.microsoft.com/en-us/advertising/guides/authentication-oauth-get-tokens?view=bingads-13#refresh-accesstoken
  • https://graph.microsoft.com/.default
  • https://login.microsoftonline.com/%s/oauth2/v2.0/token
  • https://login.microsoftonline.com/error?code=9002313
  • https://login.microsoftonline.com/error?code=70008
  • https://login.microsoftonline.com/error?code=700082
  • https://login.microsoftonline.com/error?code=70043
  • https://login.microsoftonline.com/error?code=50173
  • https://login.microsoftonline.com/error?code=700016
  • https://login.microsoftonline.com/error?code=90002
  • https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-client-creds-grant-flow#get-a-token
  • https://howtorotate.com/docs/tutorials/azure/
  • https://github.com/Azure/azure-sdk-for-js/issues/30557
  • https://login.microsoftonline.com/error?code=7000215
  • https://login.microsoftonline.com/error?code=7000222
  • https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-client-creds-grant-flow#second-case-access-token-request-with-a-certificate
  • https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-client-creds-grant-flow#third-case-access-token-request-with-a-federated-credential

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: AzureRefreshToken
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 AzureRefreshToken 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

No analyzer is recorded for this detector.

A missing analyzer is not evidence the credential has no further access.

Rotation resources

Use the provider’s instructions for this credential.

Rotation and revocation instructions

Microsoft documents app client-secret rotation and user refresh-token revocation separately. Revoking all refresh tokens for a user can also invalidate their browser sessions.

Different credential. The tutorial rotates a Storage account access key. This detector covers Entra credentials. View original tutorial

Provider documentation checked by Atlas on .

See it in the rotation directory

Token types

TruffleHog’s source looks for 2 token types, by prefix. It doesn’t name them.

Token types: from TruffleHog’s source, and what the vendor says
Prefix
0.A
1.A
Pages TruffleHog’s source links to (18)

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

    How responses are judged changed, Verification error handling changed. Changes how the detector verifies or what it treats as the credential.

    Field changes
    FieldBeforeAfter
    Expected statusesBefore: 200 (StatusOK) → verified; 400 (StatusBadRequest) → not verified; other (default) → not verifiedAfter: 200 (StatusOK) → verified; 400 (StatusBadRequest) → not verified; other (default) → error or unknown
    pkg/detectors/azure_entra/common.go+99−43View file
    @@ -4,6 +4,7 @@ import (
    44 "fmt"
    55 "io"
    66 "net/http"
    7added: "sort"
    78 "strings"
    89
    910 regexp "github.com/wasilibs/go-re2"
    @@ -38,45 +39,93 @@ var (
    3839
    3940// FindTenantIdMatches returns a list of potential tenant IDs in the provided |data|.
    4041func FindTenantIdMatches(data string) map[string]struct{} {
    41removed: uniqueMatches := make(map[string]struct{})
    42removed:
    43removed: for _, match := range tenantIdPat.FindAllStringSubmatch(data, -1) {
    44removed: var m string
    45removed: if match[1] != "" {
    46removed: m = strings.ToLower(match[1])
    47removed: } else if match[2] != "" {
    48removed: m = strings.ToLower(match[2])
    49removed: } else if match[3] != "" {
    50removed: m = strings.ToLower(match[3])
    51removed: } else if match[4] != "" {
    52removed: m = strings.ToLower(match[4])
    53removed: }
    54removed: if _, ok := detectors.UuidFalsePositives[detectors.FalsePositive(m)]; ok {
    55removed: continue
    56removed: } else if detectors.StringShannonEntropy(m) < 3 {
    57removed: continue
    42added: return offsetsToSet(FindTenantIdOffsets(data))
    43added: }
    44added:
    45added: // FindTenantIdOffsets returns potential tenant IDs in |data|, mapped to the byte offsets where each was found.
    46added: func FindTenantIdOffsets(data string) map[string][]int {
    47added: matches := make(map[string][]int)
    48added:
    49added: for _, idx := range tenantIdPat.FindAllStringSubmatchIndex(data, -1) {
    50added: // The pattern has four alternative capture groups; use the one that matched.
    51added: for group := 1; group <= 4; group++ {
    52added: start, end := idx[2*group], idx[2*group+1]
    53added: if start < 0 {
    54added: continue
    55added: }
    56added: m := strings.ToLower(data[start:end])
    57added: if isLikelyId(m) {
    58added: matches[m] = append(matches[m], start)
    59added: }
    60added: break
    5861 }
    59removed: uniqueMatches[m] = struct{}{}
    6062 }
    61removed: for _, match := range tenantOnMicrosoftPat.FindAllStringSubmatch(data, -1) {
    62removed: uniqueMatches[match[1]] = struct{}{}
    63added: for _, idx := range tenantOnMicrosoftPat.FindAllStringSubmatchIndex(data, -1) {
    64added: m := data[idx[2]:idx[3]]
    65added: matches[m] = append(matches[m], idx[2])
    6366 }
    64removed: return uniqueMatches
    67added: return matches
    6568}
    6669
    6770// FindClientIdMatches returns a list of potential client UUIDs in the provided |data|.
    6871func FindClientIdMatches(data string) map[string]struct{} {
    69removed: uniqueMatches := make(map[string]struct{})
    70removed: for _, match := range clientIdPat.FindAllStringSubmatch(data, -1) {
    71removed: m := strings.ToLower(match[1])
    72removed: if _, ok := detectors.UuidFalsePositives[detectors.FalsePositive(m)]; ok {
    73removed: continue
    74removed: } else if detectors.StringShannonEntropy(m) < 3 {
    75removed: continue
    72added: return offsetsToSet(FindClientIdOffsets(data))
    73added: }
    74added:
    75added: // FindClientIdOffsets returns potential client UUIDs in |data|, mapped to the byte offsets where each was found.
    76added: func FindClientIdOffsets(data string) map[string][]int {
    77added: matches := make(map[string][]int)
    78added: for _, idx := range clientIdPat.FindAllStringSubmatchIndex(data, -1) {
    79added: m := strings.ToLower(data[idx[2]:idx[3]])
    80added: if isLikelyId(m) {
    81added: matches[m] = append(matches[m], idx[2])
    7682 }
    77removed: uniqueMatches[m] = struct{}{}
    7883 }
    79removed: return uniqueMatches
    84added: return matches
    85added: }
    86added:
    87added: // NearestFirst returns the keys of |candidates| ordered by their distance to |pos|.
    88added: // A candidate's distance is that of its closest occurrence. Ties are broken by value so the order is stable.
    89added: func NearestFirst(candidates map[string][]int, pos int) []string {
    90added: distances := make(map[string]int, len(candidates))
    91added: ordered := make([]string, 0, len(candidates))
    92added: for value, offsets := range candidates {
    93added: closest := -1
    94added: for _, offset := range offsets {
    95added: d := offset - pos
    96added: if d < 0 {
    97added: d = -d
    98added: }
    99added: if closest < 0 || d < closest {
    100added: closest = d
    101added: }
    102added: }
    103added: distances[value] = closest
    104added: ordered = append(ordered, value)
    105added: }
    106added: sort.Slice(ordered, func(i, j int) bool {
    107added: if distances[ordered[i]] != distances[ordered[j]] {
    108added: return distances[ordered[i]] < distances[ordered[j]]
    109added: }
    110added: return ordered[i] < ordered[j]
    111added: })
    112added: return ordered
    113added: }
    114added:
    115added: // isLikelyId filters out well-known placeholder UUIDs and low-entropy values.
    116added: func isLikelyId(m string) bool {
    117added: if _, ok := detectors.UuidFalsePositives[detectors.FalsePositive(m)]; ok {
    118added: return false
    119added: }
    120added: return detectors.StringShannonEntropy(m) >= 3
    121added: }
    122added:
    123added: func offsetsToSet(offsets map[string][]int) map[string]struct{} {
    124added: set := make(map[string]struct{}, len(offsets))
    125added: for value := range offsets {
    126added: set[value] = struct{}{}
    127added: }
    128added: return set
    80129}
    81130
    82131var (
    @@ -85,35 +134,42 @@ var (
    85134)
    86135
    87136// TenantExists returns whether the tenant exists according to Microsoft's well-known OpenID endpoint.
    88removed: func TenantExists(ctx context.Context, client *http.Client, tenant string) bool {
    137added: // A non-nil error means the answer is unknown (e.g., a network failure); it is not cached.
    138added: func TenantExists(ctx context.Context, client *http.Client, tenant string) (bool, error) {
    89139 // Use cached value where possible.
    90140 if tenantExists, isCached := tenantCache.Get(tenant); isCached {
    91removed: return tenantExists
    141added: return tenantExists, nil
    92142 }
    93143
    94144 // https://www.codingexplorations.com/blog/understanding-singleflight-in-golang-a-solution-for-eliminating-redundant-work
    95removed: tenantExists, _, _ := tenantGroup.Do(tenant, func() (interface{}, error) {
    96removed: result := queryTenant(ctx, client, tenant)
    97removed: tenantCache.Set(tenant, result)
    98removed: return result, nil
    145added: tenantExists, err, _ := tenantGroup.Do(tenant, func() (interface{}, error) {
    146added: result, err := queryTenant(ctx, client, tenant)
    147added: // Only remember definite answers, so a transient failure doesn't stick.
    148added: if err == nil {
    149added: tenantCache.Set(tenant, result)
    150added: }
    151added: return result, err
    99152 })
    153added: if err != nil {
    154added: return false, err
    155added: }
    100156
    101removed: return tenantExists.(bool)
    157added: return tenantExists.(bool), nil
    102158}
    103159
    104removed: func queryTenant(ctx context.Context, client *http.Client, tenant string) bool {
    160added: func queryTenant(ctx context.Context, client *http.Client, tenant string) (bool, error) {
    105161 logger := ctx.Logger().WithName("azure").WithValues("tenant", tenant)
    106162
    107163 tenantUrl := fmt.Sprintf("https://login.microsoftonline.com/%s/.well-known/openid-configuration", tenant)
    108164 req, err := http.NewRequestWithContext(ctx, http.MethodGet, tenantUrl, nil)
    109165 if err != nil {
    110removed: return false
    166added: return false, err
    111167 }
    112168
    113169 res, err := client.Do(req)
    114170 if err != nil {
    115171 logger.Error(err, "Failed to check if tenant exists")
    116removed: return false
    172added: return false, err
    117173 }
    118174 defer func() {
    119175 _, _ = io.Copy(io.Discard, res.Body)
    @@ -122,13 +178,13 @@ func queryTenant(ctx context.Context, client *http.Client, tenant string) bool {
    122178
    123179 switch res.StatusCode {
    124180 case http.StatusOK:
    125removed: return true
    181added: return true, nil
    126182 case http.StatusBadRequest:
    127183 logger.V(4).Info("Tenant does not exist.")
    128removed: return false
    184added: return false, nil
    129185 default:
    130186 bodyBytes, _ := io.ReadAll(res.Body)
    131187 logger.Error(nil, "WARNING: Unexpected response when checking if tenant exists", "status_code", res.StatusCode, "body", string(bodyBytes))
    132removed: return false
    188added: return false, fmt.Errorf("unexpected status %d checking tenant", res.StatusCode)
    133189 }
    134190}
    pkg/detectors/azure_entra/refreshtoken/refreshtoken.go+1−1View file
    @@ -112,7 +112,7 @@ func (s Scanner) processMatches(ctx context.Context, refreshTokens, clientIds, t
    112112 }
    113113
    114114 if _, ok := validTenants[tenantId]; !ok {
    115removed: if azure_entra.TenantExists(logCtx, client, tenantId) {
    115added: if exists, err := azure_entra.TenantExists(logCtx, client, tenantId); err == nil && exists {
    116116 validTenants[tenantId] = struct{}{}
    117117 } else {
    118118 delete(tenantIds, tenantId)
    pkg/detectors/azure_entra/serviceprincipal/v1/spv1.go+3−3View file
    @@ -53,18 +53,18 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
    5353 if len(clientSecrets) == 0 {
    5454 return
    5555 }
    56removed: clientIds := azure_entra.FindClientIdMatches(dataStr)
    56added: clientIds := azure_entra.FindClientIdOffsets(dataStr)
    5757 if len(clientIds) == 0 {
    5858 return
    5959 }
    60removed: tenantIds := azure_entra.FindTenantIdMatches(dataStr)
    60added: tenantIds := azure_entra.FindTenantIdOffsets(dataStr)
    6161
    6262 client := s.client
    6363 if client == nil {
    6464 client = defaultClient
    6565 }
    6666 // The handling logic is identical for both versions.
    67removed: results = append(results, v2.ProcessData(ctx, clientSecrets, clientIds, tenantIds, verify, client)...)
    67added: results = append(results, v2.ProcessData(ctx, dataStr, clientSecrets, clientIds, tenantIds, verify, client)...)
    6868 return results, nil
    6969}
    pkg/detectors/azure_entra/serviceprincipal/v2/spv2.go+65−18View file
    @@ -58,34 +58,54 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
    5858 if len(clientSecrets) == 0 {
    5959 return results, nil
    6060 }
    61removed: clientIds := azure_entra.FindClientIdMatches(dataStr)
    62removed: tenantIds := azure_entra.FindTenantIdMatches(dataStr)
    61added: clientIds := azure_entra.FindClientIdOffsets(dataStr)
    62added: tenantIds := azure_entra.FindTenantIdOffsets(dataStr)
    6363
    6464 client := s.client
    6565 if client == nil {
    6666 client = defaultClient
    6767 }
    6868
    69removed: results = append(results, ProcessData(ctx, clientSecrets, clientIds, tenantIds, verify, client)...)
    69added: results = append(results, ProcessData(ctx, dataStr, clientSecrets, clientIds, tenantIds, verify, client)...)
    7070 return results, nil
    7171}
    7272
    73removed: func ProcessData(ctx context.Context, clientSecrets, clientIds, tenantIds map[string]struct{}, verify bool, client *http.Client) (results []detectors.Result) {
    73added: // ProcessData verifies each secret against the client and tenant IDs found in |data|.
    74added: // |clientIds| and |tenantIds| map each candidate to the offsets it was found at, so the
    75added: // candidates closest to a secret are tried (and reported) first.
    76added: func ProcessData(ctx context.Context, data string, clientSecrets map[string]struct{}, clientIds, tenantIds map[string][]int, verify bool, client *http.Client) (results []detectors.Result) {
    7477 logCtx := logContext.AddLogger(ctx)
    7578 invalidClientsForTenant := make(map[string]map[string]struct{})
    79added: // Tenants whose lookup failed. Not retried again in this call, so one flaky tenant
    80added: // costs one request instead of one per secret and client.
    81added: unknownTenants := make(map[string]struct{})
    7682
    7783 for clientSecret := range clientSecrets {
    7884 var (
    79removed: r *detectors.Result
    80removed: clientId string
    81removed: tenantId string
    85added: r *detectors.Result
    86added: // The first client/tenant pair that recognised the app but rejected the secret.
    87added: knownClientId, knownTenantId string
    8288 )
    8389
    90added: // Candidates nearest to the secret are the most likely to belong to it.
    91added: secretPos := strings.Index(data, clientSecret)
    92added: clientOrder := azure_entra.NearestFirst(clientIds, secretPos)
    93added: tenantOrder := azure_entra.NearestFirst(tenantIds, secretPos)
    94added:
    8495 ClientLoop:
    85removed: for cId := range clientIds {
    86removed: clientId = cId
    87removed: for tId := range tenantIds {
    88removed: tenantId = tId
    96added: for _, clientId := range clientOrder {
    97added: // Skip candidates removed earlier (e.g., a tenant that was also read as a client).
    98added: if _, ok := clientIds[clientId]; !ok {
    99added: continue
    100added: }
    101added: for _, tenantId := range tenantOrder {
    102added: if _, ok := tenantIds[tenantId]; !ok {
    103added: continue
    104added: }
    105added:
    106added: if _, unknown := unknownTenants[tenantId]; unknown {
    107added: continue
    108added: }
    89109
    90110 // Skip known invalid tenants.
    91111 invalidClients := invalidClientsForTenant[tenantId]
    @@ -98,7 +118,14 @@ func ProcessData(ctx context.Context, clientSecrets, clientIds, tenantIds map[st
    98118 }
    99119
    100120 if verify {
    101removed: if !azure_entra.TenantExists(logCtx, client, tenantId) {
    121added: exists, err := azure_entra.TenantExists(logCtx, client, tenantId)
    122added: if err != nil {
    123added: // Unknown, not "missing". Skip it for now but keep it as a candidate.
    124added: // If no pair is recognised, the fallback still picks the nearest tenant.
    125added: unknownTenants[tenantId] = struct{}{}
    126added: continue
    127added: }
    128added: if !exists {
    102129 // Tenant doesn't exist
    103130 delete(tenantIds, tenantId)
    104131 continue
    @@ -113,6 +140,11 @@ func ProcessData(ctx context.Context, clientSecrets, clientIds, tenantIds map[st
    113140 case errors.Is(verificationErr, serviceprincipal.ErrConditionalAccessPolicy):
    114141 // Do nothing.
    115142 case errors.Is(verificationErr, serviceprincipal.ErrSecretInvalid):
    143added: // The app exists in this tenant, only the secret is wrong (e.g.,
    144added: // rotated). Remember the pair so the fallback matches the live result.
    145added: if knownClientId == "" {
    146added: knownClientId, knownTenantId = clientId, tenantId
    147added: }
    116148 continue ClientLoop
    117149 case errors.Is(verificationErr, serviceprincipal.ErrSecretExpired):
    118150 r = createResult(tenantId, clientId, clientSecret, false, nil, nil)
    @@ -138,12 +170,12 @@ func ProcessData(ctx context.Context, clientSecrets, clientIds, tenantIds map[st
    138170 }
    139171
    140172 if r == nil {
    141removed: // Only include the clientId and tenantId if we're confident which one it is.
    142removed: if len(clientIds) != 1 {
    143removed: clientId = ""
    144removed: }
    145removed: if len(tenantIds) != 1 {
    146removed: tenantId = ""
    173added: // Nothing verified. Use the pair Azure recognised, if any. Otherwise report
    174added: // the nearest tenant, then the nearest client that isn't ruled out for it.
    175added: // This keeps the result the same whether the secret is live or rotated.
    176added: clientId, tenantId := knownClientId, knownTenantId
    177added: if clientId == "" {
    178added: clientId, tenantId = nearestPair(clientIds, tenantIds, invalidClientsForTenant, secretPos)
    147179 }
    148180 r = createResult(tenantId, clientId, clientSecret, false, nil, nil)
    149181 }
    @@ -153,6 +185,21 @@ func ProcessData(ctx context.Context, clientSecrets, clientIds, tenantIds map[st
    153185 return results
    154186}
    155187
    188added: // nearestPair picks the tenant nearest to |pos|, then the nearest client that isn't
    189added: // ruled out for that tenant and isn't the tenant itself.
    190added: func nearestPair(clientIds, tenantIds map[string][]int, invalidClientsForTenant map[string]map[string]struct{}, pos int) (clientId, tenantId string) {
    191added: if remaining := azure_entra.NearestFirst(tenantIds, pos); len(remaining) > 0 {
    192added: tenantId = remaining[0]
    193added: }
    194added: for _, candidate := range azure_entra.NearestFirst(clientIds, pos) {
    195added: if _, ruledOut := invalidClientsForTenant[tenantId][candidate]; ruledOut || candidate == tenantId {
    196added: continue
    197added: }
    198added: return candidate, tenantId
    199added: }
    200added: return "", tenantId
    201added: }
    202added:
    156203func createResult(tenantId string, clientId string, clientSecret string, verified bool, extraData map[string]string, err error) *detectors.Result {
    157204 r := &detectors.Result{
    158205 DetectorType: detector_typepb.DetectorType_Azure,

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

4 of 36 evidence rows need attention

Evidence rows that need attention
FieldStatusValueSource
lastSeenAt2026-11-25T16:33:44.855ZNo citation
timeoutNone extractedFile
rateLimitNone extractedFile
verification.authenticationMethodOAuth2 client credentials formParser confidence: mediumFile
All 36 evidence rows
All evidence rows
FieldStatusValueSource
descriptionAzure Entra ID refresh tokens provide long-lasting access to an account.File
keywords0.A, 1.A, azure, az, entra, msal, login.microsoftonline.com, .onmicrosoft.com, q~File
detectorTypesAzureRefreshToken, AzureFile
filescommon.go, refreshtoken/refreshtoken.go, serviceprincipal/sp.go, serviceprincipal/v1/spv1.go, serviceprincipal/v2/spv2.goFile
patterns([\w-]+\.onmicrosoft\.com), \b[01]\.A[\w-]{50,}(?:\.\d)?\.Ag[\w-]{250,}(?:\.A[\w-]{200,})?, (?i)(?:secret|password| -p[ =]).{0,80}?([\w~@[\]:.?*/+=-]{31,34}, (?i)(?:secret|password| -p[ =]).{0,80}[^A-Za-z0-9!#$%&()*+,\-./:;<=>?@[\\\]^_{|}~]([A-Za-z0-9!#$%&()*+,\-./:;<=>?@[\\\]^_{|}~]{31,34})[^A-Za-z0-9!#$%&()*+,\-./:;<=>?@[\\\]^_{|}~], (?:[^a-zA-Z0-9_~.-]|\A)([a-zA-Z0-9_~.-]{3}\dQ~[a-zA-Z0-9_~.-]{31,34})(?:[^a-zA-Z0-9_~.-]|\z)File
patternTypemust_compileFile
statusactiveFile
lastSeenAt2026-11-25T16:33:44.855ZNo citation
rotationGuidehttps://howtorotate.com/docs/tutorials/azure/File
verify.hasVerifyYesFile
verify.httpMethodsGET, POSTFile
verify.statusCodesOK, BadRequest, UnauthorizedFile
entropyMinimum4File
timeoutNone extractedFile
rateLimitNone extractedFile
errorHandlingSetVerificationError; unexpected status %d checking tenant; unexpected HTTP response status %dFile
verify.urlshttps://learn.microsoft.com/en-us/partner-center/account-settings/find-ids-and-domain-names#find-the-microsoft-azure-ad-tenant-id-and-primary-domain-name, https://learn.microsoft.com/en-us/microsoft-365/admin/setup/domains-faq?view=o365-worldwide#why-do-i-have-an--onmicrosoft-com--domain, https://www.codingexplorations.com/blog/understanding-singleflight-in-golang-a-solution-for-eliminating-redundant-work, https://login.microsoftonline.com/%s/.well-known/openid-configuration, https://learn.microsoft.com/en-us/advertising/guides/authentication-oauth-get-tokens?view=bingads-13#refresh-accesstoken, https://graph.microsoft.com/.default, https://login.microsoftonline.com/%s/oauth2/v2.0/token, https://login.microsoftonline.com/error?code=9002313, https://login.microsoftonline.com/error?code=70008, https://login.microsoftonline.com/error?code=700082, https://login.microsoftonline.com/error?code=70043, https://login.microsoftonline.com/error?code=50173, https://login.microsoftonline.com/error?code=700016, https://login.microsoftonline.com/error?code=90002, https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-client-creds-grant-flow#get-a-token, https://howtorotate.com/docs/tutorials/azure/, https://github.com/Azure/azure-sdk-for-js/issues/30557, https://login.microsoftonline.com/error?code=7000215, https://login.microsoftonline.com/error?code=7000222, https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-client-creds-grant-flow#second-case-access-token-request-with-a-certificate, https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-client-creds-grant-flow#third-case-access-token-request-with-a-federated-credentialFile
detection.keywords0.A, 1.ALines 44–44
detection.keywordsazure, az, entra, msal, login.microsoftonline.com, .onmicrosoft.comLines 44–44
detection.keywordsq~Lines 41–41
verification.endpointhttps://login.microsoftonline.com/%s/.well-known/openid-configurationLines 164–164
verification.httpMethodGETLines 164–164
verification.expectedStatuses.verified{"statuses":[200],"names":["StatusOK"],"outcome":"verified"}Lines 180–180
verification.expectedStatuses.not_verified{"statuses":[400],"names":["StatusBadRequest"],"outcome":"not_verified"}Lines 182–182
verification.expectedStatuses.error_or_unknown{"statuses":[],"names":["default"],"outcome":"error_or_unknown"}Lines 185–185
verification.endpointhttps://login.microsoftonline.com/%s/oauth2/v2.0/tokenLines 192–192
verification.httpMethodPOSTLines 192–192
verification.authenticationMethodOAuth2 client credentials formParser confidence: mediumFile
verification.expectedStatuses.not_verified{"statuses":[400],"names":["StatusBadRequest"],"outcome":"not_verified"}Lines 249–249
verification.expectedStatuses.not_verified{"statuses":[401],"names":["StatusUnauthorized"],"outcome":"not_verified"}Lines 278–278
verification.expectedStatuses.error_or_unknown{"statuses":[],"names":["default"],"outcome":"error_or_unknown"}Lines 275–275
verification.endpointhttps://login.microsoftonline.com/%s/oauth2/v2.0/tokenLines 46–46
verification.httpMethodPOSTLines 46–46
verification.authenticationMethodOAuth2 client credentials formLines 42–42
verification.expectedStatuses.not_verified{"statuses":[400,401],"names":["StatusBadRequest","StatusUnauthorized"],"outcome":"not_verified"}Lines 94–94
verification.expectedStatuses.error_or_unknown{"statuses":[],"names":["default"],"outcome":"error_or_unknown"}Lines 115–115
Parser completeness
  • Field status: Extracted
  • 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: Not scanned
Package files (5)
  • common.go
  • refreshtoken/refreshtoken.go
  • serviceprincipal/sp.go
  • serviceprincipal/v1/spv1.go
  • serviceprincipal/v2/spv2.go