How to fix: Groq API key in source
Groq API keys (gsk_*) grant high-throughput inference on Groq LPU hardware - attractive to attackers because of speed.
Why it matters
Groq's LPU hardware is extremely fast, making an exposed Groq key particularly attractive to attackers; they can exhaust your daily token quota in minutes and incur significant charges before you notice, completely disrupting your application.
Groq API keys (gsk_*) grant high-throughput inference on Groq LPU hardware - attractive to attackers because of speed.
How to fix it
- 1Revoke the key at console.groq.com → API Keys
- 2Set per-day token limits to reduce blast radius of future leaks
- 3Keep Groq API calls server-side only; never expose in browser bundles
Code examples
Next.js: Groq via server route only
import Groq from 'groq-sdk';
import { NextResponse } from 'next/server';
const groq = new Groq({
apiKey: process.env.GROQ_API_KEY!, // server-only: never NEXT_PUBLIC_*
});
export async function POST(req: Request) {
const { prompt } = await req.json();
const completion = await groq.chat.completions.create({
model: 'llama-3.3-70b-versatile',
messages: [{ role: 'user', content: prompt }],
});
return NextResponse.json(completion);
}References
Detected automatically by VulnRadar. The check id is secret-groq-api-key, stable across every scan so you can filter or diff on it.
More secrets checks
Questions
- How severe is Groq 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-groq-api-key, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Groq 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.