Hash or encrypt API keys at rest, patch or take offline any self-hosted admin and BI tools, and don't give them a database superuser login

ApiPass: an old Metabase hole led to the main database, where user API keys sat in plaintext and were used to burn credits · Security incident · ApiPass · apipass · Nov 9, 2026

What happened

ApiPass, an AI API gateway, said that on 9 Nov 2026 it found its Postgres database had been compromised. The attacker most likely got in through a known unauthenticated remote code execution flaw (CVE-2023-38646 type) in a self-hosted Metabase instance, then used the database superuser connection stored in Metabase to reach the Postgres cluster. It planted command-running functions, a disguised scheduled job and a crypto miner, took the key used to issue API tokens and user API keys that were stored in plaintext, and used 25 keys from 19 accounts to run Seedance video models. All user keys were force-rotated and old keys stopped working on 11 Nov.

How to prevent it

Store only hashes of user API keys, keep BI and admin dashboards patched and off the public internet, connect them with a read-only role on a replica, and offer IP allowlists and per-key spend caps.

Fix prompt for your own AI tool

Copy this into your own AI tool (Cursor, Lovable, Claude Code, Bolt…). It's general guidance written by us. Review what the AI suggests before applying it.

I'm a beginner and want to make sure my API keys are safe in my Postgres project. 1) Search the code for hardcoded keys or tokens and for secrets in variables that ship to the browser (NEXT_PUBLIC_, VITE_, REACT_APP_). List the file and line, but don't print the values. 2) For each one, tell me whether it's meant to be public (like a Supabase anon key) or secret. 3) For secret ones, show me how to move them to server-side env vars and call the provider through a server route. 4) Give me the steps to rotate each exposed key in the provider's dashboard and set a spending limit. 5) Make sure .env is in .gitignore and in my AI tool's ignore file. Don't change anything until I've approved your plan. Never ask me to paste API keys, passwords or .env contents; tell me where to check them myself.

Why this keeps happening: leaked secrets & api keys

Secret keys placed in front-end code, mobile bundles or public repositories can be found by automated scanners and abused, often running up large bills on AI or cloud accounts before anyone notices.

A quick checklist before you ship

More on this: every leaked secrets & api keys story and our related guide.

Tools involved

Postgres stories, Metabase stories, API keys stories

Related stories

Source: original post on ApiPass ↗. Summarised in our own words; numbers are as stated by the source. Browse all stories.

The Honest Build. Real stories, not hype.

Every week: real stories of what building with AI actually took, the one lesson worth keeping, and the security slip-ups to avoid. Free, unsubscribe anytime. Weekly, every Friday.