The risk is measurable. In Veracode’s 2025 GenAI Code Security Report, AI models introduced a vulnerability from the OWASP Top 10 in 45% of the test cases. Broken access control, where people can see or change data they shouldn’t, is first on the OWASP Top 10:2025. And in May 2025, CVE-2025-48757 was published for apps made with an AI app builder whose databases lacked row-level security, which let anyone read or write their tables. None of this means you should stop building with AI. It means someone has to check the work.
1. Keep secret keys on the server
Anything the browser downloads is public: the page source, the JavaScript files and their source maps. Only keys that are meant to be public belong there, such as a database’s publishable key that row-level security protects. AI model keys, service-role keys and payment and email keys stay in server environment variables, and the browser talks to your own server, never straight to those services.
How to tell which keys are secret
Ask what the key can do on its own. If it can get past your access rules, send email, charge a card, read every customer or run up an AI bill, it is secret. A key that is safe in the browser can only do what your access rules already allow a visitor to do. If in doubt, treat it as secret.
2. Enforce access on the server, not in the interface
Hiding a button does not protect data. Anyone can call your API or database directly with the same public key the app uses. Turn on row-level security for every table, write a policy for each role and test it twice: as a logged-out visitor and as the lowest role you have.
Test it with two accounts
Create two test users. As the first, open a record and note its ID in the address bar or the request. As the second, ask for that ID, then try to change it. If either works, a rule is missing. Test reading, adding, changing and deleting separately: a rule can cover one and miss the others.
Calculations belong on the server too. In the Lumen Painting admin, the database works out the HST and the totals on every invoice, never the browser.
3. Give each person only the access they need
A salesperson needs product files, not ad spend or supplier terms. Set access per role, remove people the day they leave and review the list every quarter. In the sales app I built for Glass Railing Store, each person gets one of five levels, from no access to full, in each of eight areas, and the database checks those permissions as well as the menu.
4. Put nothing private in the page before login
AI-built apps often ship as one big file that loads before the login screen. If that file holds customer emails, supplier numbers, revenue figures or old comments, they are public, however good the login looks. Open the app in a private window, view the source and search the JavaScript for names, emails and numbers you would not post online.
5. Make file storage private by default
Storage that holds quotes, contracts, reports or customer photos should be private. Serve files through short-lived signed links that your server creates after it checks who is asking. The Lumen Painting admin keeps invoice photos and project files this way, in private storage behind links that expire.
6. Check share links and logins on the server
Share links need an expiry date and a check on the server every time they are opened. Login limits work the same way: a lockout counted in the browser disappears when someone clears their storage or calls the login endpoint directly. Count failed attempts on the server and slow them down.
7. Add security headers
Set them once for the whole site in your host settings. Google’s web.dev reference explains the main ones:
- Content-Security-Policy: a policy that allows only your own scripts stops most injected code from running. It is an extra layer, so you still escape and sanitize what users type.
- Strict-Transport-Security (HSTS): tells the browser never to load the site over HTTP, only HTTPS.
- X-Content-Type-Options set to
nosniff: recommended for all of your resources. - frame-ancestors in the policy, or X-Frame-Options: decides who may embed your pages.
frame-ancestors 'none'lets no one, which protects against clickjacking.
Add a strict referrer policy as well. This website runs with a policy that blocks inline scripts on every page.
8. Pin the code you load from other sites
A script pulled from a CDN without a fixed version can change under you. Pin exact versions and add Subresource Integrity hashes, or host the files yourself. Software supply chain failures are number three on the OWASP Top 10:2025.
Check every package an AI assistant adds before you install it: the spelling, the publisher, its age and how many people use it. One that is brand new, barely used or one letter off a popular name deserves a second look. Remove packages the app no longer uses; each one is code you have to trust.
9. Keep secrets out of chats, tickets and git
Keys leak through screenshots, support tickets, AI chats and commits. Store them in your host’s secret settings, keep .env files out of git and rotate any key that was ever pasted somewhere it shouldn’t be. Deleting a key in a later commit isn’t enough, because the earlier commit still holds it: revoke the key and issue a new one.
10. Log access and keep an off switch
Record sign-ins, role changes and exports, and read them. Make sure you can remove a user, rotate a key or switch the app off in minutes. Security logging and alerting failures are on the OWASP Top 10:2025 too.
If something leaks
- Close the hole first: switch the app off, revoke the key or remove the access.
- Read the logs to find what was opened, changed or exported, when and by whom.
- Fix the cause, repeat the test that would have caught it, then switch the app back on.
- Work out, with legal advice, who you need to tell: customers, partners and, where the law requires it, a privacy regulator.
If the app has AI features
An assistant inside the app adds one more way in: the text it reads. An email, a PDF or a web page can contain instructions written by someone else, and the model may follow them. So give the AI the limits you would give a new employee:
- It acts with the permissions of the person using it, never more.
- Anything it saves or sends passes checks on the server first.
- Prices, refunds, discounts and emails to customers wait for a person to approve them.
- Its answers are shown as text, never run as code.
Lumen Painting’s website assistant works this way: server-side checks remove invented prices, outside links and contact details that aren’t the company’s before anything is saved.
A one-hour test before launch
- Open the app logged out in a private window and try every address you know.
- Log in as the lowest role and try to open what that role should not see.
- Search the page source and the JavaScript for keys, emails and internal notes.
- Check the response headers in your browser’s developer tools.
- Run your package manager’s audit, such as
npm audit, and update what it flags.
If the app holds customer, payment or health data, have someone who didn’t build it repeat the test. Security checks are part of the launch step in every AI automation project I take on, and the same standard applies to the websites I build. For what to automate first, read six marketing workflows worth automating.
Questions
Is vibe coding safe for business apps?
The risk is measurable: in Veracode’s 2025 GenAI Code Security Report, AI models introduced a vulnerability from the OWASP Top 10 in 45% of the test cases. That doesn’t mean you should stop building with AI. It means someone has to check the work before anyone on your team logs in.
Can I put API keys in my front-end code?
Only keys meant to be public, such as a database’s publishable key that row-level security protects. Anything the browser downloads is public, including the page source, the JavaScript files and their source maps, so AI model keys, service-role keys and payment and email keys stay in server environment variables.
Why do AI-built apps need row-level security?
Because hiding a button doesn’t protect data: anyone can call your API or database directly with the same public key the app uses. In May 2025, CVE-2025-48757 was published for apps made with an AI app builder whose databases lacked row-level security, which let anyone read or write their tables.
How do I test an AI-built app before launch?
In about an hour: open it logged out in a private window and try every address you know, log in as the lowest role and try to open what that role shouldn’t see, search the page source and JavaScript for keys, emails and internal notes, check the response headers and run your package manager’s audit, such as npm audit.
Sources
- AI-generated code poses major security risks in nearly half of all development tasksVeracode, July 30, 2025
- OWASP Top 10:2025OWASP Foundation
- CVE-2025-48757National Vulnerability Database, May 2025
- Security headers quick referenceweb.dev, May 18, 2021




