Skip to content
Code & CI · Secret guide

Leaked Travis CI Access Token: what to do in the first hour

High severityDetected onlyLast verified · 4 min read

A Travis CI access token is the API token of a user. It lets a script call the Travis CI API as that user: list repositories, read builds and logs, trigger builds, restart or cancel them and, depending on the rights of the account, change repository settings such as environment variables. The danger is the CI itself: a triggered build runs your configuration and can reach the secrets set for that repository. Regenerate the token first, then check what it did.

Check your GitHub account for leaked secrets — free

Provider
TravisCI
Severity
High
Impact
Source code and build access
Checked live by LeakWatch
No

What a Travis CI Access Token looks like

Travis CI API tokens are short strings of letters and digits, 22 characters long in the shape LeakWatch looks for, with no prefix:

TRAVIS_TOKEN=XXXX…   (22 letters or digits, no prefix; shortened here)

They appear as TRAVIS_TOKEN or TRAVIS_API_TOKEN, in an Authorization: token … header of a curl call, in the travis command line tool after login, and in scripts that trigger builds. A token can be obtained by running a command-line login, or from the profile page of the Travis CI website. Because the format is just a short alphanumeric string, the context is what identifies it. Do not mix it up with encrypted values in a .travis.yml (secure: entries), which are encrypted with the repository’s public key and are not API tokens.

How Travis CI Access Tokens get leaked

  • Trigger scripts. A script that starts a downstream build through the API, committed with the token.
  • Environment files. A .env or a shell profile with TRAVIS_TOKEN committed by accident.
  • Public build logs. A build that prints the token in a debug step, in a log that anyone can read for an open source repository.
  • Configuration files. A .travis.yml that holds the token in plain text instead of an encrypted or repository setting.
  • Pasted commands. A travis login or curl example copied into an issue or documentation with the real value.

What to do in the first hour

  1. Regenerate the token. Sign in to Travis CI, open your account settings and the place where your API token is shown, and generate a new one (see the link below). Test that the old value no longer authenticates.
  2. Update the clients that use the token and store the new value in a secret store.
  3. Review builds. Look at builds on your repositories for runs you did not trigger, restarted builds, and builds on unusual branches or with custom configuration.
  4. Check repository settings. Review environment variables, cron jobs and other settings. If an attacker could edit variables or run builds, assume the variables are known and rotate them.
  5. Look at public logs. For open source repositories, read recent logs for printed secrets, and delete the logs if the service allows it.
  6. Check connected services. The deploy keys, GitHub access and notification webhooks linked to the account may have been touched. Remove those you do not recognize.
  7. Clean up the code and history. 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 Travis CI

The API token is shown on the settings page of your Travis CI account, after you sign in with your source control account. Open the account settings and look for the section where the API token is displayed, with an option to regenerate it. Travis CI has more than one web address, depending on the hosting and plan, so make sure you are on the one where your repositories appear. A person has not confirmed the exact menu wording for this guide, and the interface can change, so follow Travis CI’s documentation.

How LeakWatch detects it

The rule is called TravisCI Access Token. It is contextual: the word travis in any letter case, then a short label, an assignment such as =, : or =>, optional quotes and spaces, and exactly 22 letters or digits, ending at a quote, a space, a semicolon or the end of the line. A longer or shorter value is refused, and the word travis must be present near the assignment. The prefilter keyword is travis. The severity is high. This type is not checked live: LeakWatch does not send any request to Travis CI with the token it found. Because 22 characters is short, a reported value can be a false positive, so read the context before concluding.

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

Does the token give access to all my repositories?

It carries the rights of the user, so it reaches the repositories that account can access on Travis CI.

Are secure: values in .travis.yml API tokens?

No. They are encrypted for one repository and are safe to publish in the sense that they cannot be read without the private key, though they may protect real secrets.

Why regenerate rather than just remove it from the code?

The value stays in the git history, forks and caches. Only regeneration makes the leaked value useless.

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

LeakWatch is not affiliated with TravisCI.