What I find when someone hands me their Lovable app, and how I scope the fix
Someone sends you a Lovable app and says "can you just fix it". Before you give a price, you should know what is probably inside. I'm Denys, a Forward Deployed Engineer, and I get these a lot. I wrote this with an AI ass
Someone sends you a Lovable app and says "can you just fix it". Before you give a price, you should know what is probably inside. I'm Denys, a Forward Deployed Engineer, and I get these a lot. I wrote this with an AI assistant and checked it against my own notes.
Short version: the screens are rarely the problem. The database is. A Lovable app talks to Supabase straight from the browser, so every rule about who sees what lives in Postgres, and that is where I start reading. Not in the React.
The first hour
I ask for read-only access and I do not open the app first. I look at grants, policies, views, functions and the migration files. Then I run the app and see if it matches. The same few things turn up again and again.
Roles that come from the client. A new-user trigger reads the invited role from raw_user_meta_data. That field is whatever the client sent to signUp, so anyone who registers can ask to be an owner. Roles belong in a table only the server writes, or in app_metadata.
A policy that checks the wrong thing. auth.uid() is not null means "any signed-in user", and with open sign-up that is everyone. Related: a request carries a project id and a task id, the code checks the project, and nobody checks that the task belongs to it. The row lands in someone else's project and the policy is happy, because the insert stamps the attacker's own id.
Views that skip the policies. A view runs with its owner's rights, and in Supabase the owner is usually postgres. A view over a protected table hands out the rows the policies hide, unless it has security_invoker = true.
NULL treated as allow. In PL/pgSQL, if not (has_permission or assignee_id = auth.uid()) does not raise when assignee_id is null. The whole condition is null and the if is skipped. The same expression inside a policy is safe, which is what makes the bug easy to miss.
A rate limit that never fires. The counter lived in a variable inside an edge function. On the hosted platform each request got a fresh isolate, so the counter was always 1. Locally the isolate is reused, so every local test passed.
None of these show on a screen. A quote that is based on the screens will miss all of them.
Repair or rebuild
I sort each part of the app into keep, fix or rewrite. Most parts stay. A rewrite fixes nothing this week and throws away behaviour your client's users already rely on. It is right only when the data model is wrong at the root, for example when there is no way to tell which company a row belongs to.
The honest answer usually comes in two steps. First a diagnosis, then a price for the fix. If someone asks you to quote a full rebuild before you have read the code, that is a guess, and you will be held to it. I wrote the long version of how I compare the options, with published prices, in a guide on how to hire a developer to fix a Lovable app. I am one of the options in it and it says where others fit better.
Fix the class, not the report
The first bug you find is rarely the only one. On one app, forged records took five review rounds, because each fix blocked one combination of type and status and left a sibling open. What closed it was a trigger that allows only the listed combinations and ignores whatever the client sent. When you fix one write path, list every writer of that column first. After the main insert was fixed, the same bypass was still sitting in attachments, comments and the restore of a deleted item.
Functions need the same attention. Anything in public is callable over /rpc by any role with EXECUTE, and RLS does not apply to it. But revoking EXECUTE carelessly can break public pages. Postgres checks EXECUTE on every function used by a policy that applies to the role, even in a branch that never runs. Once anon lost EXECUTE on an is_admin() helper, every anonymous read failed with 42501.
Access you can remove
Work in the owner's accounts, with access they can take away. Hosting stays in their name. If you ask for the project to be moved to yours before you have looked at anything, you look like the problem you were hired to solve. It also protects you. When something breaks a month later, nobody wonders what you did in your own account.
A test they can rerun
"Fixed" is a claim until something proves it. Leave the owner a test they can run themselves, not a message saying it works. Two traps I hit here:
- The local stack and the hosted project had different default privileges. "anon cannot insert" passed locally because the grant was missing, not because RLS worked. A negative test means something only when the positive grant exists.
- After a migration or a project move, compare what is live:
pg_policies, the function bodies, the grants. On one app a new migration copied an old function body and quietly undid a later fix.
Also ask what happens next week, when the owner changes the app with Lovable again. A prompt that makes a warning go away can do it by widening access. So the rerunnable test is worth more than a clean report today.
What I tell the owner
That I read the code before quoting. That most of it stays. That I know what I did not check, and I say what that is. That they keep the keys. If the app needs a team for a big rebuild, or a penetration test with a certificate, I say that is not me.
If you have done this kind of handover, did I miss something you always find? Tell me in the comments.
Written with AI assistance, checked by me.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.