Key takeaways
- Audit with a fresh, read-only agent session – not the session that wrote the code – and ask for findings with file, line and severity, not fixes.
- Work in five passes: secrets, transport, authentication and authorization, platform surface, dependencies.
- Most serious findings in agent-built apps sit on the server side: missing authorization checks and permissive database rules.
- Confirm each high-severity finding by reproducing it, fix it in a small pull request and add a rule so the agent does not repeat it.
Why demos hide security flaws
A coding agent optimizes for the outcome you describe. "Users can see their orders" gets you a screen that shows orders – and often a query that would show anyone's orders to anyone who changes an ID. Nothing in the demo reveals it, because the demo only ever has one user. The same pattern repeats with database rules switched off "temporarily", API keys inlined to get a feature working, and permissions added because an example used them.
None of this means agents write worse code than people in a hurry. It means security has to be checked deliberately, because it never shows up as a visible bug. If you want a reference frame, the OWASP Mobile Application Security Verification Standard (MASVS) is a good, tool-neutral checklist; the five passes below are a practical cut through it for small teams.
Set up the agent as an auditor, not a fixer
The session that wrote the code shares its blind spots. Start a fresh one – ideally with a different tool or model – and configure it for reading:
- Read-only permissions. No edits, no network calls to production, no access to
.envfiles or real credentials. - One pass per session. "Find every place secrets reach the client" produces better results than "audit the app".
- Structured output. Ask for a table: finding, file and line, why it matters, severity, how to verify. No fixes yet.
- Evidence over opinion. Instruct it to mark anything it could not confirm in the code as "suspected".
Treat the output as leads, not a verdict. Agents produce false positives (a test key flagged as live) and false negatives (an authorization check that exists only in a database policy they did not read). Our article on security risks of agentic coding covers the other side: keeping the agent itself from becoming a risk while it works in your repository.
Talk to an AI Code Engineer about shipping your app to the App Store and Google Play.
In a free call we look at what you built, tell you honestly what stands between it and an approved release – and whether you need us at all.
The five passes
Pass 1: Secrets
Search source, config files, build scripts and git history for API keys, service accounts, signing material and private URLs. Then check the built artefact, not just the source: environment variables with client prefixes end up inside the JavaScript bundle. Our playbook on secrets and API keys explains how to move what you find behind a backend.
Pass 2: Transport
Look for App Transport Security exceptions in Info.plist, cleartextTrafficPermitted or a permissive network security config on Android, custom certificate validation that accepts everything, and WebViews loading HTTP content. Agents add these to make a local development server reachable and forget to remove them.
Pass 3: Authentication and authorization
This is where the serious findings usually are. For every endpoint and database table: who can read, who can write, and is that enforced on the server? Check row-level security or security rules, IDs taken from request parameters instead of the session, admin functions reachable by normal users, and tokens stored in plain preferences instead of the Keychain or the Android Keystore.
Pass 4: Platform surface
Compare requested permissions with what the app uses. Check exported Android components, deep links and URL schemes that open screens without validation, JavaScript bridges in WebViews, personal data in logs, and sensitive screens that appear in the app switcher. Unused permissions are also a store problem – see the sensitive permissions guide.
Pass 5: Dependencies
List every package and SDK with its purpose. Remove what is unused, check that each name is the real package and not a similarly named one an agent guessed, and run the ecosystem's vulnerability check. Every third-party SDK also needs to appear in your privacy answers.
Tools the agent can run for you
Agents are good at running scanners and summarizing long output. Pair each pass with a tool so the audit does not rely on the model reading every file:
| Pass | Tool type | Examples | Agent's job |
|---|---|---|---|
| Secrets | Secret scanner over files and history | gitleaks, GitHub secret scanning | Triage hits, separate test keys from live ones |
| Code patterns | Static analysis | Semgrep, platform linters | Group findings, discard noise with a reason |
| Built app | Mobile app scanner | MobSF on the IPA or APK | Map findings back to source files |
| Dependencies | Vulnerability database check | npm audit, OSV-Scanner, Dependabot alerts | Propose upgrades, flag breaking changes |
| Backend rules | Provider advisors and rule tests | Your database's security advisor, rule unit tests | Write tests that prove one user cannot read another's data |
Triage, fix and make it stick
Sort findings into three buckets: exploitable now (fix before the next release), risky by design (plan a fix), and hygiene (batch it). For every high-severity item, a human reproduces it – for example by calling the endpoint with a second test account – before anyone writes a fix. That step also catches false positives.
Then let the agent fix one finding per pull request, each with a test that fails before and passes after. Finally, write the lesson into the agent's instruction file: "every new table gets row-level security and a test with two users", "no ATS exceptions without review". Our guide to CLAUDE.md and AGENTS.md shows where such rules go, and reviewing agent-generated code shows how to catch regressions in review.
When a self-audit is not enough
If your app handles health, financial or children's data, or a customer contract demands it, a self-audit is a starting point, not the end. Get an independent penetration test. For teams that want to build the habit in-house, our secure agentic coding workshop runs these passes on your own codebase, following ISO 27001-aligned practices from our own certified operations.
Security audit checklist for agent-built apps
- Audit runs in a fresh, read-only agent session without production credentials.
- No secret keys in source, git history or the built bundle.
- No leftover App Transport Security or cleartext exceptions.
- Every table and endpoint enforces authorization on the server, proven by a two-user test.
- Tokens stored in the Keychain or Android Keystore, not in plain preferences.
- Requested permissions match used features; Android components are not exported by accident.
- Deep links and WebView bridges validate their input.
- Every dependency is needed, correctly named and free of known critical vulnerabilities.
- High-severity findings reproduced by a human, fixed with a test and turned into an agent rule.
Frequently asked questions
Can a coding agent audit code it wrote itself?
It can, but a fresh session – ideally another tool or model – finds more, because it does not share the assumptions of the original session. Keep it read-only and ask for evidence for every finding.
Which findings matter most in AI-built apps?
Usually two: missing server-side authorization, often as disabled or overly broad database rules, and secret keys that reached the app bundle. Both are invisible in a demo and both can expose every user at once.
Does App Review check my app’s security?
Not in depth. Reviewers test behavior, privacy disclosures and policy compliance. A security hole can pass review and still expose your users, which is why the audit is your job.
Can you audit our agent-built app?
Book a free call. An AI Code Engineer looks at your stack, tells you where the risks are likely to be and whether a focused review, a workshop or an external penetration test fits best.
Free, 15 minutes, no obligation
Get your app from agent output to approved release.
Our AI Code Engineers take apps built with Claude Code, Codex, Cursor, Lovable, Base44 and co. through signing, CI/CD, store listings and review – in your own developer accounts.
AI tools, store policies and requirements change quickly – always check the current documentation of the tools and stores you use. This article is independent advice and not affiliated with or endorsed by Apple, Google, Anthropic, OpenAI or any other company or product mentioned; all trademarks belong to their owners.