A SparkPost API key lets whoever holds it call the SparkPost email API with the permissions chosen when the key was created. Many keys are created with every permission selected, because SparkPost’s own guidance says that is acceptable when you are unsure. In that case a stranger can send mail as your verified sending domains, read and change suppression lists, and read account information. Spam or phishing sent from your domain damages its reputation for weeks. Delete the key first, then investigate what it did.
Check your GitHub account for leaked secrets — free
- Provider
- SparkPost
- Severity
- High
- Impact
- SaaS account access and billing
- Checked live by LeakWatch
- No
What a SparkPost API key looks like
A SparkPost key is a 40-character string made of upper and lower case letters and digits. It has no vendor prefix, so the string alone proves nothing:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX SparkPost API key (masked, 40 letters and digits)
The key is sent in the Authorization header of requests to the SparkPost API, and it also serves as the SMTP password when you relay through SparkPost. Typical variable names are SPARKPOST_API_KEY and SPARKPOST_SMTP_PASSWORD. Accounts on the US platform and on the EU platform are separate, so a key only works on the platform where it was created. After creation the console shows only the key name, its permissions and its first four characters, which helps you match a leaked value to the right entry.
How SparkPost API keys get leaked
- Hardcoded in a mailer script. A quick test of the transmissions endpoint with the key typed into the code and committed.
- Environment files.
SPARKPOST_API_KEYin a.envor compose file that ends up in a repository. - SMTP configuration. The key reused as the SMTP password in framework mail settings, so it appears in a config file as well as in the environment.
- Plugins and CMS settings. Newsletter and form plugins that store the key in a settings export or a database dump that gets shared.
- CI logs and support threads. A debug step that prints the Authorization header, or a request pasted in a ticket.
What to do in the first hour
- Open the API keys list in your SparkPost account (see the link below) and identify the exposed key by its name and first four characters.
- Create a replacement key with only the permissions the application needs, for example sending only. A narrow key limits the next leak.
- Deploy the new key to your application or secret store and send one test message.
- Delete the exposed key from the list. Retry a request with the old value to confirm it is rejected with an authorization error.
- Review what was sent. Look at the message events and reports in the SparkPost console for the period since the exposure: unknown recipients, unexpected volume, spikes in bounces or spam complaints.
- Check what the key could change. Review sending domains, suppression lists, templates and webhooks. Remove entries you do not recognize, in particular a webhook pointing to a URL you do not own.
- Clean up the code. Remove the key from the repository and from its history, and rotate neighbouring secrets in the same file. See I accidentally pushed an API key to GitHub.
Not sure what else leaked from the same repository? Run a free scan.
Revoke it at SparkPost
SparkPost keys are managed from the API keys page of your SparkPost account, after you sign in on the platform (US or EU) that owns the key. Select the exposed key and delete it; third-party guides describe the deletion as immediate. A person has not confirmed the exact menu wording for this guide, and SparkPost’s product is now part of Bird, so the interface may differ. Look for the page where keys are created and listed, and follow the current SparkPost documentation.
How LeakWatch detects it
The rule is called SparkPost API Key. It looks for the word sparkpost (any case), then up to 40 characters of anything, then exactly 40 letters and digits with word boundaries on each side. So the key must appear close to the vendor name, in a variable name, a URL or a comment. A bare 40-character string with no sparkpost nearby is not reported, and neither is a longer or shorter string. The severity is high.
This type is not checked live: LeakWatch has no validator for SparkPost keys, so a finding means the pattern was seen, not that the key still works. Test it yourself by deleting it in the console.
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 a SparkPost key send mail from my domain?
Yes, if its permissions include sending and the domain is verified on the account. That is why the key should be deleted before anything else.
Does deleting the key stop mail already queued?
Deleting the key blocks new API calls with it. Review the message events afterwards to see what was accepted before the deletion, and contact SparkPost support if you see abuse.
The key was in a private repository. Do I still rotate it?
Yes if the repository was ever public, or if collaborators, forks or CI logs could read it. When in doubt, replace it, since it costs a few minutes.