How to fix: Datadog API key in source
Datadog API keys grant metric ingestion. Restrict by hostname tag.
Why it matters
An exposed Datadog API key allows an attacker to flood your dashboards with fake metrics and events, masking real performance issues or triggering false alert storms, and potentially silencing real incident alerts during an attack.
Datadog API keys grant metric ingestion. Restrict by hostname tag.
How to fix it
- 1Rotate the key in Datadog → Organization Settings → API Keys
- 2Restrict the key by host tag and scope to minimum required permissions
- 3Use the client token (pub_*) for browser RUM, not the API key
Code examples
Server-side metric submission only
// Only submit metrics server-side: never expose the API key to browsers
import { v1 } from '@datadog/datadog-api-client';
const configuration = v1.createConfiguration({
authMethods: {
apiKeyAuth: process.env.DD_API_KEY!, // server-only
},
});
const metricsApi = new v1.MetricsApi(configuration);References
Detected automatically by VulnRadar. The check id is secret-datadog-api-key, stable across every scan so you can filter or diff on it.
More secrets checks
Questions
- How severe is Datadog API key in source?
- VulnRadar rates this high 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-api-key, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Datadog API key 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.