AppInspected

Fix guides

There's a GitHub token in your website's code. Revoke it, then check what it touched.

Last reviewed October 30, 2026 against the providers' current documentation.

The short version

Delete the token now: on GitHub, Settings → Developer settings → Personal access tokens, then Delete next to it (for a gho_ token, revoke the app under Settings → Applications → Authorized OAuth Apps). Then read your Security log and the repositories the token could reach for changes you didn't make. Move the GitHub calls your page made into server code, using a new fine-grained token or a GitHub App with only the access that feature needs. GitHub only revokes tokens automatically when they're pushed to a public repository or gist, so don't count on that for a token in your website.

Why it matters

GitHub's own docs say to treat access tokens like passwords. A personal access token acts as your account on GitHub, with whatever it was given: a classic token (ghp_) with the repo scope can read and push to every repository you can, private ones included. Someone who copies it from your JavaScript can download your private code, read the secrets committed in it, open or merge changes, or push code that your next deploy ships to your users. Classic tokens and OAuth app tokens (gho_) are long-lived, and a fine-grained token (github_pat_) can be set to never expire, so the token keeps working until someone revokes it.

Fix it, in this order

  1. Work out which kind of token it is

    The prefix tells you. ghp_ is a personal access token (classic) and github_pat_ a fine-grained personal access token, both tied to a user account. gho_ is a token a user granted to an OAuth app. ghu_ and ghr_ are a GitHub App's user access token (expires after 8 hours by default) and its refresh token (6 months). ghs_ is a GitHub App installation token, which expires after 1 hour. Search your code for the token to find where it came from, usually a VITE_GITHUB_TOKEN or NEXT_PUBLIC_ variable.
  2. Delete or revoke it

    For a personal access token: profile picture → Settings → Developer settings → Personal access tokens → Fine-grained tokens or Tokens (classic) → Delete next to the token. GitHub notes that deleting a token that created a deploy key deletes that key too. For a gho_ token: Settings → Applications → Authorized OAuth Apps, open the menu next to the app and choose Revoke. If the token isn't in your account, anyone can report it to GitHub's credential revocation API (a POST to /credentials/revoke on api.github.com, sent without authentication); GitHub revokes valid tokens and notifies their owner. Revoked tokens can't be turned back on.
  3. If it's a GitHub App token, check the private key

    A ghs_ installation token dies within the hour, and you can end it sooner with DELETE /installation/token. But your app needs its private key to create those tokens. If that key, or a ghr_ refresh token, ever reached the browser, generate a new private key in the GitHub App's settings (Developer settings → GitHub Apps), switch your server to it and delete the old one: GitHub requires a new key before you can delete the last one.
  4. Check what the token did

    Open Settings → Security log (under Archives); it lists the last 90 days of actions on your account, filterable by action, repo and created. Look for new tokens, SSH keys, deploy keys, OAuth apps, and changes to repositories. Then, in each repository the token could reach, check recent commits, branches, releases, Actions workflow files and repository secrets for anything you didn't add. If you belong to an organization, ask an owner to check its audit log; enterprise audit logs can search by a hash of the token (hashed_token:).
  5. Move GitHub calls off the page

    The browser should never hold a GitHub token that can write, or read anything private. Put the calls behind a small server endpoint (an API route, a Supabase Edge Function, a Cloudflare Worker) that reads the token from a server-only environment variable, requires a logged-in user and rate-limits requests. Use a new fine-grained token limited to the one repository and the permissions the feature needs (GitHub recommends fine-grained over classic tokens), or a GitHub App, whose installation tokens expire after an hour. For GitHub Actions, use the built-in GITHUB_TOKEN instead of a personal token.
  6. Clean up the old copies

    Remove the token from your .env files and source, rebuild, and deploy. Old builds stay in browser caches, CDN caches and web archives, which is why revoking comes first. If the token was also committed to a repository, GitHub revokes it automatically once it's pushed to a public repository or gist; it's revoked either way after step 2, but rotate any other secrets committed next to it.

Or ask your AI tool to do it

Paste this into Lovable, Bolt, Cursor, Claude Code or whichever tool built your app. Review what it changes before you deploy.

My website's frontend contains a GitHub token (it starts with ghp_, github_pat_, gho_, ghu_ or ghs_). List every place in the code that uses a GitHub token or calls the GitHub API (api.github.com, Octokit, raw.githubusercontent.com with a token), and what each call does (read a repo or file, create an issue, commit content, trigger a workflow, and so on). Remove every GitHub token from client-side code and from any VITE_, NEXT_PUBLIC_, REACT_APP_ or EXPO_PUBLIC_ variable. Move each call into a server-side endpoint that reads the token from a server-only environment variable, requires a logged-in user where the feature allows it, validates the input (for example an allowlist of repositories and paths), rate-limits requests, and returns only what the page needs. Public data that needs no token should be fetched without one. Tell me the exact fine-grained token permissions (which repository, which permissions, read or write) the server needs. Finally, remind me to delete the old token in GitHub's Developer settings and to check my Security log.

How this happens

Usually a feature that talks to GitHub from the page: a portfolio that lists your repositories, a contact or feedback form that opens an issue, a small CMS that commits Markdown to a repo, or a dashboard that triggers a workflow. Calling api.github.com without a token hits rate limits or can't see private repos, so an AI coding tool asked to fix the error adds a token, often a classic one with full repo scope, through a VITE_ or NEXT_PUBLIC_ variable that is copied into the browser bundle.

Check that it's really fixed

After you deploy, run the free check. It reads your live site the way an attacker would and tells you if any secret key is still visible.

Topic check: Exposed API key checker

Find the other leaks before someone else does

The free check reads your home page and its scripts. The website security report goes through up to 30 pages and 40 JavaScript files, plus .env and .git files, security headers, cookies and CORS, domain and email records, and libraries with known vulnerabilities. Every finding comes with the fix for your host and a prompt for your AI tool.

$19 once, including 20 runs over 30 days so you can fix things and check again.

Get the report, $19 See an example report

Example report header: a score out of 100, findings by severity, Download PDF and Email me this report.

Questions

Will GitHub revoke the token for me?

Not reliably. GitHub's docs say it automatically revokes a valid OAuth, GitHub App or personal access token pushed to a public repository or public gist, and personal access tokens and OAuth tokens unused for a year. They don't say GitHub watches deployed websites, so a token in your JavaScript can stay live. Delete it yourself.

My token only has read access. Is that still a problem?

It depends on what it can read. A token with access to private repositories hands out your private code and anything committed in it. A fine-grained token that can only read public repositories exposes little, but it still counts against your account's rate limits, and there's no reason for it to be in the page: public GitHub data can be fetched without a token or through your server.

Can I make a GitHub token safe to use in the browser?

No. Anything in your JavaScript can be copied. If the page needs GitHub data, fetch it on your server. If users act on their own GitHub accounts, use a GitHub App or OAuth app, where each user signs in and gets their own token, and keep the app's client secret and private key on the server.

I deleted the token. Do I need to do anything else?

Check the security log and the repositories it could reach, as in step 4, and look for anything an attacker could use to get back in: new tokens, SSH or deploy keys, OAuth apps, collaborators, or changed workflow files. Then rotate other secrets that were in repositories the token could read.

Does your check try the token?

No. The free check is passive: it finds ghp_, gho_, ghu_, ghs_, ghr_ and github_pat_ tokens in your page and its JavaScript, shows them cut short, and never sends them to GitHub. Only your GitHub settings can tell you whether the token is still active and what it did.

Sources

Related guides