Skip to main content
LowSecretsOWASP A07:2021CWE-798

How to fix: Datadog client token in source

Datadog client tokens (pub_*) are intentionally shipped in browser bundles for RUM. They are read-only / ingest-only but leak account.

Why it matters

Datadog client tokens (pub_*) are intentionally public for browser RUM collection. The primary risk is that an unrestricted token allows any site to submit fake RUM data billed to your account. Ensure it is not confused with a full API key, which would be more dangerous.

Datadog client tokens (pub_*) are intentionally shipped in browser bundles for RUM. They are read-only / ingest-only but leak account.

How to fix it

  1. 1Restrict the client token by service and origin in Datadog Organization Settings
  2. 2Rotate periodically and audit for unexpected traffic sources
  3. 3Ensure the full API key is never in client bundles; only the pub_* token

Code examples

Correct: use pub_* token in browser, API key server-only

TypeScript
import { datadogRum } from '@datadog/browser-rum';

datadogRum.init({
  applicationId: process.env.NEXT_PUBLIC_DD_APPLICATION_ID!,
  clientToken: process.env.NEXT_PUBLIC_DD_CLIENT_TOKEN!,  // pub_*: safe in browser
  site: 'datadoghq.com',
  service: 'my-app',
  // Never use the API key here; only the pub_* client token
});

References

Detected automatically by VulnRadar. The check id is secret-datadog-client-token, stable across every scan so you can filter or diff on it.

See every secrets check

Questions

How severe is Datadog client token in source?
VulnRadar rates this low severity in the secrets category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id secret-datadog-client-token, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Datadog client token in source map to?
It maps to CWE-798. In the OWASP Top 10 it falls under A07:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for datadog client token in source

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: Datadog client token in source | VulnRadar