Skip to content
Messaging · Secret guide

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

High severityDetected onlyLast verified · 5 min read

Mandrill is the transactional email service of Mailchimp, now named Mailchimp Transactional. A Mandrill API key lets whoever holds it send email through your account, from any sending domain you have set up, and call the API to read data about messages, templates, webhooks and sending statistics. The main danger is mail that really comes from your domain and passes its authentication checks: phishing and spam sent with a stolen key look genuine, and the abuse damages your sending reputation and can lead to suspension. Revoke the key first, then check what was sent.

Check your GitHub account for leaked secrets — free

Provider
Mandrill
Severity
High
Impact
SaaS account access and billing
Checked live by LeakWatch
No

What a Mandrill API Key looks like

A Mandrill API key is a string of 22 characters made of letters, digits, dashes and underscores. It has no fixed prefix:

XXXX…XXXX   22 characters, URL-safe alphabet (masked)

With no prefix, the string alone cannot be told from many other identifiers. Context identifies it: variable names such as MANDRILL_API_KEY, the key field of a JSON payload sent to the Mandrill API, an SMTP configuration for the Mandrill host where the key serves as the password, or a library such as the official Mailchimp Transactional clients. Do not confuse it with a regular Mailchimp Marketing API key; that one ends with a data center suffix and is covered in Mailchimp API key. Mandrill accounts can also hold test keys, which do not send real mail but still show your setup, so rotate those found in the same file.

How Mandrill API Keys get leaked

  • Application mail settings. A framework or CMS plugin configured for Mandrill, with the key committed in a settings file or an environment file.
  • SMTP configuration. The key used as the SMTP password in a mail config, written in a Docker compose file, a server template or a CI variable.
  • Old projects. WordPress, Rails or Node projects from when Mandrill was a popular free-tier option, still public with the key in the history.
  • Examples in issues and forums. A code snippet or log pasted into a bug report when asking why mail does not arrive.
  • Client-side code. A key placed in JavaScript to send a contact form directly from the browser, which exposes it to every visitor.

What to do in the first hour

  1. Revoke the key. In the Mandrill settings of the account, find the section where API keys are listed (see the link below), and revoke or delete the exposed key. If you are unsure which key leaked, match it by its last characters and the description given when it was created.
  2. Create a new key with a description, store it in a secret manager and deploy it to the applications that send mail. Send a test message to confirm.
  3. Check the sending activity. Open the activity and outbound views of the account for the period since the exposure. Look for messages you did not send, unusual recipients, big volumes, odd subjects or senders, and a sudden rise in bounces and spam complaints.
  4. Review the account setup. Check the sending domains, the verified senders, the webhooks and the inbound routes. Remove anything you do not recognize, in particular a webhook that would forward events to an outside address.
  5. Check other keys. Revoke test keys or keys for other apps that were in the same file, and look at who has access to the account.
  6. Tell your provider if needed. If spam was sent, your Mailchimp or Mandrill account may be flagged, so be ready to explain the incident and the fix.
  7. Clean up the code and the 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 Mandrill

Mandrill API keys are managed in the settings of the Mandrill account, in the Mandrill app, after you sign in with a user allowed to manage the account. Open the settings and look for the section where API keys are listed; the keys can be created and revoked there. A revoked key stops working, so every system that used it must be updated. A person has not confirmed the exact menu wording for this guide, and the interface can change, so if the page differs from this description, follow the Mailchimp Transactional developer documentation on API keys.

How LeakWatch detects it

The rule is called Mandrill API Key. Because the key has no prefix, the rule does not match a bare 22-character string. It looks for the word mandrill, in any letter case, then up to 40 characters of anything, then a standalone value of exactly 22 letters, digits, dashes or underscores. A 22-character value without the word nearby, or one that is shorter or longer, is not reported. That keeps false alerts down, but a key far from the word can be missed. The severity is high. This type is not checked live: LeakWatch does not send any request to Mandrill with the key it found.

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 send email from my domain with a Mandrill key?

Yes, from the sending domains configured in the account. That is why you should review the sent mail and the domains, not only revoke the key.

Is a Mandrill key the same as a Mailchimp API key?

No. A Mailchimp Marketing key manages audiences and campaigns and ends with a data center suffix. A Mandrill key sends transactional mail. Check both if both appear in the leaked file.

Will revoking the key stop my email?

Yes, until the new key is deployed. Prepare the deployment first when you can. If the key is already being abused, revoke at once and accept a short outage.

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

LeakWatch is not affiliated with Mandrill.