Skip to content
Payments · Secret guide

Leaked Salesforce Access Token: what to do in the first hour

Critical severityDetected onlyLast verified · 6 min read

A Salesforce access token is a bearer credential for the Salesforce APIs. Whoever holds a valid one can call the REST and SOAP APIs as the user it was issued to, with that user’s permissions: reading accounts, contacts, opportunities, cases and any custom object the profile can see, and writing to them if the profile allows. For many companies that is the full customer database, which makes this one of the more sensitive tokens to leak. Access tokens expire on their own, but the lifetime depends on the org’s session settings and can be hours, and a leaked refresh token can mint new ones. Revoke first, then investigate what the session touched.

Check your GitHub account for leaked secrets — free

Provider
Salesforce
Severity
Critical
Impact
Payments and customer data
Checked live by LeakWatch
No

What a Salesforce access token looks like

An access token, also called a session ID, is a long string made of an org-and-user part, an exclamation mark, and a long body:

00XXXXXXXXXXXXX!XXXXXXXX…XXXX   Salesforce access token (masked)

It starts with 00, then 13 letters and digits, then a !, then a body of 96 letters, digits, underscores and dots. In practice the first 15 characters identify the Salesforce organization, which is why they look alike across tokens of the same org. The ! in the middle is the easiest sign that you are looking at a Salesforce session value and not some other long string.

You will find it in an Authorization: Bearer header, in an access_token field of an OAuth response, in a SF_ACCESS_TOKEN or SALESFORCE_TOKEN style variable, or in the sid cookie of a browser session. Do not confuse it with the other credentials around it: the consumer key and consumer secret of a connected app, the security token appended to a password, and the refresh token. Those have different shapes and lifetimes, and a refresh token is more dangerous than the access token because it can be exchanged for new ones.

How Salesforce access tokens get leaked

  • Pasted API traces. A curl command or a Postman export with the Bearer header copied into an issue, a gist or a support ticket.
  • Integration scripts. A data-migration or sync script where a developer pasted a token to test quickly and committed it.
  • Logged OAuth responses. An application that prints the whole token response, including the access token and refresh token, in debug logs that end up in CI output.
  • Environment and config files. .env files, sfdx project files or deployment pipelines with an org login stored in clear text.
  • Browser sessions. A HAR file or a screenshot of developer tools shared for debugging, containing the session cookie or header.

What to do in the first hour

  1. Revoke the session or the grant. In Salesforce, sign in with an admin account, then end the session of the affected user and revoke the OAuth access of the connected app that issued the token (see the link below). Revoking the grant also kills the refresh token, so nothing new can be minted.
  2. Rotate the app credentials. If a connected app’s consumer secret or a refresh token was in the same file, rotate those too, and consider resetting the password of the integration user, which invalidates its existing sessions.
  3. Restrict the integration user. Check that the user the token belongs to has only the permissions the integration needs. A dedicated integration user with a narrow permission set limits what the next leak exposes.
  4. Read the login history. In Setup, open the login history and look at logins and API connections for that user since the exposure. Look for IP addresses and countries you do not recognize and for API clients you did not set up.
  5. Read the audit trail and the event logs. The setup audit trail lists configuration changes, and event monitoring, if your org has it, lists API calls and report exports. Large exports and queries on many objects are the signs of data theft.
  6. Check what could have been changed. Look for new users, changed permission sets, new connected apps, new Apex or flows, and changed email or API settings.
  7. Clean up the code and search for other secrets in the same repository. See I accidentally pushed an API key to GitHub.

Not sure what else leaked from the same repository? Run a free scan.

Not sure what else leaked? Run a free scan.

Revoke it at Salesforce

Salesforce tokens are managed from your org, after you sign in at the Salesforce login page with a user allowed to manage sessions and connected apps. Look for the section of Setup where active sessions are listed, and end the session of the affected user. Look for the section where OAuth connected apps and their usage are listed, and revoke the access of the app involved. Salesforce also documents revoking a token by sending it to its OAuth revoke endpoint; see the OAuth token revocation section of the Salesforce developer documentation. Your org may use a custom My Domain address, so sign in through it. A person has not confirmed the exact menu wording for this guide, and Salesforce changes its Setup pages often, so if what you see differs, follow the Salesforce documentation.

How LeakWatch detects it

The rule is called Salesforce Access Token. It looks for 00, followed by exactly 13 letters or digits, then a !, then exactly 96 characters among letters, digits, underscores and dots, with word boundaries around the whole string. The ! and the fixed lengths are what make a match reliable, so the rule does not need the word Salesforce nearby. A string with another length, with a different separator or without the ! is not reported. The rule does not check that the first digits really are an organization identifier, so any value of that exact shape is reported. The severity is critical. This type is not checked live: LeakWatch does not send the token to Salesforce, so a finding does not say whether the session is still valid. Treat it as live until you have revoked it.

LeakWatch detects this format but does not check it live: it can tell you the key is exposed, not whether it still works. Assume it does until you have revoked it.

FAQ

Access tokens expire. Do I still need to revoke it?

Yes. The token may still be valid for hours depending on session settings, and the expiry does not help if a refresh token leaked with it. Revoking the session and the grant removes both risks.

Does changing the user's password help?

Resetting the password of the user invalidates that user’s existing sessions in most setups, which is a useful extra step. Still revoke the connected app grant, and check the login history for what happened before.

Is the consumer secret of the connected app the same thing?

No. The consumer key and secret identify the app, and with other credentials they can be used to request new tokens. If they leaked beside the access token, rotate them as well.

Get alerted next time a secret leaks — create a free account

LeakWatch is not affiliated with Salesforce.