November 29, 2026
The scariest authorization bug AI writes is not missing code. It is a check that compiles, passes review, and reads like every other permission check in the file, while quietly enforcing a security model your application does not use.
The Details:
Ask for an admin edit check and you often get if user.role == "admin", a pattern lifted from flat-role training data. If your system is actually tenant-scoped, that check lets an admin in Tenant A touch Tenant B's records, and nothing about the code signals the mismatch because the logic is internally sound.
The same gap shows up outside authorization. A rate limiter built per-IP instead of per-account throttles a shared office network while an attacker rotating addresses walks through; a validator checked against a form field instead of a database column breaks only months later when an import job hits it. In each case the model matches what is visible in the file, not the constraint that actually governs the system.
Code review rarely catches this because reviewers ask whether the logic is coherent, not whether it matches the rest of the codebase. The real tell is inconsistency: one handler doing an inline role comparison while every neighboring handler calls a shared policy helper. A plain grep for role == or is_admin across a mature repo surfaces more of these seams than any specialized scanner.
Test suites compound the blind spot by proving the right user gets in and never checking that every wrong combination, wrong tenant, wrong role, wrong user, gets refused. Denial testing with two tenants and two resources catches exactly the regressions single-tenant unit tests miss.
The fix is not more process, it is an anchor: a canonical policy helper, a one-line note in project instructions naming where checks live, or a PR template question answerable yes or no. Without that anchor the tool writes code that fits the file in front of it and nothing more.
Bottom Line: Security holds only when the real authorization model is written down where the code gets written, not carried silently in one engineer's head.
Enjoy this article?
Listen to the Claude Code Conversations radio show or join the community.