One Bad Save Deleted My Entire App
My demo community board had twenty posts from five users. I clicked Post once. Now it has zero. It wasn't a hacker, and nobody broke in. The app deleted its own data, because of how it stores it. And while it was workin
My demo community board had twenty posts from five users. I clicked Post once. Now it has zero.
It wasn't a hacker, and nobody broke in. The app deleted its own data, because of how it stores it. And while it was working, it was sending every user's private phone number to anyone who signed up.
This is a pattern I keep seeing in apps built with AI tools. I rebuilt it here with fake data so I could break it on purpose.
Is this you? (five minutes)
- Open your database (in Supabase, the Table Editor). Is there a table with one row, or a handful, holding a big JSON column with your users, posts or orders inside it?
- Sign in to your app as an ordinary user. Open DevTools (F12), go to the Network tab and reload. Click each request and look at the Response. Can you see someone else's phone number, email or address?
- Open your app in two windows, signed in as two different accounts. Post from the first. Then post from the second without refreshing it. Refresh both. Are both posts there?
If you found one big row, someone else's private data, or a missing post, keep reading. If you'd rather ask your AI tool, paste Prompt 1 from the fix below.
How an app ends up like this
It starts in a reasonable way. You're building fast and you don't have a database yet, so the app keeps everything (users, posts, profiles) in one big object saved in the browser. That's fine for a prototype. It only lives on your computer.
Then the app needs to be real. Other people need to see the posts. So you connect a database, and the quickest move, for you or your AI tool, is to keep the same structure and save that one big object to the database instead.
Now there's one table with one row, and inside that row is the entire app: every user, every post, every private phone number.
Think of a shared notebook. Every time anyone adds one line, the app tears out the whole notebook, copies it by hand with the new line added, and puts the copy back. Every time, for everyone.
The AI did exactly what was asked: keep the structure, move it to the database. Nobody asked whether the structure still made sense once real people were sharing it. That choice causes three separate problems.
Problem 1: everyone gets everything
To show anything, the page has to download that one row. So every user's browser receives all of it, not just the posts they see on screen. Every user's private phone number is in there. The app just doesn't display it. And anyone can sign up.
Hidden on the screen is not the same as private. If it's in the Network tab, anyone who presses F12 can read it.
Supabase's security rules can't fix this. Row Level Security (RLS) decides which rows each person can see. Supabase's own docs say it "doesn't give you control over which columns they can access within rows." This app even had RLS turned on. But there's only one row, so the answer is either "you get everything" or "you get nothing". There's no "you get your own part".
Problem 2: posts disappear without a bug
Two people have the app open: Maria in one window, Dev in the other. Both loaded the same board.
Maria posts. Her app takes its copy of the board, adds her post, and saves the whole thing. Then Dev posts. But Dev's copy is from before Maria posted. His app adds his post to his old copy and saves the whole thing.
Refresh both. Dev's post is there. Maria's is gone. No error message, and no bug in the code. That's what happens when two people rewrite the same box at the same time: the last save wins.
The more people use your app, the more often it happens. It gets worse as you succeed.
Problem 3: one bad save wipes everything
This is the one from the start. Because every save rewrites the entire app, a save only has to go wrong once.
Look at what this app does if loading fails. It doesn't stop. It says "couldn't load, start fresh" and carries on with an empty board. That looks friendly, and it's a very common pattern.
So the load fails once, for a moment. The page shows an empty board. I post, like anyone would. And the app saves its copy, which is just my one post, over everything. One request, no hacker, no typo.
It doesn't have to be an accident, either. To let anyone post, every signed-in user has to be allowed to write to that one row. So every user can rewrite the whole app, on purpose, as an ordinary account.
Can you just restore a backup? Not on Supabase's free plan. Free projects get no automatic backups, and Supabase's docs recommend that they "regularly export their data" themselves. If you never did, there's nothing to restore.
The fix: give every post its own row
Stop storing the app in one box. Each post gets its own row, and each profile gets its own row. Then the database can protect each piece separately, and posting adds one row instead of rewriting everything.
Before you start, export a backup. On the free plan, that's the Supabase CLI's supabase db dump.
Paste these into your AI tool (Lovable, Bolt, Cursor, Replit, Claude Code) in order.
Prompt 1: check if this is you
List every database query this app makes when a page loads,
and what data each one returns. Tell me if the app stores
most of its data in a single row or a single JSON column,
and flag any query that returns another user's private information.
Prompt 2: move to real tables
My app stores all of its data as one JSON object in a single row.
Move it into proper tables: one row per post in a `posts` table
with a `user_id` column, and private fields like phone numbers
in a `profiles` table with one row per user. Write a one-time
migration that copies the existing data into the new tables.
Change every save so it inserts or updates only the one row that
changed. Never rewrite the whole dataset. Don't delete the old
table yet.
The migration copies your existing data across, so nothing is lost in the move. Keeping the old table means you can check everything arrived before you remove it.
Prompt 3: lock it down
Enable row level security on `posts` and `profiles`. Policies:
signed-in users can read all posts; users can insert posts only
with their own user_id; users can update and delete only their
own posts; users can read and update only their own profile.
Show me the SQL you ran.
In plain English: anyone signed in can read posts, you can only post as yourself, you can only edit or delete your own posts, and you can only see your own phone number.
Then fix your backups. On the free plan, export your data on a schedule. On the Pro plan, Supabase takes daily backups and keeps the last 7 days. Daily backups can still lose up to a day of posts, and finer-grained recovery (Point-in-Time Recovery) is a paid add-on. Either way, try restoring one before you need it.
Verify it worked
Don't trust the AI's summary that it's fixed. Check it yourself. It takes two minutes.
- [ ] Network tab: reload as an ordinary user. You get the posts and only your own phone number. Nobody else's.
- [ ] Two-window test: post from two accounts, the second without refreshing. Refresh both. Both posts survive.
- [ ] Try someone else's post: signed in as one user, try to edit another user's post (ask your AI tool for the one-line test). Nothing changes.
- [ ] Bad load: if the page fails to load posts, it shows an error, not an empty board, and posting doesn't overwrite anything.
- [ ] Security Advisor: in the Supabase dashboard, the Security Advisor shows no errors.
Recap
If your app keeps everything in one row, every user downloads everyone's data, two people posting at once lose posts, and one bad save can wipe the lot, with no free-plan backup to fall back on. Give each post and profile its own row, lock the rows down with RLS, set up backups, and run the two-window test.
The full walkthrough, with the wipe and the fix on screen, is in the video. If you'd rather not touch code, the no-code version explains the same idea as a box and three questions to ask whoever built your app: Your App Might Be Giving Every User Everyone's Data, or the 50-second version: Is your app just one box?.
Short versions of each problem: I clicked Post once. My app deleted everything., Your app hides phone numbers. The Network tab doesn't. and Two people posted. One post vanished.
Written by Taylor. I build apps with AI tools, then try to break them. Every hole in this post was reproduced on a demo app I built and own, with fake data, and the fix was tested before it went up.
Drafted with AI help from my video script; I checked and edited it.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.