Orphaned access tokens and OAuth grants
| Class | Secrets, Persistence |
|---|---|
| Also known as | Stale tokens, forgotten integrations |
| MITRE ATT&CK | T1550.001 Application Access Token (use of the token) |
| Typical severity | High |
| Affects | Personal access tokens, API tokens, service account credentials and the OAuth grants given to outside applications |
An orphaned access token is a token that still works after the person, project or integration it was made for has gone. An orphaned OAuth grant is the same problem one level up: an outside application that a user once allowed to act on their account, and that keeps that permission after nobody uses it. Whoever later obtains such a token can call the service with all of its permissions, and the owner has no reason to notice. Revoking tokens at logout exists to prevent exactly this, a grant still valid for an application "of which the end-user is not aware".1
Description
A token is created for one job: a deploy script, a CI pipeline, a test of a new tool, a contractor's access. The job ends and the token stays, in an old environment variable, a script or the settings of a tool the team stopped using. Because it was created once and never typed in again, nobody remembers it exists.
The token lives apart from the password and second factor of the account that made it. A call made straight to an API with a token skips multi-factor authentication, and a password change may leave the token untouched.2 Resetting a departing employee's password can leave their tokens working. On GitHub a personal access token carries the same access as its owner, narrowed by its scopes, and becomes inactive when that owner loses access to the resource.3
Mechanism
In OAuth, a user approves an application once. The service then issues the application a short-lived access token and often a refresh token, which the application exchanges for new access tokens without asking the user again. A refresh token carries the whole scope of access granted to that client, so an attacker who copies one can keep minting fresh access tokens.4 At an email service, for example, the refresh token is what gives an application long-term access to the mailbox.2
The second path is a credential that was meant to be replaced and was missed. After a leak, a team rotates the keys it knows about. A token believed to be unused is skipped, and the attacker who copied it during the leak can use it later.
Notable incidents
On 18 October 2023 an attacker who had broken into Okta's support system obtained a set of Cloudflare credentials.5 Cloudflare meant to rotate all of them, but missed one service token and three service accounts out of thousands, because it "mistakenly" believed they were unused.6 One was a Moveworks service token with remote access to its Atlassian server; another was a Smartsheet service account with administrative access to Jira.
From 14 November the attacker used them to probe, then read 202 wiki pages and 36 Jira tickets, searching for words such as "secret" and "token". On 16 November they created an Atlassian user that looked like an employee, a step described in Rogue administrator account, and on 22 November installed the Sliver command-and-control framework through the ScriptRunner for Jira plugin. They viewed 120 code repositories and downloaded 76. Cloudflare detected the activity on 23 November, cut access on 24 November, and then rotated more than 5,000 production credentials and reimaged every machine in its network. It attributes the attack to a nation-state actor and reports no customer data or systems affected.6
Detection
Each provider keeps a list of live tokens and authorized applications. On GitHub, the profile picture, Settings, then Applications in the Integrations section shows the Authorized OAuth Apps and Authorized GitHub Apps tabs, and any entry nobody recognizes or that is out of date should be revoked there.78 Personal tokens are under Settings, Developer settings, Personal access tokens.3 An organization owner sees every fine-grained token that can reach the organization under the organization's Settings, Personal access tokens, Active tokens, filtered by Owner. Classic tokens do not appear in that list, and unless the organization restricts them, they keep working until they expire.9
Watching traffic rarely catches an attacker using such a token, because the calls look like the workflow the token was made for.2
Prevention
Expiry on every token
A token with an end date stops working by itself. GitHub revokes a personal access token on its expiration date, and revokes OAuth and personal tokens that have not been used for one year.10 A fine-grained token defaults to 30 days when created from a template link, and an organization can set a maximum lifetime that blocks tokens with no expiry.3 Cloudflare's API token form has optional Token expiration and Client IP Address Filtering fields.11 Tokens should also carry only the permissions their job needs, as Over-privileged access token explains.
Tokens that belong to the job
For access on behalf of an organization, or for a long-lived integration, GitHub advises a GitHub App over a personal token.3 The App's user tokens expire after eight hours by default.10 Revoking an app authorization revokes every token issued under it.10 Only the person who authorized a GitHub App can revoke that authorization; an organization owner can uninstall the app from the organization instead.8 After a leak, every credential on the list is rotated, including the ones thought to be unused.
Revocation in your own app
An application that signs users in with OAuth should revoke its tokens when the user logs out, changes account or uninstalls it. RFC 7009 defines the request: a form-encoded POST to the provider's revocation endpoint, over HTTPS, after which the token cannot be used again.1
POST /revoke HTTP/1.1
Host: server.example.com
Content-Type: application/x-www-form-urlencoded
Authorization: Basic <client credentials>
token=45ghiukldjahdnhzdauz&token_type_hint=refresh_tokenAn application that issues refresh tokens itself should make them expire after a period without use, and either bind them to the client or rotate them on each use, so that a copied token is detected when both parties present it.4 Session management covers the lifetimes in detail.
Prompt for a coding agent
List every access token, API key and OAuth client this project uses: in environment files, CI settings, deployment config and code. For each one, say which service it belongs to, what it is used for and where it is read. Mark any that nothing in the code reads any more. Where the app signs users in with OAuth, add a call to the provider's token revocation endpoint when a user logs out or disconnects their account. Do not delete or change any key yourself; give me the list so I can revoke the unused ones at each provider.
In SecFlash
SecFlash reports SF-CLD-314 on the Cloud page when Cloudflare API tokens have not been used in 90 days, or are more than a year old with no end date.
See also
- Over-privileged access token
- Exposed credentials in source code repositories
- Session hijacking
- Rogue administrator account
- Secrets management
- Principle of least privilege
- Category: Persistence
References
- a b Lodderstedt, T., Dronia, S. and Scurtescu, M. (August 2013). "OAuth 2.0 Token Revocation". RFC 7009. IETF.
- a b c MITRE. "Use Alternate Authentication Material: Application Access Token (T1550.001)". MITRE ATT&CK.
- a b c d GitHub (2026). "Managing your personal access tokens". GitHub Docs.
- a b IETF (January 2025). "Best Current Practice for OAuth 2.0 Security". RFC 9700. IETF.
- back Gatlan, S. (1 February 2024). "Cloudflare hacked using auth tokens stolen in Okta attack". BleepingComputer.
- a b Prince, M., Graham-Cumming, J. and Bourzikas, G. (1 February 2024). "Thanksgiving 2023 security incident". The Cloudflare Blog.
- back GitHub (2026). "Reviewing your authorized OAuth apps". GitHub Docs.
- a b GitHub (2026). "Reviewing and revoking authorization of GitHub Apps". GitHub Docs.
- back GitHub (2026). "Reviewing and revoking personal access tokens in your organization". GitHub Docs.
- a b c GitHub (2026). "Token expiration and revocation". GitHub Docs.
- back Cloudflare. "Create API token". Cloudflare Docs.