Skip to content
Databases & keys · Secret guide

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

Medium severityDetected onlyLast verified · 5 min read

A SecurityTrails API key gives access to SecurityTrails, a service that provides domain, DNS and IP history data used by security researchers, penetration testers and monitoring tools. The key is tied to your account, so whoever holds it can make queries that count against your plan and, depending on the plan, can reach the data your team has paid for. The data is mostly about internet infrastructure, so the sensitivity is moderate, but the quota and the account are still yours to protect. Replace the key first, then check the queries that were made with it.

Check your GitHub account for leaked secrets — free

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

What a SecurityTrails API Key looks like

SecurityTrails API keys are 32-character strings of letters and digits. They have no vendor prefix, so the way to spot one is by the name it is stored under, such as SECURITYTRAILS_API_KEY, or by the request that sends it:

SECURITYTRAILS_API_KEY="…XXXX"   SecurityTrails API key in an environment file (masked)

SecurityTrails’ documentation describes the key being sent in an HTTP header named APIKEY, and it also describes a query string option for cases where headers cannot be set. A query string puts the key into the URL, which many tools log, so the header is the safer choice wherever it works.

The key is created and listed on your account’s credentials page, and it is the same value that the control panel shows. Because the length and the character set are common to many keys, a match depends on the name next to it. A 32-character value next to the word SecurityTrails, in a file that calls the API, is a live credential.

How SecurityTrails API Keys get leaked

  • Command line tools. A scanning or research script with the key typed in, committed to a repository or copied into a shared notes file.
  • Shared configuration. A .env file or a tool’s settings file that is passed around a team or uploaded to a shared drive.
  • Notebooks. A notebook that queries domain data, with the key saved in a cell and published with the results.
  • Logs. A tool that writes full request URLs to its log, including the key in the query string.
  • Shared examples. A snippet pasted into a blog post, a forum or a support question to show how to make a query.

What to do in the first hour

  1. Create a new key. Sign in to SecurityTrails, open the credentials page, and create a new API key. Give it a note that says which tool will use it, so you can track it later.
  2. Switch your tools to the new key. Update every script, scanner and integration that used the old key, and confirm that a query works with the new value before you go on.
  3. Delete the old key. Once the switch is done, delete the old key using the delete option on the credentials page. Documentation from the provider describes this as the final step of a rotation.
  4. Review query usage. Check the usage for the period since the key may have been exposed. Look for query volumes you did not expect, and for queries at unusual hours or for domains your team does not monitor.
  5. Check the other secrets in the same file or tool, and rotate any credential stored alongside the key.
  6. Clean the code. Move the key into an environment variable, remove the value from the current files, and check the history for older copies. See I accidentally pushed an API key to GitHub.

Not sure what else leaked from the same project? Run a free scan.

Not sure what else leaked? Run a free scan.

Revoke it at SecurityTrails

SecurityTrails describes regenerating a key as a create-then-delete process, not a single reset button. Open the credentials page in your account, create the new key, move your applications to it and delete the old one with the delete option. The provider’s guide on this process is at docs.securitytrails.com. Because the old key keeps working until you delete it, do the deletion as soon as the switch is complete, and do not leave it in place for a convenient later date.

How LeakWatch detects it

The rule is called “SecurityTrails API Key”. It looks for the word securitytrails followed by up to forty characters of anything, and then a value of exactly thirty-two letters or digits with a word boundary on both sides. The name must come before the value and near it. A thirty-two character alphanumeric string with no SecurityTrails name close by is not reported. The severity is medium, with the impact class for SaaS services. This type is not checked live: LeakWatch does not call SecurityTrails with the key 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 domain data sensitive?

Much of it is public or derived from public sources, so the data is not the main concern. The concerns are the quota, the bill on a metered plan, and the fact that queries made with your key are tied to your account.

Why not just keep one key for everything?

A shared key means that one leak touches every tool and every team member. Give each tool its own key, so that a rotation affects one integration at a time.

Does the query string option matter?

Yes. A key in the query string ends up in the full URL, which is written to logs and browser histories. Use the header wherever your tool supports it.

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

LeakWatch is not affiliated with SecurityTrails.