Skip to main content
HighAI codeOWASP A02:2021CWE-312

How to fix: Base64-Encoded Secret Pattern Detected

A Base64-encoded string that decodes to a secret, token, or credential pattern was found in the response. AI-generated code sometimes 'encodes' secrets as Base64 under the mistaken impression that encoding is encryption.

Why it matters

Base64 is not encryption; it is trivially reversible. Anyone who sees the encoded value can decode it in seconds. Encoding secrets provides no security protection and creates a false sense of obscurity.

AI tools sometimes produce patterns like `Buffer.from('username:password').toString('base64')` embedded in source code or API responses, believing this 'secures' the credential. It does not; it only obscures it slightly for a human reader, not for any automated system.

How to fix it

  1. 1Never store credentials as Base64 in source code or responses.
  2. 2Use environment variables for all secrets.
  3. 3Treat Base64 as transparent encoding, not encryption.
  4. 4Rotate any credentials that were ever exposed as Base64 in source code.

Code examples

Correct: environment variables

TypeScript
// Bad (AI-generated, Base64 is NOT encryption)
const auth = Buffer.from('admin:password123').toString('base64');

// Good
const auth = Buffer.from(`${process.env.API_USER}:${process.env.API_PASS}`).toString('base64');

References

Detected automatically by VulnRadar. The check id is vibe-base64-sensitive, stable across every scan so you can filter or diff on it.

See every ai code check

Questions

How severe is Base64-Encoded Secret Pattern Detected?
VulnRadar rates this high severity in the ai code 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 vibe-base64-sensitive, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Base64-Encoded Secret Pattern Detected map to?
It maps to CWE-312. In the OWASP Top 10 it falls under A02: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 base64-encoded secret pattern detected

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

Base64-Encoded Secret Pattern Detected fix | VulnRadar