An AI agent writes code that runs. It does not, by default, write code that is safe to put in a stranger’s hands. The agent is optimising for “the feature works,” and the quickest way to make a feature work is often to open a door: a permissive database rule, a key pasted into a Dart file, a token in plain storage.
None of these mistakes are new. OWASP’s Mobile Top 10 for 2024 lists most of them, starting with “M1: Improper Credential Usage.” What is new is how fast an agent can ship them. This post lists the eight we see most often in vibe-coded Flutter apps and how to check for each. It is part of our guide to vibe coding a mobile app.
1. Database rules left in test mode
Firebase’s console lets you start a database in “Test mode,” which grants access to all users. Agents often keep it, because every write succeeds. Firebase’s own page on insecure rules shows the pattern and the warning:
// NEVER use this ruleset in production
allow read, write: if true;
Firebase says: “If you’re not authenticating users and configuring security rules, then anyone who guesses your project ID can steal, modify, or delete the data.”
Check: open firestore.rules and storage.rules. Look for if true, rules with no condition, and rules that only check request.auth != null. Firebase warns about that last one too: “confirm that you want any logged-in user to have access to the data.” Usually you want owner-only access, like Firebase’s example:
allow read, delete: if request.auth.uid == resource.data.author_uid;
2. Supabase tables without Row Level Security
The Supabase version of the same mistake. Its docs say: “A table in an exposed schema without RLS is readable and writable by any role with a grant on it. Enable RLS on every table in an exposed schema.” Once RLS is on, “no data is accessible through the API when using a publishable key, until you create policies.”
Check: every table in public has RLS enabled and at least one policy that limits rows to the signed-in user.
3. Secret keys in the app
Agents paste API keys wherever the code needs them. Some keys are fine in a client and some are not, and the agent rarely knows which.
- Firebase config keys are fine. Firebase says “API keys for Firebase services are OK to include in code or checked-in config files.” Protection comes from rules and App Check.
- AI provider keys are not. Firebase says a Gemini Developer API key “should never be included in your code or configuration files.” The same applies to any paid AI or payment key.
- Server keys are never fine. Supabase’s
service_rolekey “bypasses RLS, so keep it server-side,” and its docs say “Never use a secret key in the browser or expose it to customers.”
Check: search the repo for sk-, service_role, secret, apiKey and .env files bundled as assets. Move anything secret behind a server function you control.
4. Trusting obfuscation
An agent may suggest obfuscation to “hide” a key. Flutter’s docs are clear: “It is a poor security practice to store secrets in an app,” and obfuscation “does not encrypt resources nor does it protect against reverse engineering. It only renames symbols with more obscure names.” Obfuscation is still worth turning on for release builds:
flutter build apk --obfuscate --split-debug-info=build/symbols
It just is not a place to keep secrets.
5. Tokens in plain storage
Session tokens, refresh tokens and personal data often end up in SharedPreferences because that is the first storage API the agent reaches for. Use secure storage for anything sensitive. The flutter_secure_storage package “Uses Keychain for iOS/macOS” and on Android encrypts values with “RSA OAEP (key cipher) + AES-GCM (storage cipher).” OWASP lists this as “M9: Insecure Data Storage.”
6. Checking permissions only in the UI
A common agent shortcut: hide the “premium” button in the app, but leave the premium data readable by anyone who calls the backend. The same goes for admin screens. Anything the client can skip, an attacker can skip. Enforce access in rules or on the server. OWASP calls this “M3: Insecure Authentication/Authorization.”
The purchase version of this mistake is granting premium content from a client-side flag. Verify purchases on a server or through your subscription provider. See RevenueCat with Flutter.
7. Unreviewed dependencies
Agents add packages freely. Each one is code you ship. OWASP lists “M2: Inadequate Supply Chain Security.”
Check: read pubspec.yaml after every session. Remove packages you do not use, prefer well-maintained ones, and ask the agent why it added anything you do not recognise.
8. Logging and sending too much
Debug prints with tokens and emails, analytics events with personal data, crash reports with request bodies. These leak data and can contradict your privacy label. OWASP lists “M6: Inadequate Privacy Controls.” Apple and Google both expect your declared data use to match the app. See App Store privacy labels and the Google Play data safety form.
Make the agent check its own work
You can turn this list into a review step. Put the rules in your CLAUDE.md so the agent follows them while it builds:
## Security rules
- Never put secret keys in Dart code or assets. Use a server function.
- Every Firestore and Storage rule must check request.auth.uid ownership.
- Store tokens with flutter_secure_storage, never SharedPreferences.
- Enforce premium access on the server, not only in the UI.
Then, before each release, run a separate review pass with a fresh context and ask it to look only for these issues. A reviewer that did not write the code is more likely to catch them. See a Claude Code subagent code reviewer for one way to set that up, and the full mobile app security checklist for everything else.
The short version
Most security problems in vibe-coded apps come from the backend being open, not from clever attacks on the app. Lock the rules, move secrets to a server, store tokens securely, and enforce access where the client cannot reach. MobileKit’s QA stage runs these checks before release, but a ten-minute manual pass catches most of them too.
Sources read on the day this post was written: OWASP Mobile Top 10, OWASP Mobile Top 10 2024 risks, Firebase: avoid insecure rules, Firebase: API keys, Supabase: Row Level Security, Flutter: obfuscate Dart code and flutter_secure_storage.