In Depth: Pushing Back on AI Security Findings

[In Depth #44] Part 2 of our Claude security scan - working through the remaining findings to figure out what we actually need to care about, what we need to push back on, and what can be ignored.

Share
In Depth: Pushing Back on AI Security Findings

Let's pick up the thread we left from our previous In Depth, Auditing Your App with Claude’s Security Plugin, and look at the remainder of the security issues the Claude Code Security Plugin flagged when asked to review one of my side projects.

As a reminder, these are the findings from last time:

Several findings are the same bug found more than once, so they come down to about ten real issues:

- F1 (MEDIUM): the Markdown mail escaping in Laravel itself can be bypassed. withSecuredEncoding() escapes [ but not \. A wishlist name of \[text](url) renders as \\[text](url), and CommonMark then produces a real link. Anyone with an invite can send studio-branded email with a disguised link to any address. F4 is the same gap in the admin notification email. Your MailMarkdownEscapingTest only covers the payload without the backslash, which is why it passes. Every app that relies on withSecuredEncoding() is affected, so it's worth reporting upstream.
- F2, F3, F8: signed claim links. A GET on one rebinds a browser that already has a wishlist, with no confirmation, so it skips the swap guard you added to the manage route. The links also keep working after the token rotates, so replaying one lets the attacker read what the victim entered. F11 is a similar gap on the manage route, for browsers that have redeemed an invite but not submitted yet.
- F6, F7, F13: plaintext tokens in the job queue. The three queued mailables that carry a manage or claim URL don't implement ShouldBeEncrypted. Those URLs therefore sit in plaintext in jobs and failed_jobs, which undoes the hashing of tokens at rest.
- F5, F12: Pot-Off shows hidden pieces. A piece that was crowned or defending before the potter hid it keeps rendering, edits included.
- Smaller ones:
  - F9: X-Forwarded-Prefix is trusted via trustProxies('*'), which can poison recovery links outside production.
  - F10: the manage-cookie fallback binds a wishlist without regenerating the session ID.
  - F14: Fathom runs on error pages at URLs that contain tokens.
  - F15: a timing difference in recovery reveals whether an email has a wishlist.

Last time we only managed to tackle the first finding on the list:

- F1 (MEDIUM): the Markdown mail escaping in Laravel itself can be bypassed. withSecuredEncoding() escapes [ but not \. A wishlist name of \[text](url) renders as \\[text](url), and CommonMark then produces a real link. Anyone with an invite can send studio-branded email with a disguised link to any address. F4 is the same gap in the admin notification email. Your MailMarkdownEscapingTest only covers the payload without the backslash, which is why it passes. Every app that relies on withSecuredEncoding() is affected, so it's worth reporting upstream.

That one finding led us down a rabbit hole that resulted in a security fix being submitted to the framework itself! Not what I was intending in that article, but sometimes the unexpected paths are the most interesting. So now, let's tackle the rest of the findings.

💡
Before we get into it, I wanted to make it clear the point of this article isn't to teach you how to use Claude's security plugin - I want to show you how I go about engaging with AI security scans. What I do to confirm or reject their findings, and get the most out of them. You should be able to do this with any AI agent, after it has found some "security issues".

Since we've done F1, let's take on F2, F3, and F8, which are the next in the list, and see what Claude says about them:

The two flaws:
1. A GET binds the browser with no confirmation. Opening a valid claim link rotates the token, binds the session and overwrites the pottery_wishlist cookie. It never checks whether the browser already holds a different wishlist. The manage route asks "Swap wishlists?" in this case, but the claim route skips that.
2. Links survive token rotation. The signature covers only the wishlist id, the expiry and the batch. Rotating the token, which is the app's only way to revoke access, doesn't affect it. A claim link keeps working until it expires: 60 minutes for recovery emails, 30 days for batch announcements.

What each finding adds:
- F2: flaw 1 alone.
An attacker sends a friend their own claim link, say a batch announcement posted in a group chat. The friend's browser silently switches to the attacker's wishlist, and every stamp from then on goes to the attacker's list. This skews your matchmaking.
- F3: flaws 1 and 2 together. The same rebinding as F2, plus a replay. If the friend then submits the form, their name, email, address and message land on the attacker's wishlist. The attacker opens the same link again and sees it all pre-filled. This is the worst outcome of the three, because it exposes personal details.
- F8: flaw 2 alone, from a different angle. The attacker never sends a link. Instead, a real owner's link leaks: a forwarded announcement, browser history or a mail archive. Whoever has it can take the wishlist over again and again for up to 30 days, and the owner can't revoke it. Resubmitting rotates the token, but the link still works.

The shared fix:
- Swap guard (fixes F2, half of F3):
when the browser already has a different wishlist, show the confirmation page and only bind on the CSRF-protected POST. Don't rotate the token or set the cookie on the GET. The F11 fix also applies here: count a browser with unsent stamps as already holding a wishlist.
Revocable links (fixes F8, the other half of F3): add a hash of the current token, or a version counter, to the signed parameters, and reject the link once it no longer matches. Each link then works once and dies when the token rotates.
Optional (from F8): shorten the lifetime of announcement claim links, and mark the link in the announcement email as personal, as the confirmation email already does.

Flaw #1: Wishlist Override

Let's look at flaw #1 first. When I was looking at the description that Claude gave me, I was a bit confused. It doesn't really spell out what's happening here.

Is the existing wishlist being lost completely? Is it still there? The user just being pointed at a different wishlist? Is it hijacking the existing one so the attacker can access the old items?

These are all valid questions. You can't just read the agent report blind and go: "Oh, yeah, this is a problem!" and then blindly ask Claude to fix it. You need to understand what flaws have been identified. So, push back against the agent:

Me: So, does flaw #1 mean an existing older wishlist can be completely lost and the user will need to start from scratch with a new one?

Claude: No. The old wishlist isn't lost. Only the browser's connection to it is replaced.

Claude went on to provide a detailed list of what is actually happening here, and there's a few different factors in place. Basically, the wishlist isn't lost, it can be recovered, but the victim now gets the attacker's wishlist, which the attacker can then retrieve information about the victim from (if the victim provides it).

In short: this is an exfiltration and/or theft risk.