Skip to content

In review · not yet published

6 min readLaunchapp

One missing policy: row-level security in AI-built apps

Moltbook exposed 1.5 million tokens and a study found thousands of AI-built apps serving records to any visitor. The cause is one missing database policy.

Most data exposures in AI-built applications share one cause, and it is not exotic. The app's front end talks straight to a hosted database using a key that is meant to be public. Whether a visitor can read someone else's data then depends entirely on policies inside the database. If those policies are missing, the public key opens everything.

This part looks at one well-documented case, Moltbook, and at three pieces of research that suggest how common the pattern is. The researchers in each case reported responsibly and published their methods, and the numbers below are theirs.

What happened at Moltbook

Moltbook was a social network for AI agents. On January 31, 2026, researchers at Wiz found, in their words, "a Supabase API key exposed in client-side JavaScript". A key in client code is normal for this architecture. The problem was the other half: "without RLS policies, this key grants full database access to anyone who has it."

What that access reached, by Wiz's count:

  • 1.5 million API authentication tokens
  • 35,000 email addresses
  • 4,060 private direct-message conversations between agents, some containing plaintext OpenAI API keys
  • about 4.75 million records in total

Wiz also noted that the 1.5 million registered agents had only 17,000 human owners behind them.

The access was read and write. Wiz's timeline shows why that matters. After the first fix closed the most sensitive tables, write access was still open, and the team needed further rounds to block it: about three hours from first contact to the final fix. During that window, anyone could have edited posts that agents were reading, which turns a data exposure into a way of steering other people's agents.

The founder had said publicly, as Wiz quotes it, "I didn't write a single line of code for @moltbook." We repeat that only for context. The same omission is made by experienced teams, and the fix took the Moltbook team an evening once it was reported.

PL. 07How a public key becomes full accessCause chain · read left to right
  1. Link 01

    The browser talks straight to the database

    Guardrail

    A server tier, or policies on every table

  2. Link 02

    The key in the page is public by design

    Guardrail

    Treat the key as public and rely on policies

  3. Link 03

    Tables had no row-level security

    Guardrail

    Row-level security enabled and tested per table

  4. Link 04

    The app stored other services' keys in plaintext

    Guardrail

    Keep third-party secrets out of app tables

  5. Link 05

    Nobody tested as a stranger

    Guardrail

    Automated tests for signed-out and wrong-user access

Each link is a condition that had to hold for the damage to happen. The line beneath it is the control that breaks that link.

How widespread it is

Three separate pieces of research point the same way. Each needs its caveats, and we give them.

A CVE for a platform's generated apps. CVE-2025-48757, published in May 2025 and rated 9.3, describes "an insufficient database Row-Level Security policy in Lovable through 2025-04-15" that let unauthenticated attackers "read or write to arbitrary database tables of generated sites." The researcher, Matt Palmer, reports finding 303 exposed endpoints across 170 of 1,645 projects analysed. The supplier disputes the CVE, on the basis that each customer accepts responsibility for protecting their own application's data, and that position is recorded in the CVE entry itself.

One app, examined closely. In February 2026, The Register reported on researcher Taimur Khan's claims about an app for creating exam questions and viewing grades. According to Khan, it had 16 vulnerabilities, six of them critical, and exposed 18,697 user records. The detail worth remembering is the authentication logic, which was inverted. As the report puts it, "The guard blocks the people it should allow and allows the people it should block." Lovable's response was that every project includes a free security scan before publishing, that acting on it is "at the discretion of the user", and that this project included code Lovable did not generate and a database it did not host.

A survey of the ecosystem. The Hamburg firm Crissy Field, working with Handelsblatt, published an analysis of 159,041 Lovable projects found through Common Crawl. Of 34,545 that used Supabase, 24,664 sent database records to any visitor on page load, without a login. In 7,403 of those, the researchers found tables containing email addresses.

Those last figures are easy to overstate, and the researchers are careful not to. Records returned without login are not necessarily sensitive; a public product catalogue would count. The email addresses may be public contact details or test data, and the 30 percent figure is not a confirmed breach rate. The sample is not representative of all apps on the platform. What the study does establish is that the direct-to-database pattern is the norm, and that in a large share of cases nothing stands between a visitor and the tables.

Why it happens, in engineering terms

Row-level security is a database feature: a rule attached to a table that decides, for each row, whether the current user may see or change it. In the direct-to-database architecture it is the only access control there is. There is no server in the middle to check anything.

Three things make it fail in generated apps.

It is invisible when it is missing. An app with no policies works perfectly for its author. Every feature loads. The demo is flawless. Access control only shows itself when someone who should be refused is refused, and nobody tests for that by using the app normally.

"A policy exists" is not "the policy is right". Palmer's criticism of the platform's scanner at the time was that it checked for the presence of a policy, not its correctness. A policy that allows everyone passes that check.

Generated authorisation logic repeats its mistakes. The inverted guard in the exam app was not one typo. A pattern, once generated wrong, gets reused.

What it cost

For Moltbook, the exposure reached beyond its own data. Because the app stored other services' credentials in messages, a hole in one table became a risk to accounts elsewhere. The cost of a missing policy scales with what you chose to store.

For the wider ecosystem the cost is harder to measure, and we will not guess at it. The Crissy Field researchers did not establish misuse.

The practice that stops it

  • Enable row-level security on every table, and deny by default. A new table should be unreadable until a policy says otherwise.
  • Test as a stranger. For every table, an automated test that signs out and tries to read, and one that signs in as user A and tries to read user B's rows. Both must fail. These are negative tests, and they are the only kind that would have caught an inverted guard.
  • Run those tests in CI, so a new table without a policy fails the build.
  • Store less. Third-party API keys do not belong in application tables in plaintext. If they must be stored, they belong encrypted, in a table the public key cannot reach.
  • Treat the builder's scan as a start. Lovable's own documentation says its checks "do not replace a thorough security review." That is a fair statement of the position, and the responsibility it describes is real.

Your app working when you log in tells you nothing about what happens when someone else does not.

How we handle this

Access control is the part of an application we least want to improvise, so we start from foundations we have already built and tested. Our SaaS starter and our authentication platform exist for this reason: client projects begin from a production baseline with sign-in, single sign-on and organisations already in place, and the first weeks go to the product.

The habit of testing what must not happen comes from the same place as the rest of our work. In the seven games post we describe how invariant tests, properties that any change must preserve, were what made it safe to accept a large amount of agent-written code. "A signed-out request returns nothing" is an invariant of exactly that kind.

And on storing less: our post on PCI scope makes the argument for card data, and it carries over unchanged. The cheapest control is the one that never applies to you, because the data was never there.

What we built

The work behind this post: the authentication platform and the SaaS starter that client projects begin from. The cards below link to both.

Proof

The work behind this post

  • Built

    Auth platform

    An enterprise authentication platform on Better Auth: SSO, SCIM, organizations, webhooks and feature flags, with client SDKs in eleven languages.

    commits in six weeks
    1,200+
    commits in six weeks
    SDK languages
    11
    SDK languages
  • Built

    LaunchApp SaaS starter

    Production SaaS starter bootstrapped by the create-launchapp CLI, used to deliver client projects in days instead of weeks.

    to a production baseline
    Days
    to a production baseline

Founder-led

Building something like this? A founder will reply personally.

Scope a project