{"slug": "a-year-ago-we-fixed-ai-s-bugs-now-ai-finds-ours", "title": "A year ago, we fixed AI's bugs. Now AI finds ours", "summary": "An AI-assisted security audit at Geocodio uncovered a high-severity two-factor authentication bypass in the company's PHP application, caused by a loose type comparison in which the JSON boolean true equals the integer 4821. Geocodio said the vulnerability has been fixed and that it has no evidence it was ever exploited. The audit used parallel subagents to trace execution paths, a critic agent to challenge each finding, and reproducible tests to confirm results before reporting.", "body_md": "# Code and Coordinates\n\nengineering at Geocodio\n\n# A year ago, we fixed AI's bugs. Now AI finds ours.\n\nTake a look at this simplified piece of PHP:\n\n``` php\n$expectedCode = 4821;\n\nif ($request->input('code') == $expectedCode) {\n    // Second factor verified.\n}\n```\n\nSee the vulnerability?\n\nHere's a hint:\n\n```\ntrue == 4821; // true\n```\n\nDuring 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.\n\nThe vulnerability has been fixed, and we have no evidence that it was ever exploited.\n\n## [Obvious in hindsight](#obvious-in-hindsight)\n\nOnce 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.\n\nPut 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.\n\nThe fix itself is straightforward:\n\n``` php\n$code = $request->input('code');\n\nif (\n    is_string($code)\n    && hash_equals((string) $expectedCode, $code)\n) {\n    // Second factor verified.\n}\n```\n\nWe 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.\n\nThe difficult part was never fixing the vulnerability. It was finding it.\n\n## [Type safety is a security feature](#type-safety-is-a-security-feature)\n\nThis 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:\n\n```\n#[derive(Deserialize)]\nstruct VerificationRequest {\n    code: String,\n}\n```\n\nA 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.\n\nNeither 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.\n\nAs 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.\n\n## [The tables are turning](#the-tables-are-turning)\n\nA 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.\n\nToday, 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:\n\n- A large number of subagents scanned the application in parallel, tracing execution paths through the code.\n- Their findings were collected and handed to a critic agent, whose job is to challenge each one.\n- A finding only counted once it was verified and proven with reproducible tests.\n\nAI's value in software engineering now includes how well it can scrutinize code, including the code we wrote ourselves.\n\n## [What if AI makes software safer?](#what-if-ai-makes-software-safer)\n\nThere'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?\n\nCombine 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.\n\nAI still makes mistakes, and so do we. What changes is how few of those mistakes survive.\n\n### Get new posts in your inbox\n\nWe 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.", "url": "https://wpnews.pro/news/a-year-ago-we-fixed-ai-s-bugs-now-ai-finds-ours", "canonical_source": "https://www.geocod.io/code-and-coordinates/2026-12-04-a-year-ago-we-fixed-ais-bugs-now-ai-finds-ours", "published_at": "2026-12-04 15:01:23+00:00", "updated_at": "2026-12-04 15:17:38.074625+00:00", "lang": "en", "topics": ["artificial-intelligence", "ai-agents", "ai-safety"], "entities": ["Geocodio", "Laravel Go", "Laravel Rust", "PHP", "Rust", "Go"], "also_reported_by": [], "takeaway": "Loose PHP comparison let a JSON boolean true pass a 2FA check against the integer code 4821; validating is_string() and using hash_equals() closes the bypass.", "recommendation": {"advice": "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.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/a-year-ago-we-fixed-ai-s-bugs-now-ai-finds-ours", "markdown": "https://wpnews.pro/news/a-year-ago-we-fixed-ai-s-bugs-now-ai-finds-ours.md", "text": "https://wpnews.pro/news/a-year-ago-we-fixed-ai-s-bugs-now-ai-finds-ours.txt", "jsonld": "https://wpnews.pro/news/a-year-ago-we-fixed-ai-s-bugs-now-ai-finds-ours.jsonld"}}