Salesforce OAuth Token
Detects Salesforce OAuth tokens in the two shapes Salesforce's own documentation shows: the opaque access token, which doubles as a session ID and begins with the 15-character org ID (00D...) and an exclamation mark, and the refresh token beginning 5Aep861. An access token gives API access to the org's data as the user who authorised it; a refresh token can be exchanged for new access tokens, so a stolen one gives continuing access to that data over the REST API. JWT-based access tokens, which an app must opt in to, are not covered.
- Type
- regex
- Engine
- universal
- Confidence
- medium
- Confidence justification
- Medium confidence. The access-token shape is well attested: three examples in Salesforce Help share it exactly (org ID, !, 96-character body) and TruffleHog's production detector pins the same structure, so the org-ID prefix and separator make a chance match unlikely. The refresh-token shape is less certain: one Salesforce example and TruffleHog agree on the 5Aep861 prefix but not on length, and Salesforce's rotation example shows a refresh token with a different beginning. Salesforce publishes examples, not a format specification, and describes its tokens as opaque, so both regexes can go stale without notice; a single token therefore stops at 75 and needs a Salesforce or OAuth term.
- Jurisdictions
- global
- Regulations
- Criminal Code Act 1995 (Cth)
- Frameworks
- CIS Controls, ISO 27001, NIST CSF, SOC 2
- Data categories
- credentials, security
- Scope
- narrow
- Risk rating
- 8
- Platform compatibility
- Purview: Compatible, GCP DLP: Unsupported, Macie: Unsupported, Zscaler: Compatible, CrowdStrike DLP: Unsupported, Palo Alto: Unsupported, Netskope: Unsupported
Pattern
(?-i)(?<![A-Za-z0-9])(00D[A-Za-z0-9]{12}(?:!|%21)[A-Za-z0-9_.]{90,130})(?![A-Za-z0-9_.])
Corroborative evidence keywords
salesforce, force.com, sfdc, access_token, refresh_token, instance_url, session id, api key, api_key, apikey, access key, access token, auth token, authorization, bearer, conn str, connection string, connectionstring, cookie, credential (+40 more)
Proximity: 300 characters
Should match
00D000000000ABC!ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef— Bare access token / session ID (15-character org ID, !, 96-character body); 65 discovery tier{"access_token": "00D000000000ABC!ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef", "instance_url": "https://yourInstance.salesforce.com", "token_type": "Bearer"}— Access token in a token-endpoint JSON response; 75 tierhttps://localhost:8443/callback#access_token=00Dxx0000000XYZ%21abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_.abcdefghijklmnopqrstuvwxyz012345&instance_url=https://yourInstance.salesforce.com— Access token in a user-agent flow redirect URL, where the ! is URL-encoded as %21; 75 tierSalesforce connected app refresh_token: 5Aep861ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmn.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKL_— Refresh token with a Salesforce label; 75 tiersfdc refresh tokens 5Aep861ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmn.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKL_ 5Aep8610123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN_ABCDEFGHIJKLMNOPQRSTUVWXYZ==— Two distinct Salesforce refresh tokens in one file with context; the 85 tier needs two distinct tokens of the same kind (one token, or the same token repeated, stays below 85)
Should not match
Salesforce org ID 00D000000000ABC— An org ID on its own is an identifier, not a tokenSalesforce access_token 00D000000000ABC!ABCDEFGHIJKLMNOPQRSTUVWXYZ— Org ID and ! followed by a body far too short to be a session IDSalesforce access_token 005000000000ABC!ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef— Same shape but beginning 005 (a user ID prefix), not the 00D org ID prefixSalesforce refresh_token 5Aep861ABCDEFGHIJKLMNOPQRSTUVWXYZ— 5Aep861 prefix followed by a body far too short to be a refresh tokenrotate the Salesforce refresh_token for the integration user— Prose mention without a token valuetemplate example placeholder record identifier— Template/sample context should be excluded even when anchor words are present
Known false positives
- Expired access tokens. A session ID stops working at the org's session timeout, so one found in an old debug log or support ticket is usually dead; a refresh token is longer-lived. Mitigation: The pattern cannot test validity. Treat a refresh token as live until it is confirmed revoked, and check the age of the content before escalating an access token.
- The sample tokens from Salesforce's own documentation (for example 00Dx0000000BV7z!AR8AQ...) copied into internal wikis and integration guides. Mitigation: The template-exclusion dictionary suppresses content framed as an example or placeholder; an unframed copy of a documentation sample still matches.
- Tokens this pattern does not match. JWT-based access tokens (opt-in per connected app) are ordinary three-part JWTs with no Salesforce-specific prefix, and Salesforce's refresh-token-rotation example shows a refresh token that does not begin 5Aep861. Mitigation: Documented as a known scope limitation. Pair with a generic JWT detector where JWT-based access tokens are enabled; the pattern needs a version bump if Salesforce's token shapes change.
References
- OAuth 2.0 Web Server Flow - Salesforce Help (example token response; access_token is a 15-character 00D org ID, !, then a 96-character body)
- OAuth 2.0 Refresh Token Flow - Salesforce Help (example access_token whose prefix equals the org ID in the identity URL; the rotation example shows a refresh token that does not begin 5Aep861)
- OAuth 2.0 User-Agent Flow - Salesforce Help (redirect URL example with the ! URL-encoded as %21 and a refresh_token beginning 5Aep861)
- Access Tokens - Salesforce Help (opaque tokens are the default; JWT-based access tokens must be enabled per app)
- REST API Developer Guide, OAuth refresh token - Salesforce Developers (the access token acts as a session ID)
- TruffleHog production Salesforce access-token detector (00 + 13 alphanumerics, !, 96 characters of letters, digits, underscore and dot)
- TruffleHog production Salesforce refresh-token detector (5AEP861 followed by 80 or more characters of letters, digits, dot, underscore and =)