Skip to main content
MediumSecretsOWASP A07:2021CWE-798

How to fix: High-entropy value assigned to a secret-shaped variable in source

A response includes a long, high-entropy string literal assigned to a variable or JSON key named like a token, API key, or auth key: a shape common to real credentials that don't match any known vendor token format yet.

Why it matters

If the flagged value is a real credential, anyone who loads this response has it: for a client-rendered page that means every visitor's browser, for an API response it means anyone who can reach the endpoint. This check does not match a known vendor token format, so treat it as a prompt to verify the value manually rather than a confirmed leak.

This is a shape-and-entropy heuristic, not a match against a known vendor token format: it flags identifiers matching token/secret/api_key/access_key/private_key/auth_key assigned a 20+ character quoted value whose Shannon entropy is at or above 4.0 bits/character, a threshold that separates random-looking credential material from ordinary structured text. It intentionally skips any value already caught by one of this scanner's own vendor-specific secret checks, so the same value is never reported twice under two check IDs. It will still miss low-entropy secrets and can occasionally flag high-entropy non-secrets (hashes, generated IDs); verify the actual value before treating this as confirmed.

How to fix it

  1. 1Check where the flagged value originates in your code or template to confirm whether it's a real credential
  2. 2If it is a real secret, move it to a server-only environment variable and rotate it immediately
  3. 3If it is not a secret (a hash, a generated ID, a nonce), rename the variable so it doesn't read as a credential to scanners and future maintainers

Code examples

Move a real secret server-side instead of inlining it

TypeScript
// Bad: a real credential assigned inline and shipped in the response
const apiKey = "9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e";

// Good: read from a server-only environment variable
const apiKey = process.env.THIRD_PARTY_API_KEY!;
// Never prefix a real secret's env var with NEXT_PUBLIC_

References

Detected automatically by VulnRadar. The check id is secret-generic-high-entropy-value, stable across every scan so you can filter or diff on it.

See every secrets check

Questions

How severe is High-entropy value assigned to a secret-shaped variable in source?
VulnRadar rates this medium 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-generic-high-entropy-value, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does High-entropy value assigned to a secret-shaped variable 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 high-entropy value assigned to a secret-shaped variable 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

High-entropy value assigned to a secret-shaped variable in source | VulnRadar