How to fix: Hard-coded secret in source (elevated-risk key)
A real server-side credential (legacy Firebase Cloud Messaging server key, HuggingFace write token, or Replicate API token) is embedded directly in the source code. Unlike the critical tier, abuse is bounded to a single third-party service rather than full account or infrastructure takeover.
Why it matters
An exposed HuggingFace or Replicate token lets anyone run inference billed to your account or push content under your identity. An exposed legacy FCM server key lets anyone send spoofed push notifications to every user of your app. Neither grants broader account or database access.
These formats are real, sensitive credentials with no legitimate client-side use, but the blast radius of a leak is narrower than an AWS or database credential, so they are rated high rather than critical.
How to fix it
- 1Move the credential to a server-side environment variable
- 2Proxy the API call through your own backend instead of calling the vendor API from the client
- 3Rotate the exposed credential immediately
Code examples
Move a vendor API token to a server-side proxy
// BAD: token shipped to the browser
// const res = await fetch('https://api-inference.huggingface.co/...', {
// headers: { Authorization: `Bearer ${HF_TOKEN}` }
// });
// GOOD: client calls your own route, token stays server-side
export async function POST(req: Request) {
const body = await req.json();
const res = await fetch('https://api-inference.huggingface.co/...', {
headers: { Authorization: `Bearer ${process.env.HF_TOKEN}` },
method: 'POST',
body: JSON.stringify(body),
});
return Response.json(await res.json());
}References
Detected automatically by VulnRadar. The check id is hardcoded-secrets-high-risk, stable across every scan so you can filter or diff on it.
More code checks
- CriticalForm Submits Data Over Insecure HTTP
- MediumPotential Prototype Pollution Sinks Detected
- HighPotential Command Injection Vectors
- HighJWT Decoded Without Signature Verification
- HighPotential Path Traversal Vulnerability
- HighInsecure Authentication Mechanisms Detected
- HighPotential Insecure Deserialization
- Mediumeval() Usage in Inline Scripts
Questions
- How severe is Hard-coded secret in source (elevated-risk key)?
- VulnRadar rates this high severity in the 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 hardcoded-secrets-high-risk, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Hard-coded secret in source (elevated-risk key) 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.