# A year ago, we fixed AI's bugs. Now AI finds ours

> Source: <https://www.geocod.io/code-and-coordinates/2026-12-04-a-year-ago-we-fixed-ais-bugs-now-ai-finds-ours>
> Published: 2026-12-04 15:01:23+00:00

**Recommendation:** Run staged AI security audits with parallel scanning subagents, a critic agent to challenge findings, and reproducible tests before trusting any result; enforce strict input typing to rule out loose-comparison bypasses.
More in the playbook "Securing agents and AI tools": <https://wpnews.pro/playbooks/agent-security>

# Code and Coordinates

engineering at Geocodio

# A year ago, we fixed AI's bugs. Now AI finds ours.

Take a look at this simplified piece of PHP:

``` php
$expectedCode = 4821;

if ($request->input('code') == $expectedCode) {
    // Second factor verified.
}
```

See the vulnerability?

Here's a hint:

```
true == 4821; // true
```

During a recent AI-assisted security audit at Geocodio, we found a high-severity vulnerability in our two-factor authentication caused by exactly this kind of loose type comparison. If the code arrived as the JSON boolean `true` instead of a string, the SMS second factor could be bypassed entirely.

The vulnerability has been fixed, and we have no evidence that it was ever exploited.

## [Obvious in hindsight](#obvious-in-hindsight)

Once you see it, it's almost embarrassingly obvious. It would make a good interview question about type safety, and shown these few lines in an interview, we would have spotted the problem in seconds.

Put the same lines inside a large, mature application, surrounded by thousands of lines of perfectly reasonable code, middleware, and abstractions, and it becomes a different challenge.

The fix itself is straightforward:

``` php
$code = $request->input('code');

if (
    is_string($code)
    && hash_equals((string) $expectedCode, $code)
) {
    // Second factor verified.
}
```

We validate the input type and drop the loose comparison, which closes the hole. We also use `hash_equals()` rather than a regular string comparison, so the check takes the same time whether the first digit is right or not. For a short SMS code, rate limiting does most of that work, but constant-time comparison is a good habit and costs nothing.

The difficult part was never fixing the vulnerability. It was finding it.

## [Type safety is a security feature](#type-safety-is-a-security-feature)

This discovery came shortly after the introduction of [Laravel Go](https://laravel.com/go) and [Laravel Rust](https://laravel.com/rust). Consider a typed request in Rust:

```
#[derive(Deserialize)]
struct VerificationRequest {
    code: String,
}
```

A JSON boolean isn't a string, so deserialization rejects it before it ever reaches the verification logic. With properly typed request structures in Go or Rust, this class of vulnerability is eliminated by design.

Neither language makes an application secure on its own. But every category of mistakes the language rules out is one less category we need to find in code review.

As more of our code is written with AI assistance, I think the strongest argument for type safety is correctness, ahead of performance and developer experience.

## [The tables are turning](#the-tables-are-turning)

A year ago, much of the conversation around AI-assisted software engineering was about humans reviewing AI-generated code, fixing its bugs, and catching its security vulnerabilities.

Today, I increasingly find myself on the other side of that equation. This finding didn't come from a single prompt. The audit ran in stages:

- A large number of subagents scanned the application in parallel, tracing execution paths through the code.
- Their findings were collected and handed to a critic agent, whose job is to challenge each one.
- A finding only counted once it was verified and proven with reproducible tests.

AI's value in software engineering now includes how well it can scrutinize code, including the code we wrote ourselves.

## [What if AI makes software safer?](#what-if-ai-makes-software-safer)

There's an ongoing debate about whether AI-generated code is reducing software quality. I think we're missing half of the equation. We're measuring the mistakes AI introduces, but are we also measuring the mistakes it discovers?

Combine stronger type systems, compiler-enforced guarantees, specialized AI security audits, automated regression testing, and experienced engineers, and we might end up with software that is developed faster and is also more thoroughly reviewed, better tested, and more secure than it was a year ago.

AI still makes mistakes, and so do we. What changes is how few of those mistakes survive.

### Get new posts in your inbox

We write about what we're working on, thinking about, and getting so excited playing around with that we accidentally stay up a bit too late.
