AI App Rescue: automated diagnosis
Project: Demo app built to fail (Lovable-style, synthetic)
Date: 2026-11-29
Files read: 14
Tool: rescue_scan 0.1.0 (static, read-only: your code was read, never run)
Verdict
Not safe for real users or payments yet. 5 critical problem(s) below can expose or destroy data today.
Summary
| Severity | Problems |
|---|---|
| CRITICAL | 5 |
| HIGH | 6 |
| MEDIUM | 6 |
| LOW | 4 |
| INFO | 1 |
Fix these first
- [CRITICAL] Supabase service_role key is in the code (1x)
- [CRITICAL] Browser code creates a Supabase client with the service_role key (1x)
- [CRITICAL] Table without Row Level Security (2x)
- [CRITICAL] Firebase security rules allow anyone to read or write (1x)
- [CRITICAL] Live Stripe secret key is in the code (1x)
Findings
1. [CRITICAL] Supabase service_role key is in the code
Where:
.env:3eyJhbGci…89 (201 chars) role=service_rolein an env file
Why it matters: This key skips every Row Level Security rule. Whoever has it can read, change and delete all data in the database.
How to fix: Rotate the key in Supabase (Settings > API) now. Keep it only in server-side secrets (Edge Function secrets, your host's env vars), never in frontend code or VITE_/NEXT_PUBLIC_ variables.
2. [CRITICAL] Browser code creates a Supabase client with the service_role key
Where:
src/lib/admin.ts:6import.meta.env.VITE_SUPABASE_SERVICE_ROLE_KEY );
Why it matters: Code that runs in the browser is public. A service_role client there gives every visitor full database access.
How to fix: Use the anon key in the browser; move privileged operations to an Edge Function that checks the user's JWT.
3. [CRITICAL] Table without Row Level Security
Where:
supabase/migrations/20250102000000_tweaks.sqlpublic.notessupabase/migrations/20250101000000_init.sqlpublic.orders
Why it matters: With RLS off, anyone who has your public anon key (it is in your website's JavaScript) can read, change and delete every row of this table.
How to fix: alter table public.<table> enable row level security; then add policies that only let users reach their own rows (e.g. using (auth.uid() = user_id)).
4. [CRITICAL] Firebase security rules allow anyone to read or write
Where:
firestore.rules:5allow read, write: if true;
Why it matters: Open rules mean the whole database or storage is public and writable.
How to fix: Replace with rules that require request.auth != null and check ownership, e.g. request.auth.uid == userId.
5. [CRITICAL] Live Stripe secret key is in the code
Where:
supabase/functions/stripe-webhook/index.ts:4sk_live_…89 (42 chars)hard-coded in server code (still in the repository)
Why it matters: With this key anyone can issue refunds, read customer data and create charges on your account.
How to fix: Roll the key in the Stripe Dashboard (Developers > API keys), then move it to a server-side secret.
6. [HIGH] Policy lets anyone on the internet read a whole table
Where:
supabase/migrations/20250101000000_init.sqlpublic.profiles: "Profiles are viewable by everyone" FOR SELECT TO public
Why it matters: using (true) for anon/public on select exposes every row to anyone. Fine for truly public content (blog posts, product list); a data leak for anything personal.
How to fix: If the table holds personal or business data, limit the policy to the owner: using (auth.uid() = user_id).
7. [HIGH] Any logged-in user can change every row
Where:
supabase/migrations/20250101000000_init.sqlpublic.messages: "Authenticated users can do anything" FOR ALL TO authenticated
Why it matters: A policy with true for authenticated on insert/update/delete lets any user who signs up edit or delete other users' data.
How to fix: Add an ownership condition: using (auth.uid() = user_id) with check (auth.uid() = user_id).
8. [HIGH] Stripe webhook handler does not verify the signature
Where:
supabase/functions/stripe-webhook/index.ts:8checkout.session.completed
Why it matters: Without constructEvent, anyone can POST a fake 'checkout.session.completed' and get the product without paying.
How to fix: Verify every event with stripe.webhooks.constructEvent(rawBody, signature, endpointSecret) (or constructEventAsync in Deno) before acting on it.
9. [HIGH] A secret is stored in a browser-exposed variable
Where:
.env:3VITE_SUPABASE_SERVICE_ROLE_KEYin an env filesrc/lib/admin.ts:6VITE_SUPABASE_SERVICE_ROLE_KEYin code that is sent to the browser
Why it matters: Variables starting with VITE_, NEXT_PUBLIC_, REACT_APP_, EXPO_PUBLIC_ or PUBLIC_ are copied into the JavaScript every visitor downloads.
How to fix: Rename the variable without the public prefix and read it only in server-side code (Edge Function, API route).
10. [HIGH] AI provider API key (OpenAI / Anthropic) is in the code
Where:
src/lib/ai.ts:1sk-proj-…ij (52 chars)in code that is sent to the browser
Why it matters: Leaked AI keys are found by bots within hours and used to run up your bill.
How to fix: Revoke the key in the provider's console, set a spending cap, and call the AI API only from a server-side function.
11. [HIGH] Dependency with a known vulnerability
| Package | Version | Fixed in | Advisories |
|---|---|---|---|
| lodash | 4.17.15 | 4.18.0 | GHSA-29mw-wpgm-hmr9 (CVE-2020-28500): Regular Expression Denial of Service (ReDoS) in lodash; GHSA-35jh-r3h4-6jhm (CVE-2021-23337): Command Injection in lodash; GHSA-p6mc-m468-83gw (CVE-2020-8203): Prototype Pollution in lodash and 2 more |
Why it matters: Published advisories (OSV / GitHub) list this exact version as vulnerable.
How to fix: Upgrade to the fixed version shown, run the tests, and redeploy.
12. [MEDIUM] .env file is in the repository
Where:
.envnon-public: VITE_SUPABASE_SERVICE_ROLE_KEY, <secret value>
Why it matters: Anything in a committed .env file stays in git history even after you delete it.
How to fix: Rotate every secret that was in the file, remove the file from git, and add .env* to .gitignore.
13. [MEDIUM] Dependency with a known vulnerability
| Package | Version | Fixed in | Advisories |
|---|---|---|---|
| vite (dev only) | 5.0.0 | 6.4.4 | GHSA-356w-63v5-8wf4 (CVE-2025-32395): Vite has an server.fs.deny bypass with an invalid request-target; GHSA-4r4m-qw57-chr8 (CVE-2025-31125): Vite has a server.fs.deny bypassed for inline and raw with ?import query; GHSA-4w7w-66w2-5vf9 (CVE-2026-39365): Vite Vulnerable to Path Traversal in Optimized Deps .map Handling and 20 more |
Why it matters: Published advisories (OSV / GitHub) list this exact version as vulnerable.
How to fix: Upgrade to the fixed version shown, run the tests, and redeploy.
14. [MEDIUM] SECURITY DEFINER function without a fixed search_path
Where:
supabase/migrations/20250101000000_init.sqlpublic.is_admin
Why it matters: These functions run with the owner's rights and skip RLS. Without set search_path, a caller can make them run objects they control (Supabase lint 0011).
How to fix: Add set search_path = '' (and schema-qualify names) or set search_path = public to the function definition.
15. [MEDIUM] Edge Function with JWT verification turned off
Where:
supabase/config.toml:4stripe-webhook
Why it matters: verify_jwt = false means anyone can call this function. Right for webhooks that check their own signature; wrong for anything that acts on behalf of a user.
How to fix: Turn verify_jwt back on, or make sure the function verifies a signature or token itself.
16. [MEDIUM] Anyone on the internet can add rows to a table
Where:
supabase/migrations/20250101000000_init.sqlpublic.waitlist: "Anyone can join" FOR INSERT TO anon
Why it matters: Normal for a contact form or a waitlist; otherwise it lets bots fill your database with junk or fake records.
How to fix: If only users should add rows, restrict to authenticated with with check (auth.uid() = user_id); if it is a public form, add rate limiting or a captcha in an Edge Function.
17. [MEDIUM] View in the public schema that bypasses RLS
Where:
supabase/migrations/20250101000000_init.sqlpublic.order_totals
Why it matters: Postgres views run with the creator's rights by default, so a view over a protected table can show all rows to anyone (Supabase lint 0010).
How to fix: Create it with (security_invoker = true) (Postgres 15+), or move it out of the exposed schema.
18. [LOW] Raw HTML is injected without a sanitiser
Where:
src/components/Post.tsx:5dangerouslySetInnerHTML
Why it matters: dangerouslySetInnerHTML / v-html with user content allows script injection (XSS), which can steal sessions.
How to fix: Sanitise with DOMPurify before rendering, or render as text.
19. [LOW] .gitignore does not exclude .env files
Where:
.gitignore
Why it matters: The next .env created on this project will be committed by accident.
How to fix: Add .env and .env*.local to .gitignore.
20. [LOW] Public storage bucket
Where:
supabase/migrations/20250101000000_init.sqlinvoices
Why it matters: Files in a public bucket can be downloaded by anyone who has or guesses the URL. Fine for avatars and images, not for invoices, IDs or uploads.
How to fix: Make the bucket private and serve files with signed URLs if they are not meant to be public.
21. [LOW] RLS is on but the table has no policies
Where:
supabase/migrations/20250101000000_init.sqlpublic.audit_log
Why it matters: Safe (nobody can reach it through the API), but if the app reads or writes this table from the browser it will fail silently: the classic 'it saves but nothing appears'.
How to fix: If the browser needs it, add owner-scoped policies; if only the server uses it, leave as is.
22. [INFO] Supabase anon (public) key found: expected, and only safe with RLS
Where:
.env:2eyJhbGci…89 (191 chars) role=anonin an env file
Why it matters: The anon key is meant to be public. Your data is protected only by Row Level Security policies, so the database checks in this report decide whether this is safe.
How to fix: Nothing to do for the key itself. Make sure every table has RLS on with correct policies.
What this scan does not cover
- It reads the code; it does not run the app or attack it. It is not a penetration test.
- Database rules are read from the SQL files in the repository (loose scripts first, then migrations by date). Changes made by hand in the Supabase dashboard are not in the files, and scripts may have run in another order: the read-only query
sql/rls_check.sqlchecks the live database. - Business logic (who may do what), Edge Function authorisation, rate limits and payment flows need a human review. That review is part of the paid written diagnosis.
- A secret found here should be treated as leaked even if the repository is private: rotate it.