LangSmith (LangChain) API key

ID

langsmith_apikey

Severity

high

Remediation Complexity

trivial

Remediation Risk

high

Remediation Effort

low

Vendor

LangSmith

Family

API Token

Description

LangSmith is LangChain’s tracing, evaluation and monitoring platform. Applications send their traces to it with an API key: lsv2_pt_ marks a personal access token, lsv2_sk_ a service key.

lsv2_pt_ or lsv2_sk_, followed by 32 hex digits, an underscore, and 10 hex digits.

Security

A leaked LangSmith key grants an attacker the same access as the application that owns it:

  • Unauthorized usage is billed to your account, and automated high-volume calls can run up a large charge before anyone notices.

  • Whatever is sent through the leaked key — prompts, documents, query results — is exposed to whoever holds it.

  • Traces normally contain the full prompts and completions of your application, so the leak exposes the data it processes and not only its budget.

  • The key does not expire on its own, so the exposure lasts until it is revoked.

Examples

The following is a leak of a LangSmith key:

LANGSMITH_API_KEY=lsv2_pt_0fe2c869...2e52595a4

Mitigation / Fix

  1. Follow your policy for handling leaked secrets, which normally requires revoking the key. Go to [LangSmith > Settings > API Keys], delete the leaked key and create a new one.

    Revoke the leaked key, do not merely disable it.
  2. Remove the leaked key from the source code or committed configuration file, and replace its usages with the new value. Environment variables, local files or secret vaults could be used for passing the key, instead of hardcoding the value, as documented in How to Prevent Hard-Coded Secrets.

  3. Review the usage and audit logs for the key, to confirm that it was not used by unintended actors while it was exposed.

  4. Apply the usual precautions for API keys: never commit them, pass them through environment variables or a secret manager, use a separate key per environment, monitor usage for unusual spikes, and rotate them periodically.

You should consider any sensitive data in commits with secrets as compromised.

Remember that secrets may be removed from history in your projects, but not in other users' cloned or forked repositories.