CCyberwiki

Over-privileged access token

Over-privileged access token
ClassSecrets, Access control
Also known asOver-scoped token, excessive token permissions
CWECWE-250: Execution with Unnecessary Privileges
OWASP Top 10A01:2025 Broken Access Control
Typical severityHigh when the token can write or delete
AffectsPersonal access tokens, CI workflow tokens, payment and AI provider keys, OAuth access tokens

A nightly script that reads issues from one repository can hold a token that reaches every repository its owner can reach. Such an over-privileged access token, a token or API key granted more than the program holding it needs, works as intended until it leaks. From then on, everything it is allowed to do is open to whoever holds it. Unneeded privilege enlarges the damage of every other weakness, a leak among them.1

Description

A service decides what a request may do from two things: the account that owns the token and the scope attached to the token. At GitHub, a token can do what its owner can do, narrowed by the scopes or permissions granted to it, and it can never add access the owner lacks.2 That leaves the scope as the only control the developer sets on the token itself. In OAuth 2.0 the client asks for a scope as a list of space-separated strings defined by the provider, and each string adds a further range of access to the token that is issued.3 Granting more than a program needs breaks least privilege, which the OWASP Top 10:2025 counts as broken access control.4

Several providers issue a broad and a narrow kind of credential side by side, and the developer picks one when creating it:

Table 1. Broad and narrow credentials at three providers
ProviderBroad credentialNarrow credential
GitHubPersonal access token (classic): every repository the user can reach, in every organization they belong toFine-grained token: one owner, chosen repositories, permission by permission at read, write or admin
StripeSecret key: any action in the accountRestricted key (rk_live_): Read, Write or None for each resource
Hugging FaceWrite token: write access to every repository the user can write toFine-grained token: access to named models or organizations

Sources for the table: GitHub,2 Stripe5 and Hugging Face.6

Mechanism

A small script reads open issues from one repository each night. Its author creates a classic token and ticks repo, the scope GitHub suggests for command-line access to repositories. A classic token reaches every repository the author can reach, including those of every organization the author belongs to.2 If the script's configuration file is later committed to a public repository (see Exposed credentials in source code repositories), the finder receives all of that access, although the script needed read access to the issues of one repository.

CI workflows show the same pattern. GitHub creates a fresh GITHUB_TOKEN for each job, limited to the repository and valid until the job ends, at most six hours on GitHub-hosted runners.7 Any action in the job can read that token through the github.token context, even when the workflow never passes it in.8 A job whose token can write contents and releases hands that write access to every third-party action it runs; Secret exposure in CI/CD workflows and Software supply chain compromise describe how such an action turns hostile.

Notable incidents

In November 2023, researchers at Lasso Security searched GitHub and Hugging Face for Hugging Face tokens and found 1,681 valid ones, giving access to 723 organization accounts.9 Of these, 655 tokens had write permissions, 77 of them to organizations, including the accounts behind Meta's Llama 2, BigScience Workshop's Bloom and EleutherAI's Pythia models.9 The Register reported that this access was enough to change 14 datasets with tens of thousands of monthly downloads and to take more than 10,000 private models.10 Meta, Google, Microsoft, VMware and other organizations revoked the tokens, many on the day they were told.9 A read-only token in the same places can only read repositories, so it would have exposed private models without allowing changes to published ones.6

Detection

List every token and key the application and its pipelines use, and compare each one with the calls the code makes. On GitHub, tokens are under Settings, Developer settings, Personal access tokens; a classic token with repo or an admin scope used by a single script is a candidate for replacement. In workflow files, a missing permissions key or permissions: write-all marks a job whose token is not narrowed. In Stripe, the account's request logs show which API methods a key calls.5

Prevention

Give each program its own token, scoped to its task, with an expiry date. With one token per app, revoking one leaves the others working.6 On GitHub, prefer fine-grained tokens to classic ones and set an expiration.2 When a narrower key replaces a broad one, rotate or delete the broad one; Stripe allows a delayed expiry of up to seven days for the old secret key.5

GitHub Actions

Set the permissions key at the top of the workflow and widen it per job. Once any permission is named, every permission not named is set to none, and permissions: {} removes all of them.11

permissions:
  contents: read

jobs:
  open-issue:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      issues: write

Stripe

A restricted key replaces the secret key in server code without other changes. Map each call to a permission: PaymentIntent.create needs Payment Intents: Write, Customer.retrieve needs Customers: Read. A call outside the granted permissions fails with an invalid request error.5 Any key given to an AI agent should be a restricted key.5

Prompt for a coding agent

List every API key, access token and workflow token this project and its CI workflows use. For each one, list the API calls or git operations the code makes with it. In every GitHub Actions workflow, add a top-level permissions block set to contents: read and give each job only the extra permissions its steps need. For other providers, write down the narrowest key type and permissions that cover the calls you found, for me to create in the provider dashboard. Do not create, print or rotate any key yourself.

In SecFlash

SecFlash reports a GitHub Actions workflow whose token has more access than its steps need as SF-SEC-804 on the Security page.

See also

References

  1. back "CWE-250: Execution with Unnecessary Privileges". Common Weakness Enumeration. MITRE.
  2. a b c d GitHub (2026). "Managing your personal access tokens". GitHub Docs.
  3. back Hardt, D., ed. (October 2012). "The OAuth 2.0 Authorization Framework", RFC 6749, section 3.3. IETF.
  4. back "A01:2025 Broken Access Control". OWASP Top 10:2025. OWASP Foundation.
  5. a b c d e Stripe (2026). "Restricted API keys". Stripe Docs.
  6. a b c Hugging Face (2026). "User access tokens". Hugging Face Hub documentation.
  7. back GitHub (2026). "GITHUB_TOKEN". GitHub Docs.
  8. back GitHub (2026). "Use GITHUB_TOKEN for authentication in workflows". GitHub Docs.
  9. a b c Lanyado, Bar (December 2023). "1500+ HuggingFace API Tokens were exposed". Lasso Security.
  10. back Jones, Connor (4 December 2023). "Exposed Hugging Face API tokens offered full access to Meta's Llama 2". The Register.
  11. back GitHub (2026). "Workflow syntax for GitHub Actions". GitHub Docs.