Before you ship: lock the database, back it up, and log what happens
An app can work fine on your screen while its database is open to anyone. Firebase's docs put it plainly: "You might think you're the only person using your app, but if you've deployed it, it's available on the internet." (source)
This guide is a checklist to run before launch. It covers three jobs: lock the database, make sure you can get your data back, and log what happens without leaking secrets. It's quoted from Supabase, Firebase, MongoDB, PostgreSQL and OWASP docs, checked Oct 2026.
Not affiliated with or endorsed by Supabase, Google, MongoDB, the PostgreSQL Global Development Group or OWASP. Check their current docs before relying on these details.
For keeping API keys out of your code, see how to keep secrets safe with AI coding tools. This guide doesn't repeat it.
Part 1: Lock the database
Check 1: Supabase: turn on Row Level Security for every table
Supabase gives your frontend a public key. That's by design. Supabase's docs explain: "The publishable key is taped to the front door, and it only opens the lobby. The secret key is the master key, and it stays in your pocket." (source)
The lock is Row Level Security (RLS). Without it, the public key opens much more than the lobby: "A table in an exposed schema without RLS is readable and writable by any role with a grant on it. Enable RLS on every table in an exposed schema." Here, "anon" means "an unauthenticated request (the user is not signed in)". (source)
Policies alone aren't enough on some projects. Supabase says: "On projects that still grant anon and authenticated by default, revoke those grants. Adding policies doesn't remove them." And: "A table protected only by policies still hands anon an insert path if you never revoke the grant." (source)
- RLS is on for every table in an exposed schema.
- Default anon and authenticated grants you don't need are revoked.
Check 2: Keep the secret key off the browser
The secret key (formerly service_role, checked Oct 2026) is different: "It bypasses Row Level Security, so it must never leave your control". (source)
The key names are changing: "Supabase is deprecating the anon and service_role keys by the end of 2026. Use the publishable (sb_publishable_xxx) and secret (sb_secret_xxx) keys instead." (source)
- Search your frontend code and public repo for
sb_secret_andservice_role. Neither should appear there. - Your frontend uses only the publishable (formerly anon) key.
Check 3: Never allow 0.0.0.0/0
An IP allowlist decides which addresses can connect. In PostgreSQL's words, "0.0.0.0/0 represents all IPv4 addresses, and ::0/0 represents all IPv6 addresses." (source) So adding it to an allowlist lets everyone in.
- MongoDB Atlas: "Atlas only allows client connections to the cluster from entries in the project's IP access list." MongoDB warns: "Adding the /0 CIDR (Classless Inter-Domain Routing), such as 0.0.0.0/0, allows access from anywhere. This configuration can expose your deployment to unauthorized access, data exfiltration, and other malicious activity." If you need short-term access, "Atlas supports creating temporary IP access list entries that expire within a user-configurable 7-day period." (source)
- Supabase: "Network restrictions let you control which IP ranges can connect to Postgres and its pooler, reducing your project's exposure to unauthorized access." They're off until you set them: "If restrictions have never been applied, the allowed CIDRs list is empty and Restrictions applied successfully is false. All IPs can connect". They "apply to all connection routes, whether pooled or direct." (source)
- No 0.0.0.0/0 or ::0/0 entry in any allowlist.
- On Supabase, decide whether to apply network restrictions, and if so, list only the IP ranges you need.
Check 4: Self-hosted Postgres: no '*' with trust
Two settings together leave a server with no password at all:
listen_addresses: "The default value is localhost, which allows only local TCP/IP “loopback” connections to be made." Setting it to*changes that: "The special entry * corresponds to all available IP interfaces." (source)trustin pg_hba.conf: "Allow the connection unconditionally. This method allows anyone that can connect to the PostgreSQL database server to login as any PostgreSQL user they wish, without the need for a password or any other authentication." (source)
A line like this in pg_hba.conf, on a server listening on *, lets anyone who can reach it log in as any user (we haven't tried it ourselves):
host all all 0.0.0.0/0 trust
listen_addressesstays at localhost unless the server must take outside connections.- No
trustline in pg_hba.conf covers addresses outside the machine.
Check 5: Firebase: remove 'if true' rules
Firebase's insecure-rules page lists this rule as not recommended. Its comment warns that it allows "anyone to overwrite your entire database." (source)
allow read, write: if true;
Firebase says: "If you're not authenticating users and configuring security rules, then anyone who guesses your project ID can steal, modify, or delete the data." (source)
- No
if truerule is left in your deployed security rules.
Check 6: Tell your agent not to "fix" it by opening up
When a connection fails, the quick fix is to open things up. Add a rule like this to your agent's instructions (we haven't tried it ourselves):
Never turn off RLS, add 0.0.0.0/0 to an allowlist, use trust auth, or
write 'if true' rules to make something work. Stop and explain the
problem and a safer fix instead.
See AI agent permissions for beginners to make the agent ask before it changes settings.
Part 2: Make sure you can get your data back
Check 7: Know whether you have automatic backups
On Supabase, "We automatically back up all Pro, Team, and Enterprise Plan projects on a daily basis." For free tier projects, Supabase recommends they "regularly export their data using the Supabase CLI db dump command and maintain off-site backups." How long backups are kept depends on your plan (checked Oct 2026). (source)
Daily backups still leave a gap: "Even with daily backups, you could still lose a day's worth of data. With PITR, you can back up to the point of disaster." (source)
- You know whether your plan backs up automatically.
- If it doesn't, you export with
db dumpon a schedule and keep a copy off-site. - You've decided whether losing a day of data is acceptable.
Check 8: Restore a backup once
Our advice, not a vendor quote: a backup you've never restored is untested. Restore one into a separate test project or database, and check your data is there before you need it for real.
- You've restored at least one backup somewhere safe and checked the data.
Part 3: Log what happens, safely
Check 9: Log the events that matter
OWASP says: "Without logging and monitoring, attacks and breaches cannot be detected, and without alerting it is very difficult to respond quickly and effectively during a security incident." One common failure: "Auditable events, such as logins, failed logins, and high-value transactions, are not logged or logged inconsistently (for instance, only logging successful logins, but not failed attempts)." Another: "Logs of applications and APIs are not monitored for suspicious activity." (source)
- Logins, failed logins and high-value actions are logged.
- Someone, or an alert, actually looks at the logs.
- You'd notice if logging stopped. OWASP says to "Enable processes to detect whether logging has stopped, and to identify tampering or unauthorized access and deletion". (source)
Check 10: Keep secrets out of the logs
OWASP's list of things not to log includes "Access tokens", "Authentication passwords", "Database connection strings" and "Encryption keys and other primary secrets". It also warns: "Logs may contain personal and other sensitive information, or the data may contain information regarding the application's code and logic." (source)
- Search your logs for tokens, passwords, connection strings and keys. None should appear.
- Access to logs is limited, because they can hold sensitive data.
Next steps
- Keep keys out of reach: how to keep secrets safe with AI coding tools
- Control what your agent can change: AI agent permissions for beginners
- Get an undo button for code: git basics for AI coders
Sources
All checked Oct 15, 2026:
- Supabase Row Level Security
- Supabase API keys
- Supabase Network Restrictions
- Supabase Database Backups
- Firebase, avoid insecure rules
- MongoDB Atlas IP access list
- PostgreSQL pg_hba.conf
- PostgreSQL connection settings
- OWASP Logging Cheat Sheet
- OWASP Top 10:2025 A09
Not affiliated with or endorsed by Supabase, Google, MongoDB, the PostgreSQL Global Development Group or OWASP. Check their current docs before relying on these details.