# LLM-written tests find 33 new flaws in Keycloak and other login brokers

A University of Toronto tool pairs GPT-5.2 with fixed, rule-based checks to probe seven open-source identity brokers. Maintainers have confirmed 29 of the flaws so far, and 19 have received CVE numbers.

- Category: Safety & evaluation
- Readiness level: III (Open source) on Science Underway's four-step scale, as proposed
- Published: 2026-11-28
- Editor: Stefan Perdal
- URL: https://scienceunderway.com/articles/llm-written-tests-find-33-new-flaws-in-keycloak-and-other-login-brokers

## The study

PORTA: Systematic Discovery of Vulnerabilities in Identity Brokers (preprint, not peer reviewed). DOI 10.1145/3830454.3846557, arXiv 2611.33015. https://arxiv.org/abs/2611.33015

## At a glance

- What it shows: Many companies use an identity broker: software that takes a login from one provider and turns it into access to other apps. A tool that uses an AI model to write attack tests found 33 previously unknown security flaws across seven popular open-source brokers, including Keycloak, Vault and Dex.
- What it does not show: It does not show how safe any real company's setup is, because every test used default settings in a sealed test environment. It also does not claim its five security rules cover every way a broker can fail.
- Why it matters: One broker often guards dozens of apps, so a single flaw can open all of them at once. The work suggests cheap, AI-assisted testing can find serious login bugs, provided the AI is not left to judge its own results.

## What the study shows

An identity broker sits between a company's login provider and the apps behind it. It checks the incoming proof of login, reads who the user is and what they may do, then issues a fresh pass for the downstream app. Keycloak, Vault, Dex and Authentik are common examples. The authors argue that brokers are risky because they play two roles at once: they receive logins like an ordinary app, and they hand out logins like a provider. The login standards were written for software that plays only one of those roles.

The researchers first wrote down five rules a broker must always keep. For example, it must only trust what it actually checked, must reject expired or reused proofs, and must never let two different people end up as the same account. They drew these from 40 'must' clauses in eight login standards, including SAML, OpenID Connect, OAuth and JWT. They then checked them against 60 past security flaws (CVEs, the public catalogue of known vulnerabilities) in 10 broker products. Every one of the 60 broke at least one rule.

Their tool, PORTA, uses a large language model (GPT-5.2) in two places. It reads each broker's API documentation and maps it to a common set of operations. It then writes pairs of tests: a normal login, and an attack aimed at one of the five rules, along with a precise true-or-false check for each test. The tests run against a live broker in an isolated container. Fixed code, not the language model, decides whether a rule was broken.

On known flaws, the tool re-found 10 of 11 selected past CVEs across three runs. On current versions of seven brokers, three runs of under three hours each cost about $70 in API fees. They produced 252 candidate problems after automatic merging. Manual review confirmed 226, a precision of about 88%, and traced them to 33 distinct, previously unreported flaws.

The authors report that maintainers have confirmed 29 of the 33, patched 14 and assigned 19 CVE numbers. At least 10 are rated critical. Examples include Zitadel accepting tokens meant for a different service, Casdoor letting users skip multi-factor login by signing in through a partner provider, and Logto linking accounts on an unverified email address. That last flaw allows an attacker to take over an existing account.

The design choices matter, according to tests that switched parts off. With only a generic 'find security bugs' prompt, the tool found no real flaws. When the language model itself judged the results instead of the fixed checks, precision fell from about 88% to about 8%. Most of its false alarms described attacks that did not exist. The paper appears in the proceedings of ACM CCS 2026 and is also posted on arXiv. Its code and saved tests are public.

## Our reading

In our reading, the most useful lesson here is not about identity brokers alone. It is about where to put a language model in a testing pipeline. The model is good at the tedious part: reading unfamiliar API documentation and drafting many plausible attack sequences. It is poor at deciding whether an attack worked. When asked to judge, it invented findings. Handing the verdict to plain, pre-written checks is what made the output trustworthy enough to send to maintainers.

The second lesson is about standards. Of the 33 flaws, 18 were unsafe behaviour that no standard clearly forbids. A typical case: a broker skips a check whenever an optional field is missing, so an attacker simply deletes the field. That habit is harmless for an app that trusts a single, known provider. It becomes dangerous in a broker that may accept logins from providers an attacker controls. The authors found the same patterns in brokers written in four languages by separate teams, which points to a gap in the specifications rather than one careless developer.

For a concrete picture: a company runs one broker in front of its payroll, HR and finance tools. If that broker accepts a token minted for the HR tool as valid for finance, every app is exposed, and none of them can tell. That is the kind of failure this tool was built to catch.

The rest of the article (what it means, limits, what to watch) is free for members: https://scienceunderway.com/articles/llm-written-tests-find-33-new-flaws-in-keycloak-and-other-login-brokers

## How this was made

An AI model read the study and wrote this article in the structure Science Underway uses. An editor reviewed it and approved it for publication. Check the original study before you rely on the details.

---
Source: Science Underway, https://scienceunderway.com/. Please link to the article when you cite it.
