I built an app with AI and it worked perfectly. Then I ran one test and watched another business's invoice come back.
The application was working. Customers could sign in, create records, manage their accounts and come back to find everything where they left it. On the surface, nothing was wrong. Underneath, there was a problem I hadn't thought to look for.
It was getting late, and I was still at my desk. By then I had become comfortable building software with AI. I had spent weeks on it: adding features, refining the interface, fixing errors and connecting the different parts of the system. What started as an idea had slowly become a working product.
There was a login system. Each business had its own account, its own dashboard and its own records. I could add customers, create invoices, record transactions and find everything again the next day. I had tested every feature many times, and every one of them did what it was supposed to do.
That evening I wasn't looking at the interface at all. One of the processes that fetched data from the database wasn't behaving the way I expected, and I wanted to understand why. So I opened the code and started reading the queries. The application checked whether a user was signed in. But I couldn't find anything that checked, every time, whether that user was allowed to see the specific records they were asking for.
On its own, it was a small observation. But it raised a question I should have asked weeks earlier: what actually stops one customer from seeing another customer's information?
The test
I created two test accounts for two different businesses. I'll call them Account A and Account B. I signed in as Account A and added a few customers and an invoice. Then I signed out and signed in as Account B.
Everything looked normal. Account B saw its own dashboard and its own records, and nothing from Account A appeared anywhere. If I had stopped there, I would have gone to bed thinking all was well.
But I wanted to know what happened when someone stopped using the dashboard the way it was designed. So, still signed in as Account B, I took the identifier of the invoice I had created in Account A and asked the database for it directly. I expected an error. Instead, the invoice came back: customer name, address, amount, everything.
Invoice INV-1042 for a customer of Account A, with their name, address and amount due.
I sat looking at the screen for a while. Then I tried a customer record, then a list of transactions. Each time, the database handed over information that belonged to a different business, to a user who had no right to see it. Every customer's data was open to anyone who was signed in and knew how to ask.
Locked front door, open offices
The easiest way I can explain it is a building with separate offices. Everyone who works there has a key to the front door. The receptionist checks your key and points you to your own office. It all looks organised, but once you're inside, none of the office doors are locked. The receptionist was doing a perfect job, and the building still wasn't secure.
That was my application. The login identified each user correctly, and the interface showed each user their own records. But the database itself wasn't enforcing anything. It trusted the dashboard to ask only for the right things, and anyone willing to skip the dashboard could ask for anything.
The relief came a moment later. These were test accounts, and no real customer had used the application yet. I had found the problem before anyone else could. But I knew how close it had come. A few more weeks and those records would have belonged to real businesses.
The mistake was an assumption
When people think about application security, they usually think about passwords, login screens and verification codes. Those matter, but they only answer one of the two questions every application has to answer. The first is: who is this person? The second is: what is this person allowed to see and do?
The first is authentication and the second is authorisation. They sound alike, but they solve completely different problems. Someone can sign in perfectly legitimately and still reach information they should never see.
Hiding another business's invoice from the dashboard doesn't make it private. Removing an admin button from a cashier's screen doesn't stop that cashier from trying the admin action another way. The rules have to live somewhere the user can't get around, which means the database or a trusted server, not the screen.
Why AI made it so easy to miss
I think this is one of the easiest mistakes to make when you build with AI, and I don't think I'm alone. Tools like Lovable, Bolt, Cursor and Claude Code are remarkable at turning a description into a working feature. You ask for a customer area, and you get the screens, the queries and the database tables. You ask for invoices, reports and user roles, and they appear. Each user sees the right information, so you assume the permissions are working.
But what you see on screen only shows you what the app chose to request. It doesn't prove what the database would allow. AI will often add a business ID to every record and filter by it in the queries, which looks like protection. But filtering in the app is a polite request, while enforcing it in the database is a rule, and only the rule stops someone who doesn't play along.
The worst part is how reassuring the answers can sound. Ask an AI assistant whether your database is secure and you may get a confident explanation that authentication is enabled, records are linked to accounts and access is restricted. It reads well, but it isn't evidence.
I've come to think the real risk of building with AI isn't that it writes bad code. It's that it writes code that looks reasonable, works in every normal situation and still has weaknesses you won't see unless you go looking for them.
The fix, and the proof
My first instinct was to type "make this secure" and accept whatever came back. I didn't. Instead, I started by mapping everything. Where was customer information stored? Which parts of the application could read it? Was there anything running on the server that skipped the normal checks? What happened to a user's access when they were removed from a business?
Then I rewrote the database rules. Every request to read or change a record now checks two things: that the user belongs to the business that owns the record, and that their role allows that action. An owner can see the finances. A cashier can record a sale but can't open the accounts. A removed user loses access straight away, even with an old session still open. Uploaded files got the same treatment, because documents are customer data too, and anything sensitive moved to the server, where the user can't touch it.
If you're using Supabase, this is what Row Level Security policies are for. With Firebase, it's Firestore and Storage Security Rules. The tools differ, but the principle doesn't: access has to be enforced at a boundary the user can't reach.
Then came the part that mattered most. I ran the same test again. Signed in as Account B, I asked for Account A's invoice, and this time the database refused.
Does this user belong to the business that owns INV-1042? No. Request refused, nothing returned.
I tried the customer record and the transactions, and both were refused. I tried each role in turn, and each one could do exactly what it should and nothing more. That test is now part of how I work. I don't just check that a user can see their own data; I check that they're refused when they reach for someone else's, and I run it before every release.
Try this on your own app
If you've built an application with AI tools and other people's information is going into it, you can do a quick version of my test today. Create two accounts for two different customers or businesses. In the first, create a record and copy its link or ID. Sign in as the second account and try to open that record, either through the link or by putting the ID into a request. If you can see it, you have the same problem I had.
If you're refused, that's a good sign, but it isn't the whole picture. These are the questions I now ask of every application before real customers use it. Tick off the ones you can honestly say yes to.
Work through the list honestly. Any box you can't tick is worth looking at before real customers arrive.
I'd also change how you talk to your AI tools. Don't ask them to make the app secure. Ask them to explain the security: every place customer data is stored, every route to it and every check that protects it. Ask them to find the weak points before they change anything, then test the result yourself. AI is a good helper in this investigation, but it shouldn't be the only judge of whether its own work is safe.
Building it is not the same as protecting it
I still think AI has changed software development for the better. It lets people test ideas faster, build complex features in days and turn ideas into products without a large team. That's worth a lot. But being able to build an application is different from being ready to look after the information inside it.
When customers give your app their details, their records and their finances, they're trusting the people behind it. They don't care whether it was built with AI, written by hand or both. They expect their information to be seen only by the people allowed to see it.
A feature that works is not the same as a feature that's safe. A login screen is not a security plan. And an app that looks finished can still have a serious problem waiting underneath. That night, I learned to ask AI not just what it built, but what it can prove.
The most important part of an application is often the part customers never see. It's also the part you can't afford to get wrong.
If you've built an app with Lovable, Bolt, Cursor or another AI tool and you're not sure what's protecting your customers' data, that's exactly what I check. Find out how I take AI-built apps to production, or read why vibe coding and production engineering are not the same thing.





