Skip to content
Detectors

Scanner deep dive

Overview

Box is a service offering various service for secure collaboration, content management, and workflow. Box Oauth credentials can be used to access and interact with this data.
From the detector’s Description() in source
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 Box OAuth detector looks for pieces of a credential that belong together. The code names fields such as “client ID” and “client secret”.

Runs by default

Matching rules and source
Keywords
  • box

Regexes

  • Regex 1clientIdPatboxoauth.go:47 (opens TruffleHog source on GitHub)Only code file

    \b([a-zA-Z0-9]{32})\b

    Matches 32-character strings of letters and digits.

    Show as a diagram

    Must appear near: “id”

  • Regex 2clientSecretPatboxoauth.go:47 (opens TruffleHog source on GitHub)Only code file

    \b([a-zA-Z0-9]{32})\b

    Matches 32-character strings of letters and digits.

    Show as a diagram

    Must appear near: “secret”

  • Regex 3subjectIdPatboxoauth.go:52 (opens TruffleHog source on GitHub)Only code file

    \b([0-9]{6,20})\b

    Matches 6–20-character strings of digits.

    Show as a diagram

    Must appear near: “enterprise”, “enterprise_id”, “user”, “user_id”, “subject” or “box_subject”

How it works

  1. Skips any text that doesn’t contain “box”. This keeps scanning fast.
  2. Looks for 32-character strings of letters and digits within 40 characters after the word “id”. Also looks for 32-character strings of letters and digits within 40 characters after the word “secret”, or 6–20-character strings of digits within 40 characters after one of the words “enterprise”, “enterprise_id” or “user” (3 more).
  3. Finds each part (client ID and client secret) and pairs them.
  4. Identical key and secret values are skipped.
  5. Reports each remaining match as a possible Box OAuth credential. It isn’t known to work until it’s verified.
Prefix regex
Several partsclient_id and client_secret
Guards against false matches
Not found in source
Not found in source
Pairing and normalization
  • client_id, client_secret are combined from match sets
  • Identical key and secret values are skipped.

How it behaves

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

pkg/detectors/boxoauth · Scanner

Keywords

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

  • box

boxoauth.go line 99 (opens TruffleHog source on GitHub)

Behavior

Multi-part
No
Match window
512 bytes on each side of a keyword
ahocorasickcore.go line 159 (opens TruffleHog source on GitHub)
Custom endpoints
No
Cloud endpoint
None
Randomness check
None in this detector's own code
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

Wakes on “box” and tests matches with the provider. A default scan runs it.

How verification works

What it means

Sends POST to api.box.com.

Open Source + Enterprise support detection and verification for this credential type. Edition source.

Does checking a key change anything at the provider?

Probably not, but not certain: the source declares no changes, and many checks use POST only to read. POST can change data, so check the source if it matters.

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

Verification walkthrough

How it works

  1. Sends a POST to api.box.com.
  2. Puts the found credential in the request: credential is sent in a JSON body field named client_id.
  3. If the request can’t reach the provider, the result is an error, not a rejection.

Evidence from source

Endpoint

https://api.box.com/oauth2/token

boxoauth.go:221 (opens TruffleHog source on GitHub)

Key is sent as

JSON client_id field

boxoauth.go:134 (opens TruffleHog source on GitHub)

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. The key goes in a request body whose other fields aren't recorded here.

Rule: body. Key placement as recorded: JSON client_id field.

2. Likely causes

  • The scanner couldn't reach the provider. The scanner needs outbound HTTPS access to api.box.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

No provider doc recorded for this check yet. Look up the API docs for api.box.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 HTTP response status %d

transport errors return a verification error

All URLs found in source

  • https://api.box.com/oauth2/token

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

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.

The detector’s source links no vendor pages.

Coverage in other scanners

2 scanners have a confirmed match.

Changes

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

  1. What this change means

    Regex changed, Capture groups changed, How the credential is sent changed, How responses are judged changed, Verification error handling changed, Description changed. Changes how the detector verifies or what it treats as the credential.

    Field changes
    FieldBeforeAfter
    Regex patternsBefore: \b([a-zA-Z0-9]{32})\b, \b([a-zA-Z0-9]{32})\b, \b([0-9]{6,20})\bAfter: \b([a-zA-Z0-9]{32})\b, \b([a-zA-Z0-9]{32})\b
    Expected statusesBefore: 400 (StatusBadRequest) → error or unknown; other (default) → error or unknownAfter: none
    How the credential is sentBefore: client_id and client_secret are posted as application/x-www-form-urlencodedAfter: credential is sent in a JSON body field named client_id
    Description
    Before: Box is a service offering various service for secure collaboration, content management, and workflow. Box Oauth credentials can be used to a… show all
    Box is a service offering various service for secure collaboration, content management, and workflow. Box Oauth credentials can be used to access and interact with this data.
    After: Box is a service offering various service for secure collaboration, content management, and workflow. Box Oauth credentials can be used to a… show all
    Box is a service offering various service for secure collaboration, content management, and workflow. Box Oauth credentials can be used to access and interact with this data. 
    pkg/detectors/boxoauth/boxoauth.go+149−59View file
    @@ -2,10 +2,12 @@ package boxoauth
    22
    33import (
    44 "context"
    5added: "encoding/json"
    6added: "errors"
    57 "fmt"
    68 "io"
    79 "net/http"
    8removed: "slices"
    10added: "net/url"
    911 "strings"
    1012
    1113 regexp "github.com/wasilibs/go-re2"
    @@ -22,17 +24,68 @@ type Scanner struct {
    2224// Ensure the Scanner satisfies the interface at compile time.
    2325var _ detectors.Detector = (*Scanner)(nil)
    2426
    27added: const tokenURL = "https://api.box.com/oauth2/token"
    28added:
    29added: // maxSubjectIDCandidates bounds how many nearby subject IDs are tried per
    30added: // client ID and secret pair. Each candidate costs up to one token request per
    31added: // subject type, every request counts against the customer's Box API
    32added: // allocation, and a long run of failed subject attempts against one client
    33added: // looks like enumeration. Real configs usually carry one or two genuine IDs,
    34added: // and candidates are ranked so the most likely ones fall inside the cap.
    35added: const maxSubjectIDCandidates = 5
    36added:
    37added: // subjectTypes are the box_subject_type values tried for each subject ID, in
    38added: // order. "enterprise" authenticates as the app's Service Account; "user"
    39added: // authenticates as an App User, Managed User or admin. User-subject tokens act
    40added: // as a real person, so dropping "user" here is the single switch for
    41added: // narrowing that footprint.
    42added: var subjectTypes = []string{"enterprise", "user"}
    43added:
    2544var (
    2645 defaultClient = common.SaneHttpClient()
    2746 // Make sure that your group is surrounded in boundary characters such as below to reduce false positives.
    2847 clientIdPat = regexp.MustCompile(detectors.PrefixRegex([]string{"id"}) + `\b([a-zA-Z0-9]{32})\b`)
    2948 clientSecretPat = regexp.MustCompile(detectors.PrefixRegex([]string{"secret"}) + `\b([a-zA-Z0-9]{32})\b`)
    49added:
    3050 // Box enterprise and user IDs are numeric strings.
    31removed: subjectIdPat = regexp.MustCompile(detectors.PrefixRegex([]string{
    32removed: "enterprise", "enterprise_id", "user", "user_id", "subject", "box_subject",
    33removed: }) + `\b([0-9]{6,20})\b`)
    51added: subjectKeywords = []string{"enterprise", "enterprise_id", "user", "user_id", "subject", "box_subject"}
    52added: subjectIdPat = regexp.MustCompile(detectors.PrefixRegex(subjectKeywords) + `\b([0-9]{6,20})\b`)
    53added:
    54added: // subjectLabelPat finds the subject keywords inside a subjectIdPat match.
    55added: // A match starts at the leftmost keyword, which can be a different label
    56added: // than the one beside the number when two labels fall within the 40
    57added: // characters before it, so ranking reads the last keyword instead.
    58added: subjectLabelPat = regexp.MustCompile(`(?i)` + strings.Join(subjectKeywords, "|"))
    59added: )
    60added:
    61added: // strongSubjectKeywords are labels that name a Box subject specifically.
    62added: // Numbers next to them are tried before numbers next to generic labels like
    63added: // "user", which also precede timestamps, phone numbers and unrelated IDs.
    64added: var strongSubjectKeywords = map[string]struct{}{
    65added: "enterprise": {},
    66added: "enterprise_id": {},
    67added: "box_subject": {},
    68added: }
    69added:
    70added: var (
    71added: // errUnauthorizedClient is Box's unauthorized_client response to a request
    72added: // carrying only the client ID and secret. Box defines it as "Client is not
    73added: // authorized for requested grant type" and treats it as inconclusive: it
    74added: // doesn't confirm the secret, so only a token issued for a subject can.
    75added: errUnauthorizedClient = errors.New("unauthorized_client: cannot verify incomplete Box credentials without an enterprise, user, or subject id found nearby")
    76added:
    77added: // errInvalidClient is Box's invalid_client response, which Box defines as
    78added: // an invalid client ID or secret. It's a definite rejection, so it never
    79added: // surfaces as a verification error.
    80added: errInvalidClient = errors.New("invalid_client")
    3481)
    3582
    83added: // tokenErrorResponse is the OAuth 2.0 error body Box returns from the token endpoint.
    84added: type tokenErrorResponse struct {
    85added: Error string `json:"error"`
    86added: ErrorDescription string `json:"error_description"`
    87added: }
    88added:
    3689func (s Scanner) getClient() *http.Client {
    3790 if s.client != nil {
    3891 return s.client
    @@ -47,7 +100,8 @@ func (s Scanner) Keywords() []string {
    47100}
    48101
    49102func (s Scanner) Description() string {
    50removed: return "Box is a service offering various service for secure collaboration, content management, and workflow. Box Oauth credentials can be used to access and interact with this data."
    103added: return "Box is a service offering various service for secure collaboration, content management, and workflow. Box Oauth credentials can be used to access and interact with this data. " +
    104added: "Box only confirms a client ID and secret by issuing a token for an enterprise or user ID, so these credentials verify only when such an ID appears nearby."
    51105}
    52106
    53107// FromData will find and optionally verify Box secrets in a given set of bytes.
    @@ -64,15 +118,7 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
    64118 uniqueSecretMatches[match[1]] = struct{}{}
    65119 }
    66120
    67removed: var subjectIds []string
    68removed: uniqueSubjectIdMatches := make(map[string]struct{})
    69removed: for _, match := range subjectIdPat.FindAllStringSubmatch(dataStr, -1) {
    70removed: if _, seen := uniqueSubjectIdMatches[match[1]]; !seen {
    71removed: uniqueSubjectIdMatches[match[1]] = struct{}{}
    72removed: subjectIds = append(subjectIds, match[1])
    73removed: }
    74removed: }
    75removed: slices.Sort(subjectIds)
    121added: subjectIds := rankSubjectIDs(dataStr)
    76122
    77123 for resIdMatch := range uniqueIdMatches {
    78124 for resSecretMatch := range uniqueSecretMatches {
    @@ -91,18 +137,15 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
    91137 }
    92138
    93139 if verify {
    94removed: isVerified, verificationErr := verifyMatch(ctx, s.getClient(), resIdMatch, resSecretMatch)
    140added: isVerified, subjectId, verificationErr := verifyMatch(ctx, s.getClient(), resIdMatch, resSecretMatch, subjectIds)
    95141 s1.Verified = isVerified
    96removed: s1.SetVerificationError(verificationErr, resIdMatch)
    97removed:
    98removed: if isVerified {
    99removed: for _, subjectId := range subjectIds {
    100removed: if verifySubjectID(ctx, s.getClient(), resIdMatch, resSecretMatch, subjectId) {
    101removed: s1.SecretParts["subject_id"] = subjectId
    102removed: break
    103removed: }
    104removed: }
    142added: // subject_id feeds the Box analyzer, which needs the same
    143added: // subject to authenticate, so it's only recorded once Box has
    144added: // accepted it.
    145added: if subjectId != "" {
    146added: s1.SecretParts["subject_id"] = subjectId
    105147 }
    148added: s1.SetVerificationError(verificationErr, resIdMatch, resSecretMatch)
    106149 }
    107150
    108151 results = append(results, s1)
    @@ -117,67 +160,121 @@ func (s Scanner) FromData(ctx context.Context, verify bool, data []byte) (result
    117160 return
    118161}
    119162
    120removed: func verifyMatch(ctx context.Context, client *http.Client, id string, secret string) (bool, error) {
    121removed: url := "https://api.box.com/oauth2/token"
    122removed: payload := strings.NewReader("grant_type=client_credentials&client_id=" + id + "&client_secret=" + secret)
    123removed: req, err := http.NewRequestWithContext(ctx, http.MethodPost, url, payload)
    124removed: if err != nil {
    125removed: return false, err
    163added: // verifyMatch applies Box's verification rules to one client ID and secret
    164added: // pair, as Box defines them:
    165added: //
    166added: // - invalid_client on the subject-less request: unverified (dead).
    167added: // - unauthorized_client: inconclusive on its own. The pair is Verified only
    168added: // when a request naming a nearby subject ID returns HTTP 200. If there's no
    169added: // subject ID, or every subject attempt fails, the result stays unknown,
    170added: // because Box won't say whether the secret or the subject caused a failure.
    171added: // - Any other response: unknown, with no subject requests.
    172added: //
    173added: // It returns the accepted subject ID alongside a Verified result.
    174added: func verifyMatch(ctx context.Context, client *http.Client, id, secret string, subjectIds []string) (bool, string, error) {
    175added: err := probeClientCredentials(ctx, client, id, secret)
    176added: switch {
    177added: case errors.Is(err, errInvalidClient):
    178added: return false, "", nil
    179added: case !errors.Is(err, errUnauthorizedClient):
    180added: return false, "", err
    181added: }
    182added:
    183added: if len(subjectIds) == 0 {
    184added: return false, "", err
    185added: }
    186added:
    187added: candidates := subjectIds
    188added: if len(candidates) > maxSubjectIDCandidates {
    189added: candidates = candidates[:maxSubjectIDCandidates]
    190added: }
    191added:
    192added: for _, subjectId := range candidates {
    193added: if verifySubjectID(ctx, client, id, secret, subjectId) {
    194added: return true, subjectId, nil
    195added: }
    196added: }
    197added:
    198added: // These messages use %v, not %w: Result.SetVerificationError keeps only the
    199added: // innermost wrapped error, which would drop the context added here.
    200added: msg := fmt.Sprintf("%v; no nearby subject ID was accepted", err)
    201added: // When the cap skipped candidates, say so, so an unknown result on a noisy
    202added: // chunk is explainable. Counts only: the IDs themselves stay out of the
    203added: // stored error.
    204added: if len(subjectIds) > len(candidates) {
    205added: msg = fmt.Sprintf("%s (tried %d of %d subject ID candidates)", msg, len(candidates), len(subjectIds))
    126206 }
    207added: return false, "", errors.New(msg)
    208added: }
    127209
    128removed: req.Header = http.Header{"content-type": []string{"application/x-www-form-urlencoded"}}
    210added: // probeClientCredentials sends the client ID and secret to Box's token
    211added: // endpoint without a subject. Box requires a subject for client-credentials
    212added: // tokens, so this request never issues one; its only purpose is to sort the
    213added: // pair into Box's rule buckets. It returns errInvalidClient,
    214added: // errUnauthorizedClient, or an error describing an unexpected response.
    215added: func probeClientCredentials(ctx context.Context, client *http.Client, id string, secret string) error {
    216added: form := url.Values{
    217added: "grant_type": {"client_credentials"},
    218added: "client_id": {id},
    219added: "client_secret": {secret},
    220added: }
    221added: req, err := http.NewRequestWithContext(ctx, http.MethodPost, tokenURL, strings.NewReader(form.Encode()))
    222added: if err != nil {
    223added: return err
    224added: }
    225added: req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
    129226
    130227 res, err := client.Do(req)
    131228 if err != nil {
    132removed: return false, err
    229added: return err
    133230 }
    134231 defer func() {
    135232 _, _ = io.Copy(io.Discard, res.Body)
    136233 _ = res.Body.Close()
    137234 }()
    138235
    139removed: // We are using malformed request to check if the client id and secret are valid.
    140removed: // In this case, the Box OAuth API returns a 400 status code even if the credentials are valid.
    141removed: //
    142removed: // - If the client ID/secret are valid, the response contains "unauthorized_client"
    143removed: // - If the credentials are invalid, the response contains "invalid_client"
    144removed: //
    145removed: // So we check the response body for one of these keywords.
    146removed: switch res.StatusCode {
    147removed: case http.StatusBadRequest:
    148removed: {
    149removed: bodyBytes, err := io.ReadAll(res.Body)
    150removed: if err != nil {
    151removed: return false, err
    152removed: }
    153removed: body := string(bodyBytes)
    154removed: if strings.Contains(body, "unauthorized_client") {
    155removed: return true, nil
    156removed: } else if strings.Contains(body, "invalid_client") {
    157removed: return false, nil
    158removed: } else {
    159removed: return false, fmt.Errorf("response body missing expected keyword")
    160removed: }
    161removed: }
    236added: if res.StatusCode != http.StatusBadRequest {
    237added: return fmt.Errorf("unexpected HTTP response status %d", res.StatusCode)
    238added: }
    239added:
    240added: var tokenErr tokenErrorResponse
    241added: if err := json.NewDecoder(res.Body).Decode(&tokenErr); err != nil {
    242added: return fmt.Errorf("failed to decode token error response: %v", err)
    243added: }
    244added:
    245added: switch tokenErr.Error {
    246added: case "invalid_client":
    247added: return errInvalidClient
    248added: case "unauthorized_client":
    249added: return errUnauthorizedClient
    162250 default:
    163removed: return false, fmt.Errorf("unexpected HTTP response status %d", res.StatusCode)
    251added: return fmt.Errorf("unexpected token error %q", tokenErr.Error)
    164252 }
    165253}
    166254
    167255// verifySubjectID checks whether a subject ID is valid for the given client
    168256// credentials by attempting the Box CCG (Client Credentials Grant) auth flow.
    169removed: // It mirrors the analyzer's Authenticate logic: try enterprise subject type
    170removed: // first, then fall back to user subject type. Returns true on the first
    171removed: // successful authentication (HTTP 200).
    257added: // It mirrors the analyzer's Authenticate logic: try each of subjectTypes in
    258added: // order, and return true on the first successful authentication (HTTP 200).
    259added: //
    260added: // A 200 means Box issued a real access token, valid for 60 minutes with no
    261added: // refresh token. That's unavoidable: Box confirmed tha

    Diff truncated for size. See the full file on GitHub.

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 20 evidence rows need attention

Evidence rows that need attention
FieldStatusValueSource
lastSeenAt2026-11-25T16:33:44.855ZNo citation
rotationGuideNone extractedFile
timeoutNone extractedFile
rateLimitNone extractedFile
All 20 evidence rows
All evidence rows
FieldStatusValueSource
descriptionBox is a service offering various service for secure collaboration, content management, and workflow. Box Oauth credentials can be used to access and interact with this data. File
keywordsboxFile
detectorTypesBoxOauthFile
filesboxoauth.goFile
patterns\b([a-zA-Z0-9]{32})\b, \b([a-zA-Z0-9]{32})\b, \b([0-9]{6,20})\bFile
patternTypeprefix_regexFile
statusactiveFile
lastSeenAt2026-11-25T16:33:44.855ZNo citation
rotationGuideNone extractedFile
verify.hasVerifyYesFile
verify.httpMethodsPOSTFile
verify.statusCodesBadRequest, OKFile
timeoutNone extractedFile
rateLimitNone extractedFile
errorHandlingSetVerificationError; unexpected HTTP response status %dFile
verify.urlshttps://api.box.com/oauth2/tokenFile
detection.keywordsboxLines 98–98
verification.endpointhttps://api.box.com/oauth2/tokenLines 221–221
verification.httpMethodPOSTLines 221–221
verification.authenticationMethodJSON client_id fieldLines 134–134
Parser completeness
  • Field status: Extracted
  • Field status: Extracted
  • Field status: Extracted
  • Field status: Extracted
  • Field status: Unknown
  • Field status: Unknown
  • Field status: Extracted
  • Field status: Extracted
  • Field status: Extracted
  • Field status: Extracted
  • Field status: Not scanned
Package files (1)
  • boxoauth.go