Skip to content
Code & CI · Secret guide

Leaked Percy Token: what to do in the first hour

Medium severityDetected onlyLast verified · 5 min read

A Percy token is the project token that a test pipeline uses to upload visual snapshots to Percy, the visual testing service from BrowserStack. The token is write-only for the project, which limits what it can do: it cannot read your existing snapshots, but it can add builds to the project. Someone holding it can therefore push screenshots that look like your own test results, or flood the project with builds that hide the real ones. The risk is mostly to the integrity of your review process and to your build quota. Regenerate the token first, then review the builds that were added.

Check your GitHub account for leaked secrets — free

Provider
Percy
Severity
Medium
Impact
SaaS account access and billing
Checked live by LeakWatch
No

What a Percy Token looks like

Percy project tokens are a 64-character string of lowercase hexadecimal digits. Newer tokens from some Percy products begin with a short product prefix, such as auto_ for automated testing and app_ for mobile app testing, followed by a hash. The masked form below shows the general layout:

PERCY_TOKEN   environment variable name
…XXXX         token value (masked)

The environment variable name PERCY_TOKEN is the usual place the token appears, and it is set in CI settings or in a shell before a test run. Because the value is hexadecimal, a bare string does not identify itself. The rule in LeakWatch therefore needs the variable name near the value. Keep the name and the value together in mind when you search your repository and logs, since the variable name is often the easiest thing to find.

How Percy Tokens get leaked

  • CI configuration committed to a repository. A workflow file that sets the token as a plain value rather than referencing a secret, pushed to a public or shared repository.
  • Shell scripts. A test script that exports the variable with the value written in, then runs in a shared environment.
  • Logs. A pipeline step that prints the environment, or a test runner that echoes its configuration when it fails.
  • Shared snippets. A value pasted into a bug report or a forum post when a snapshot upload failed.
  • Forked repositories. A repository that carries the value in its history, copied into forks that are then made public.

What to do in the first hour

  1. Regenerate the token. Sign in to Percy with admin access, open the account settings for the project, and regenerate the project token. Regenerating replaces the old value, so the old one stops working.
  2. Update every pipeline that uploads snapshots to the project. Store the new value as a secret in the CI system, and not in a file in the repository.
  3. Review the builds. Look at the builds on the project for the period since the exposure. Check for builds you did not start, for unfamiliar branch names, and for snapshots that do not match the product.
  4. Check the approvals. If a build was approved, review the approvals in the same period. An approved build with unexpected screenshots can let a change through review.
  5. Check the build quota. A flood of builds uses up your plan, so confirm your usage is in line with what your team normally runs.
  6. Check the rest of the file. Revoke other credentials kept with the token, such as the test service keys in the same pipeline.
  7. Clean the repository. Remove the value from current files, rewrite history if the repository was public, and see I accidentally pushed an API key to GitHub for the full order.

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 Percy

Percy’s documentation on this topic describes regenerating the token from the project settings page, and only an organization admin can do that. Open the project in Percy, go to its settings, and click the control that regenerates the token. The new value replaces the old one. Anyone with access to the old token can still add builds until it is replaced, so do this before you clean the repository. Because the token is only used for uploads, check the pipelines after regenerating to make sure they still work. We did not confirm the exact labels or any grace period for the old value in the current interface, so check them before you rely on them.

How LeakWatch detects it

The rule is called “Percy Token”. It looks for the word percy, followed within about 40 characters by the variable name PERCY_TOKEN, an equals sign, and a value of exactly 64 lowercase hexadecimal characters, with a word boundary after the value. The match is not case-sensitive for the name. The severity is medium, with the SaaS impact class, because the token adds builds to a project but cannot read its existing snapshots. This type is not checked live: LeakWatch does not send the value to Percy, so a finding means the variable and a matching value were seen together, not that the token is still valid.

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

Can someone see my screenshots with this token?

Not through the token itself, since it is write-only for uploads. The risk is that the token can add builds, which can disrupt your review process and your quota. Check the builds for unexpected screenshots.

Do I need to tell my team?

Yes, if a pipeline that others rely on will be interrupted, or if approvals may have been affected. A short note in the team channel helps people know which builds to trust.

How do I keep the token out of the repository?

Store it as a secret in your CI system and reference it by name. Do not set it in a shell script or a workflow file that is committed.

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

LeakWatch is not affiliated with Percy.