Skip to main content
HighSecretsOWASP A07:2021CWE-798

How to fix: Cohere API key in source

Cohere trial/production keys grant access to generate, embed, and classify endpoints with billable usage.

Why it matters

An exposed Cohere API key allows an attacker to consume your generation and embedding quotas, incurring billable usage charges. Production keys also expose any fine-tuned models or datasets you have created.

Cohere trial/production keys grant access to generate, embed, and classify endpoints with billable usage.

How to fix it

  1. 1Revoke the key at dashboard.cohere.com → API Keys
  2. 2Keep Cohere API calls server-side only
  3. 3Proxy browser-initiated requests through your own API route

Code examples

Next.js: proxy Cohere through server route

TypeScript
import { CohereClient } from 'cohere-ai';
import { NextResponse } from 'next/server';

const cohere = new CohereClient({
  token: process.env.COHERE_API_KEY!,  // server-only
});

export async function POST(req: Request) {
  const { text } = await req.json();
  const response = await cohere.embed({
    texts: [text],
    model: 'embed-english-v3.0',
    inputType: 'search_query',
  });
  return NextResponse.json({ embeddings: response.embeddings });
}

References

Detected automatically by VulnRadar. The check id is secret-cohere-api-key, stable across every scan so you can filter or diff on it.

See every secrets check

Questions

How severe is Cohere 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-cohere-api-key, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Cohere 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.

Propose a checkHow a check is built

Scan your own site for cohere api key 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: Cohere API key in source | VulnRadar