CCyberwiki

Database dumping

Database dumping
ClassData exposure
CWECWE-862: Missing Authorization (the most common cause in web applications)
MITRE ATT&CKT1213.006 Data from Information Repositories: Databases
Typical severityCritical
AffectsDatabases reachable through an API without row rules, routes open to SQL injection, and database accounts whose password has leaked

Database dumping copies whole tables, or a whole database, out of an application in bulk. Known cases involve MySQL, PostgreSQL, MongoDB, Amazon RDS, Google Firebase and Snowflake.1 The attacker is usually after usernames, password hashes, personal data and financial data, and uses the stolen copy for further intrusion, for extortion or for sale.1

Description

A dump needs a channel that returns many rows and an identity the database allows to read them. Web applications offer four routes to both.

Supabase shows the first route, an API that queries a table directly with no per-row check. It exposes tables in the public schema through its Data API, and on existing projects new tables there receive select, insert, update and delete grants for the anon role by default.2 The publishable key (formerly the anon key) that every frontend ships maps to that role, so without row level security anyone holding the key reads the whole table.3 The underlying flaw is missing authorization, where data is read "directly from a data store that is not restricted".4

SQL injection gives the second. Once a query can be changed, tools such as sqlmap automate the extraction: its --dump switch reads the entries of a table and --dump-all reads every table the database session can read.5

A leaked database password, from an exposed credential or a database port open to the internet, opens the third. With it, an attacker runs the database's own export tools; pg_dump, for example, produces a plain-text file of the SQL commands needed to rebuild the database elsewhere.6 Sandworm Team has copied data from enterprise databases through Adminer, a web-based database manager.1

The last route needs no query at all: a dump file left on the web server or in a bucket, covered in Exposed backups.

Mechanism

Supabase's Data API runs on PostgREST, which pages results with HTTP range headers. A request with the header Prefer: count=exact returns the total row count in the Content-Range header, and limit and offset parameters, or a Range header, select each block of rows.7 Against an unprotected profiles table on example.supabase.co, a script first asks for the size:

curl -I "https://example.supabase.co/rest/v1/profiles?select=*&limit=1" \
  -H "apikey: sb_publishable_..." \
  -H "Prefer: count=exact"

# Content-Range: 0-0/48210

It then loops over offset=0, 1000, 2000 and onward until all 48,210 rows are saved. With row level security on and no policy granting the anon role access, the same request returns an empty result; a missing grant returns a permission error.3 PostgREST's own db-max-rows setting, a hard cap on rows per request, is unlimited by default.8 A cap makes each page smaller, and a loop still reads every page.

Impact

A dump exposes everything in the copied tables at once: email addresses, password hashes, tokens and API keys stored for users, and private messages. Tokens and keys in the dump let the attacker act as each user. Where the same missing check also covers writes, the attacker can change or delete rows as well.

Notable incidents

On 31 January 2026, researchers at Wiz found the Supabase key of Moltbook, a social network for AI agents, in the site's JavaScript. A request to /rest/v1/agents?select=name,api_key returned agents' API keys, where row level security would have returned an empty array or an error.9 Using PostgREST error hints and GraphQL introspection to list tables, they counted about 4.75 million exposed records, including 1.5 million API tokens, 35,000 email addresses and private messages, some holding OpenAI API keys. Write access was also open: they changed an existing post with a PATCH request. The tables were secured in four rounds, the last at 01:00 UTC on 1 February.9 Infosecurity Magazine reported the case on 3 February 2026, with a count of 30,000 email addresses.10

Detection

For a Supabase project, open Database > Policies in the dashboard and look for tables in public with row level security off, then send the request above with only the publishable key and no login, one table at a time. Any table that returns rows is readable by everyone.

On a server, the trace is a database command-line client such as psql, mysql or mongo run by an account that does not normally use one, followed by new .sql or .csv files or an outbound transfer.1

Prevention

Row rules and grants

Every exposed object sits behind two layers. Grants decide which role reaches a table, and row level security decides which rows that role sees.2 Turn row level security on and add a policy that ties each row to its owner:

alter table profiles enable row level security;

create policy "Users read their own profile"
on profiles for select
using ( (select auth.uid()) = user_id );

Revoke the grants on tables the frontend never reads, and turn off Automatically expose new tables in the Data API settings so new tables start closed:2

revoke all on table public.audit_log from anon, authenticated, service_role;

The secret key (formerly service_role) bypasses every policy and stays on the server.3 Details are in Row level security and Privileged key in client-side code.

Limits on volume

An API should set a maximum number of records per page and a limit on requests per client.11 In PostgREST, db-max-rows sets the first.8 Rate limiting slows a paging loop down, and the row check is still needed.

Accounts and stored data

Database accounts should get least privilege, and the list of who can read sensitive databases needs a periodic review. Data should be encrypted at rest, and whatever the business no longer needs archived or deleted.1 A table that no longer holds old records cannot leak them.

Prompt for a coding agent

List every table in this project's Supabase public schema. For each one, report whether row level security is enabled, which policies exist, and which roles have grants. Enable row level security on every table, and write select, insert, update and delete policies so that a signed-in user reaches only rows where user_id matches auth.uid(). Revoke all grants from anon and authenticated on tables the frontend does not use. Confirm no secret or service_role key appears in frontend code. List each table you changed and any policy you were unsure about.

In SecFlash

SecFlash reports a Supabase table that returns rows to a request with no login as SF-EXP-213 on the Exposure page. On the Cloud page it reports a public table without row level security as SF-CLD-501, sensitive columns readable through the API as SF-CLD-504, and a policy whose condition is always true as SF-CLD-508. A database dump file on the web server shows as SF-EXP-413, an API with no rate limit as SF-EXP-208, and SQL injection found by the attack test as SF-SEC-601.

See also

References

  1. a b c d e MITRE (created 22 May 2025, modified 12 May 2026). "Data from Information Repositories: Databases, T1213.006". MITRE ATT&CK.
  2. a b c Supabase (updated 19 November 2026). "Securing your API". Supabase Docs.
  3. a b c Supabase. "API keys". Supabase Docs.
  4. back "CWE-862: Missing Authorization". Common Weakness Enumeration. MITRE.
  5. back sqlmap project. "Usage". sqlmap wiki. GitHub.
  6. back PostgreSQL Global Development Group. "pg_dump". PostgreSQL Documentation.
  7. back PostgREST. "Pagination and Count". PostgREST documentation.
  8. a b PostgREST. "Configuration". PostgREST documentation.
  9. a b Nagli, Gal (2026). "Hacking Moltbook: The AI Social Network Any Human Can Control". Wiz Blog.
  10. back Muncaster, Phil (3 February 2026). "Vibe-Coded Moltbook Exposes User Data, API Keys and More". Infosecurity Magazine.
  11. back "API4:2023 Unrestricted Resource Consumption". OWASP API Security Top 10. OWASP Foundation.