Stopping KV Secrets Leaks in Edge AI with Cloudflare Workers A security writeup demonstrates that a misconfigured Cloudflare Workers KV namespace can turn an edge-hosted AI model into a data-leak oracle: an attacker embeds a crafted token like {{SECRET_API_KEY}} in a prompt, the Worker performs an unauthenticated KV GET, and the secret is echoed back in the model's output. The guide details detection signals such as {{...}} patterns in request logs, spikes in KV read counts, and raw key formats in model responses, and recommends making the namespace private, whitelisting allowed tokens, and validating the request origin. A mis‑configured Cloudflare Workers KV namespace can turn your edge‑hosted AI model into an accidental data‑leak oracle. Within hours of the first Hacker News thread, security researchers demonstrated that an attacker can embed a crafted token in a prompt, trigger a KV lookup, and receive the secret value back in the model’s response. If you’re running inference at the edge, this is the most urgent “check‑your‑config” task of 2024. In this guide you’ll get: ┌───────────────┐ ┌─────────────────────┐ │ Client │ HTTPS │ Cloudflare Edge │ │ browser/API │ ───────► │ Worker AI inference │ └─────┬─────────┘ └─────┬───────────────┘ │ │ │ Prompt with token │ ▼ ▼ ┌───────────────┐ ┌─────────────────────┐ │ AI Runtime │ KV GET │ Workers KV global │ │ TensorFlow.js│ ◀─────── │ namespace │ │ / ONNX │ └─────────────────────┘ └─────┬─────────┘ │ ▼ Model output → returned to client If the KV namespace is public or the Worker’s request handler does not validate the origin, the KV GET call succeeds and the secret value becomes part of the model’s output. Prerequisite – You have a Worker that loads a prompt from KV and feeds it to a TensorFlow.js model. Create a namespace called "my‑kv" curl -X POST "https://api.cloudflare.com/client/v4/accounts/