How to fix: Mistral AI API key in source
Mistral API keys grant chat/completion/embedding access on the La Plateforme and can incur significant cost.
Why it matters
An exposed Mistral API key allows an attacker to consume your chat and embedding quotas without restriction, potentially incurring large charges and exhausting your rate limits, disrupting your own application's ability to serve users.
Mistral API keys grant chat/completion/embedding access on the La Plateforme and can incur significant cost.
How to fix it
- 1Revoke the key at console.mistral.ai → API Keys
- 2Set usage limits and billing alerts to detect unexpected consumption
- 3Keep Mistral API calls server-side only
Code examples
Next.js: Mistral via server route
import MistralClient from '@mistralai/mistralai';
import { NextResponse } from 'next/server';
const mistral = new MistralClient(process.env.MISTRAL_API_KEY!); // server-only
export async function POST(req: Request) {
const { messages } = await req.json();
const response = await mistral.chat({
model: 'mistral-large-latest',
messages,
});
return NextResponse.json(response);
}References
Detected automatically by VulnRadar. The check id is secret-mistral-api-key, stable across every scan so you can filter or diff on it.
More secrets checks
Questions
- How severe is Mistral AI 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-mistral-api-key, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Mistral AI 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.