ai

Fable 5.2 reads code like an attacker

Fable 5.2 reads code like an attacker

This morning I opened a new worktree of our platform in Claude Code, picked Fable 5.2, and typed one line: "find performance and security bugs into my application". Typo included. I didn't point it at a folder or give it a list of things to look for.

Opus 5.5 is still the model I have open all day. I went with Fable here because auditing an entire API is the kind of task where I want the most careful reader I can get, and also because I wanted to see what it does with a prompt that vague.

Six audits and one rule

Two minutes after the prompt it had split the work into six read-only audits running in parallel. Four were security: ownership checks on the member side, the unauthenticated surface and webhooks, authentication and sessions, and staff-side authorization together with injection and SSRF. The other two were performance, one for the request paths and one for background jobs, the schema and frontend fetching. It told me nothing would be changed and no tests, servers or migrations would run.

Before any result came back it also set itself a rule. It would check each finding against the code before passing it on, because a claim from an audit agent is not proof. And it kept to that. As each audit landed it re-read the paths, told me which findings held up when it read the code itself, and listed the ones it hadn't traced yet.

Nineteen minutes after my prompt the consolidated report was in, with eighteen security findings and fifteen performance ones. Every finding it had not re-read itself was marked as coming from an audit agent alone. Nothing was executed, so no exploit was attempted and no query plan was measured, and it said so at the top. At the bottom was a list of what it hadn't covered: signup, the individual platform operations, the CMS routes, most payment webhook handlers, the mobile apps, and dependency vulnerabilities (no one had run npm audit).

A chain across five files

The finding at the top of the list is the one that convinced me. It has five pieces, and not one of them is a bug if you read it alone:

  • The CSRF middleware is commented out, with a note that it is temporarily disabled while debugging.
  • CORS allows credentialed requests from an allowlist that includes every tenant's portal subdomain, every tenant website, and every verified custom domain.
  • Which product's session cookie the API reads is decided by a request header the caller sets, and the header is consulted before the Origin.
  • The refresh endpoint accepts just the cookie and returns a fresh access token and refresh token in the response body.
  • A tenant admin can attach their own tag manager container to their portal and website, and a tag manager tag can run arbitrary script.

Together they mean that the owner of any organization, including one created five minutes earlier, can get script onto a page our API trusts. When a staff member of another organization opens that page, the script asks the API for a new admin session and reads the tokens out of the response. If the visitor is one of our super admins, the session covers the entire platform.

Without being asked, it connected a second finding to this one. The account email can be changed with only a session, no current password needed and no message sent to the old address. So a stolen session, one that could still be revoked, becomes a permanent account takeover through a password reset at the new address.

It also said what it couldn't see from the repository, namely whether the portal and website pages send a content security policy that would block the tag manager route. The custom domain route doesn't depend on that, and it pointed that out too.

The check that could never fire

Two other findings needed an understanding of how the code runs, as opposed to what it looks like.

The route that deletes an uploaded image has an ownership check. It looks up the media record by the image's public id and refuses the request if the record belongs to another organization. If you just read the route, it's protected. But our ORM has an extension that adds the caller's organization to every query on a tenant model, and the lookup goes through it. So another organization's record is never found, the variable is null, and the handler falls through to the delete. The refusal branch can only run for a super admin, whose queries skip the scope. The comment next to it calls the public id non-enumerable, and Fable noted that the id is part of every public image URL, so any staff login can delete any tenant's logo.

The second one is an ordering problem in a member payment route. It finds or creates the caller's contact in the invoice's organization, which also creates an active membership, and only then checks whether the invoice belongs to the caller. The caller gets a 403, but the membership is already committed. Invoice ids are sequential, so walking them joins every organization that has ever sent an invoice, private clubs included.

I'd expect a pattern-matching scanner to see an ownership check in the first route and a 403 in the second, and move on.

Our own code as the reference

Several findings cited a neighbour that already did it right. One login code route has a per-address limiter, and the routes next to it that also verify emailed six-digit codes don't, so rotating IPs gives unlimited guesses against one address. One public route documents the cross-organization trap in a comment and binds member visibility to the session's organization, and the public content, classes and areas routes do not. That made each of these quick to accept, and the fix is mostly copying a pattern we already wrote.

It caught comments that disagreed with the code the same way. On the performance side, a renewal job has a comment saying its 63-day cap "keeps the query cheap". For weekly and monthly billing that cap covers every auto-renewing membership on the platform, so every hour the job takes a lock and runs two queries per membership before skipping all but the few inside the three-day window that counts.

The performance half

The performance findings were good too, just more ordinary then the security ones. A public availability endpoint loads a court's entire booking history, with full user and contact rows, and filters it by date in JavaScript, and the kiosk calendar calls it once per court. The admin payments page asks for 10,000 rows and the server passes the limit through. The transactions, payments and classes tables have no index for the per-organization, date-ordered lists they serve. The event and email queues drain a fixed batch per tick with no loop to clear a backlog.

The block at the end

The report ended in one block I could paste into a fresh session. It had every finding with its files, the scenario, the impact and a suggested correction, with the unverified ones labelled, and then a list of regression tests to write. A token from one organization gets only public rows from another. A refresh from a tenant origin with the admin product header is refused. A failed-code lockout survives a resend. The URL fetch guard refuses 127.0.0.1, 10.0.0.0/8 and 169.254.0.0/16, and redirects into them.

Deyan Peev

Founding Engineer in Sofia, Bulgaria. Currently at 1club.

© 2026 Deyan Peev