A page generated by an AI coding tool can look fine. It may even support registration, login, and private messaging without errors. That does not mean it is safe to deploy.
The research page “Lovable apps expose passport details and more than 200K private messages” disclosed exposed data that included sensitive personal information such as users’ passports, along with more than 200,000 private messages. The research reached the Hacker News front page, earning 256 points and 79 comments.
The incident is worth examining in detail. This was not simply a case of a model generating bad code. It exposed a gap between prompting, preview environments, and production deployment: code can be generated, but no one automatically supplies the safeguards that developers need.
Original research: https://www.crissyfield.de/research/lovable-en/
Hacker News discussion: https://news.ycombinator.com/item?id=50499017
The Leak Exposed Application Boundaries, Not Just Code
Traditional code audits usually begin with the code itself: Is there SQL injection? Are there hardcoded secrets? Does the project depend on vulnerable libraries?
AI-generated applications add another layer. A developer enters a natural-language request, and the model turns it into a frontend, backend, database tables, and APIs. A prompt might say only “build a social app,” without specifying:
- Which fields only the user should be able to read;
- Which endpoints require authentication;
- Whether preview environments can access real data;
- Whether production releases retain the broad permissions of test environments;
- What default policies apply to third-party services, object storage, and databases.
These are product decisions that a model cannot reliably infer on its own. When permissive defaults are used, the faster an application is generated, the faster those misconfigurations are also replicated.
Passport information is highly sensitive personal data. Once exposed, the damage goes beyond changing a password or deleting a message. Identity theft, fraud, and cross-service correlation risks all increase. More than 200,000 exposed private messages also suggest that the breach extended beyond a single test account.
The central issue is therefore not whether Lovable can write code. The question is whether the applications it generates establish clear boundaries between real users and production data.
Three Stages Between a Prompt and Real Data
1. Build Stage: Malicious Instructions Can Enter the Requirements
Users give AI coding tools instructions such as:
Add an upload feature and save the files to a public directory.
Once the model follows that instruction, the upload directory, static asset service, and access policy may all be configured for public access.
The problem becomes more serious when a repository’s README, issues, or environment documentation contains malicious text. A developer may copy what appears to be a harmless configuration, and the AI may treat it as project context. Once an AI Agent has terminal, database, or deployment access, prompt injection can do more than produce incorrect code: it can trigger incorrect actions.
2. Preview Stage: The Test Interface May Connect to Real Data
Preview environments are intended to be low-risk sandboxes, but configurations like the following are common:
DATABASE_URL=真实生产数据库地址
AUTH_SECRET=生产环境密钥
OBJECT_STORAGE_PUBLIC=true
The application runs locally because it reads production data directly. If the preview URL is publicly accessible, authentication middleware is missing, or object-storage policies are too permissive, a test account may see real users’ content.
In the Lovable case, passport information and a large volume of private messages appeared together. That points to a failure to align data-access boundaries with UI permission boundaries.
3. Deployment Stage: A Successful Release Does Not Mean Correct Authorization
Deployment pipelines usually check whether a build succeeds, whether the port is healthy, and whether the page loads. These are availability checks, not security checks.
Both of the following endpoints could return a 200 response:
GET /api/messages/:userId
GET /api/messages/:userId
Authorization: Bearer <任意有效或缺失的令牌>
The difference lies in the authorization logic. A successful database query only shows that the query ran. Without a per-user check, the user_id in the data model has not become an access-control condition.
This is where AI coding tools are most likely to be overlooked. Models can quickly produce CRUD endpoints, but they do not automatically understand organization, tenant, role, ownership, and audit requirements.
What the Lovable Case Reveals
First, code-generation quality and access-control quality are separate metrics.
Valid syntax, complete pages, and visible data do not prove that an endpoint allows only the data owner to access the resource. AI is often good at generating the main path: registration, login, lists, and detail views. Permissions, however, tend to live in conditional branches, row-level filters, and middleware. If those requirements appear only in a vague prompt, the model is likely to produce something suitable for a demo but not for production.
Second, database access should be the first place to inspect.
A typical vulnerable endpoint looks like this:
export async function GET(
request: Request,
{ params }: { params: { userId: string } }
) {
const messages = await db.messages.findMany({
where: { userId: params.userId },
})
return Response.json(messages)
}
There is no syntax error or runtime exception. However, the endpoint trusts the userId in the URL. If the logged-in session does not participate in the query, changing one parameter lets a user read someone else’s messages.
A secure version should at least derive the user’s identity from a verified session on the server and explicitly check resource ownership:
export async function GET(request: Request) {
const session = await requireSession(request)
const messages = await db.messages.findMany({
where: { userId: session.user.id },
})
return Response.json(messages)
}
Third, authentication and authorization must not be treated as the same thing.
“The user is logged in” answers who the user is. “Can this user read this private message” answers whether the user can access a particular resource. The latter requires an object-level check. Administrator access, customer support troubleshooting, test accounts, and shared data each need their own rules.
Fourth, preview and production environments must be strictly isolated.
The easiest approach is not merely to change the database address. Each environment should use separate accounts, secrets, storage buckets, and network policies. Production data should never appear in a routine preview workflow.
Five Security Checks Developers Need to Add
1. Minimize Sensitive Data
Start with a simple question: Does this feature really need passport images, full birth dates, or long-term retention of private messages?
Collect only the fields required by the business. If a status can represent the image, do not upload the original file. If the count of messages is sufficient, do not copy every message body.
Uploaded files should also have restrictions on type, size, and storage location. Data such as passport scans should never default to a public object directory.
2. Fully Isolate Environment Variables and Data
Prepare at least three environments: local, preview, and production. Each should use an independent database account and storage bucket.
# 本地与预览只使用测试数据
DATABASE_URL="$PREVIEW_DATABASE_URL"
AUTH_SECRET="$PREVIEW_AUTH_SECRET"
OBJECT_STORAGE_BUCKET="app-preview-uploads"
OBJECT_STORAGE_PUBLIC=false
Do not rely on namespaces or NODE_ENV alone. Real isolation requires database account permissions, network policies, and storage-bucket policies working together.
3. Add Authentication and Object-Level Checks to Every Endpoint
The checklist includes:
- Do unauthenticated requests return 401?
- Do authenticated requests for another user’s data return 403 or 404?
- Do query conditions come from the server-side session rather than URL parameters?
- Do administrative endpoints have separate roles?
- Do write operations have CSRF protection or an appropriate Token policy?
A basic verification can be performed with curl:
curl -i https://example.com/api/messages/target-user-id
The expected result is 401. Then sign in as another regular user and request the same path. The response must not contain the target user’s data. Either 403 or 404 is acceptable, but the message body must not be returned.
4. Automate Scans for Common Exposure Paths
Put the checks into CI rather than relying on intuition before launch. Focus on the following:
- Whether exposed routes exist;
- Whether the code references environment variables;
- Whether authentication middleware covers each route;
- Whether database queries include user or tenant conditions;
- Whether storage buckets permit public access.
Tools can begin with static rule scans, followed by integration tests that verify unauthorized access. Scanners can only detect issues that have been encoded as rules; they cannot replace permission testing.
5. Perform a Manual Permission Review Before Launch
At minimum, have two roles walk through the entire flow: a regular user, an administrator, and an unauthenticated visitor.
The focus should not be on whether buttons work. Test the endpoints directly. Pay particular attention to lists, search, downloads, exports, shared links, and bulk actions. Many issues live outside the page, especially in public APIs.
Before release, add a data-exposure review: record access logs and check for unusually high read volumes, consecutive requests across multiple user IDs, and large exports over short periods.
What This Incident Changes
This incident differs from earlier risks associated with coding assistants. In the past, AI mainly helped developers write functions, add tests, or explain code. Even when the output was wrong, it usually remained within a code repository familiar to the developer. AI coding products now connect the frontend, backend, database, preview, and deployment into one chain, where a permissive default can immediately become an accessible production capability.
The next competitive metric for AI coding products is likely to shift from “generating a usable application in minutes” to “shipping with secure defaults.” Enterprises will ask whether preview environments can reach production data, what an Agent can do once granted deployment permissions, and whether every release automatically generates authorization tests and audit reports. These questions will matter more than first-screen design when companies choose a vendor.
The available evidence is not sufficient to conclude that the leak originated in the Lovable platform itself. A specific application configuration, third-party component, or faulty deployment may also have contributed. The original research warrants further follow-up. What is clear is that working code does not guarantee correct authorization logic. Once real passports and 200,000 private messages are exposed, AI coding tools can no longer leave security entirely to the prompt.