Skip to main content
HighSecretsOWASP A07:2021CWE-798

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

  1. 1Revoke the token at replicate.com → Account → API tokens
  2. 2Set billing alerts in your Replicate account to catch unexpected usage
  3. 3Proxy Replicate calls through your own API so the token never reaches the browser

Code examples

Next.js: proxy Replicate calls server-side

TypeScript
// 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.

See every secrets check

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.

Propose a checkHow a check is built

Scan your own site for replicate api token in source

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

How to fix: Replicate API token in source | VulnRadar