How to fix: Replicate API token in source
Replicate API tokens (r8_*) grant inference and model upload access; can be abused for huge GPU bills.
Why it matters
An exposed Replicate token lets an attacker run expensive GPU inference workloads billed to your account. A single day of abuse can incur thousands of dollars in charges. It also allows uploading malicious model weights under your identity.
Replicate API tokens (r8_*) grant inference and model upload access; can be abused for huge GPU bills.
How to fix it
- 1Revoke the token at replicate.com → Account → API tokens
- 2Set billing alerts in your Replicate account to catch unexpected usage
- 3Proxy Replicate calls through your own API so the token never reaches the browser
Code examples
Next.js: proxy Replicate calls server-side
// app/api/predict/route.ts: server-only
import Replicate from 'replicate';
import { NextResponse } from 'next/server';
const replicate = new Replicate({
auth: process.env.REPLICATE_API_TOKEN!, // server-only
});
export async function POST(req: Request) {
const { prompt } = await req.json();
const output = await replicate.run('stability-ai/sdxl:...', { input: { prompt } });
return NextResponse.json({ output });
}References
Detected automatically by VulnRadar. The check id is secret-replicate-api-token, stable across every scan so you can filter or diff on it.
More secrets checks
Questions
- How severe is Replicate API token 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-replicate-api-token, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does Replicate API token 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.