Skip to content
Payments · Secret guide

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

High severityDetected onlyLast verified · 5 min read

A Lob secret API key lets whoever holds it call the Lob print and mail API as your account. A live key can send real letters, postcards and checks that are billed to you, read the recipient addresses and mailing history you stored, and verify or create address records. A test key does not send real mail. Lob also issues a separate public key meant for the browser, which is far less sensitive. The main danger of a live secret key is billable mail and exposed recipient data. Revoke it first, then investigate.

Check your GitHub account for leaked secrets — free

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

What a Lob API key looks like

Lob has two kinds of keys, and each comes in a test and a live version:

live_XXXX…XXXX        secret key, live (masked, 35 hex characters after the prefix)
test_XXXX…XXXX        secret key, test (masked, same length)
live_pub_XXXX…XXXX    public key, live (masked, 31 hex characters after the prefix)
test_pub_XXXX…XXXX    public key, test (masked, same length)

The secret key is used as the username in HTTP basic authentication, with an empty password, so it appears in a request as -u live_…: and in code as LOB_API_KEY. The public key is used for address verification in a web page or app, which is why it is meant to be visible there. The prefix alone is generic: live_ and test_ are used by other vendors, so what identifies a Lob key is the context, such as the variable name, the api.lob.com host or an Authorization header sent to it. Because the live and test secret keys look alike, check the word at the start.

How Lob API keys get leaked

  • Hardcoded in a script. A mailing script or webhook handler with the key typed into the client and committed.
  • Environment files. LOB_API_KEY in a .env, compose or deployment file that reaches a repository.
  • Frontend and mobile code. A secret key placed in browser JavaScript or an app so it can verify addresses, where anyone can extract it. Only the public key belongs there.
  • Sample projects and notebooks. Integration examples or data notebooks shared with a real key left in.
  • Logs and support tickets. The basic-authentication header printed by a debug option or pasted into a request for help.

What to do in the first hour

  1. Sign in to the Lob dashboard and open the page where API keys are listed (see the link below). Identify the exposed key, live or test, by its last characters.
  2. Roll or regenerate the key. Do this before cleaning anything else. If the key is clearly being abused, accept a short interruption of your mailing flow.
  3. Deploy the new key to the application or secret store, then run a small test call to confirm it works.
  4. Check what was mailed. Review letters, postcards and checks created since the exposure. Look for items you did not send, unknown recipients, large batches or high-cost formats.
  5. Cancel what can still be cancelled. Mail that has not yet been printed may be cancelled from the dashboard. Contact Lob support about anything already sent that you did not authorize.
  6. Review stored data. Check the addresses, address books and any webhooks on the account for entries you do not recognize, and remove them.
  7. Clean up the code and look for other secrets next to the key. 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 Lob

Lob keys are managed from the API keys page of the settings in your Lob dashboard, after you sign in as a user allowed to manage them. Find the exposed key and roll or regenerate it, which should replace the old value. Confirm afterward that a request with the old key is rejected. 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, look for the section where live and test keys are shown, and follow Lob’s documentation.

How LeakWatch detects it

Two rules cover Lob. Both need the word lob in the text before the key, followed within about 20 characters by an assignment sign such as =, : or =>, and both ignore letter case.

The rule called Lob API Key accepts live_ or test_ followed by exactly 35 lowercase hexadecimal characters. Its severity is high, because a live secret key can send billable mail.

The rule called Lob Pub API Key accepts live_pub_ or test_pub_ followed by exactly 31 lowercase hexadecimal characters. Its severity is medium, because a public key is designed to be used in client code and has far fewer rights.

A key with no lob nearby, a body of a different length, or uppercase hexadecimal is not reported. Neither type is checked live: LeakWatch does not send any request to Lob with the key it found, so it cannot tell a live key from a revoked one.

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 mail at my expense with a leaked key?

Yes, if it is a live secret key. Mail created through it is billed to your account. Roll the key, then review what was sent and contact Lob about anything unauthorized.

Is a leaked public key a problem?

A smaller one. Public keys are meant to appear in web pages for address verification. Replace it if you want to cut off usage on your account, but treat the secret key as the urgent one.

Do I need to rotate a test key?

It cannot send real mail, but it often sits next to the live key in the same file. Rotate both, and check that the live key did not leak with it.

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

LeakWatch is not affiliated with Lob.