Skip to content
Code & CI · Secret guide

Leaked Cloudsmith API Key: what to do in the first hour

High severityDetected onlyLast verified · 5 min read

A Cloudsmith API key is the credential that lets a tool or a person publish, download and manage packages in a Cloudsmith repository. Depending on the account it belongs to, it can upload new package versions, read private packages and change repository settings. A key that can publish is especially sensitive, because a malicious package version pushed under your name can end up in the builds of everyone who installs from that repository. Refresh the key first, then check whether anything was pushed that you did not expect.

Check your GitHub account for leaked secrets — free

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

What a Cloudsmith API Key looks like

Cloudsmith API keys begin with csa_, followed by a long run of hexadecimal characters and a few more letters and digits:

csa_…XXXX   Cloudsmith API key (masked)

The csa_ prefix is specific enough that a match in a file deserves attention. The key is usually set in a variable such as CLOUDSMITH_API_KEY, in a package manager configuration, or in the command line tool’s own settings file. Cloudsmith issues a few kinds of credential, and they are not interchangeable. A personal API key belongs to one user. A service account key is not tied to a person and is meant for CI and automation. A read-only entitlement token is created per repository and is used to share private packages with others.

Do not treat a read-only entitlement token as harmless because it is read-only. It still gives access to the packages it covers, and it should be refreshed when it leaks, just like a key that can publish.

How Cloudsmith API Keys get leaked

  • CI configuration. A pipeline file that contains the key in plain text instead of referencing a secret variable, committed to a public repository.
  • Package manager settings. A .npmrc, pip.conf, .gemrc or similar file that holds the key in a URL, copied into a repository or a Docker image.
  • Command line history. A login command or upload command typed with the key on the line, saved to a shared shell history.
  • Build logs. A step that prints its configuration or the full command it ran, which then appears in the CI log.
  • Container images. A Dockerfile that copies the key into a layer, which remains in the image even after a later step deletes the file.

What to do in the first hour

  1. Refresh the key. Open the account settings in Cloudsmith, go to the API key section that matches the key you found, and refresh it. Refreshing a personal API key permanently disables the current one, so the leaked value stops working as soon as the refresh is done.
  2. Update your CI and tools with the new value. Store it as a secret variable in the CI system, not in a configuration file. Every pipeline and developer machine that used the old key will need the new one.
  3. Review uploads. Check the packages pushed to your repositories in the period since the key may have been exposed. Look for versions you did not build, unfamiliar publishers, and packages whose build time does not match a pipeline run.
  4. Check entitlement tokens for the repositories the key could reach. If a read-only token was also stored in the same place, refresh it too, because anyone with its code can still download the packages.
  5. Remove unexpected packages. If a version was pushed that you did not build, remove it or mark it as unsafe, and rebuild your dependent software from clean sources.
  6. Clean the code. Remove the value from the files, switch to a secret reference, and check the history for older copies. 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 Cloudsmith

Cloudsmith’s documentation describes personal API keys in the web app under your profile menu, and service account keys under the account’s services page. For a personal key, the documented way to replace it is to refresh it, which disables the current value. For a service account, the documented route is the refresh button on the service’s page, which also requires owner or manager rights in the organization. Deleting a service removes its API key permanently. The API key documentation is at docs.cloudsmith.com. The menu wording could not be confirmed against the live interface for this guide, so follow the labels in your own account.

How LeakWatch detects it

The rule is called “Cloudsmith API Key”. It looks for the prefix csa_, followed by thirty hexadecimal characters and six more letters or digits, and the match must end at a quote, a space, a semicolon, a line break or the end of the line. A key cut short is not reported. The severity is high, with the impact class for identity and code access. This type is not checked live: LeakWatch does not call Cloudsmith with the value it finds.

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

Is a refreshed key enough, or should I also change the service account?

Refreshing the key is what stops the old value from working. If the leaked key belonged to a service account, also review which pipelines use it, and make sure the new value is stored in a secret manager and not in the repository.

Can someone use the key to read my private packages?

Yes, if the key has read access to them. Read access alone can expose internal code and dependencies. Check the access logs if Cloudsmith provides them for your plan, and refresh any entitlement token that could reach the same packages.

What if I only see the key in a local config file?

A file on your own machine is still a leak if it was ever copied, synced to a backup, or shared with a colleague. Refresh the key, update your local tools, and keep the new value in a file that is excluded from version control.

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

LeakWatch is not affiliated with Cloudsmith.