Build1 publisher3 min readPublished
Six of seven AI-code vulnerability patterns are visible in a single expression
A dev.to post lists seven defect patterns in AI-generated code, and the one its author calls most distinctly AI-flavored is a dropped auth middleware that only shows up when you compare a route to its siblings.
The Engineer · Build desk

What happened
- A dev.to post publishes a versioned taxonomy, the AI Vulnerability Pattern Catalog, listing seven defect classes its author says appear disproportionately in AI-generated code.
- The author also released ai-vuln-scan, a static analysis tool tuned to those seven patterns rather than to bugs in general.
- The stated cause is that an assistant optimizes for a plausible runnable example, so, as the post puts it, it generates the version that works, not necessarily the version that is safe.
- Pattern six covers inconsistent authorization across near-identical routes, where an assistant asked for another route like the others regenerates the block and the auth middleware quietly drops out.
- The post reports no scanned corpus size, no defect counts and no false-positive rate for the scanner.
Compiled by The EngineerSomething wrong?How this is made
Why it matters
- decision A team that already scans for committed secrets and interpolated SQL has to decide whether one route-consistency rule justifies a second scanner in CI, or whether that rule should be written into the checker it already runs.
- exposure Codebases that enforce authorization outside the route handler keep the defect the catalog considers most AI-specific, because the sibling routes the scanner compares look the same either way.
- constraint A gate tuned to seven named patterns catches defects someone has already named, so a new failure mode arriving with a new model default gets no rule until a contributor notices it and versions the catalog.
Sort the seven by what a checker has to see. Hardcoded placeholder secrets [7], `SELECT * FROM users WHERE id = ${userId}` [8], `exec("cmd " + arg)` [9], wildcard CORS and disabled TLS verification [10], MD5 and `Math.random()` in a security context [11], and `err.stack` in a response body [15] are all wrong on the line they occupy. Six of the seven need no context beyond that line [19]. Number six needs the rest of the file [19].
The mechanism there is specific. Ask an assistant to add another route like the others and it regenerates the pattern from the description instead of copying the existing block, and the auth middleware is what falls out, especially across separate prompts or edits [12]. "A human copy-pasting an existing route is more likely to preserve the whole block by construction; an AI regenerating it from a description is not," the post says [13]. Its author calls that "the most distinctly AI-flavored bug on the list" [14].
The worked example is an Express handler that reads `req.params.id` and returns `res.json({ userId })`, and the defect is that it sits in a file where every other route includes an `authMiddleware` call and this one does not [16]. The sample route does not query anything, so the missing middleware is the only thing wrong with it [16]. That is a comparison, not a pattern match: the signal is the difference between this route and its neighbours [16].
Which is also the limit. The comparison only carries information where authorization is written per route in the file, as in the example [16]. Put the check on a codebase where auth is enforced in a gateway config, a decorator, or a policy engine, and the sibling routes look identical to the scanner.
The post says its author wanted to find out whether the pattern was real or just a feeling, and built `ai-vuln-scan` to look [18][2]. Settling that needs the same rules run over human-written code in the same stack and language, plus the count of flags you have to dismiss on your own tree. Seven observed classes with a stated cause is a hypothesis worth writing rules against [1].
The stated cause is worth taking seriously on its own, because it predicts the defects. A runnable sample does not need a real secrets manager, parameterized queries to demonstrate the concept, or the hardened production config [5]. Pattern four is the cleanest case: wildcard CORS and disabled certificate verification remove setup friction the assistant has no way to resolve, since it does not know your real allowed origins and does not have your real cert [10]. Parameterization has the same shape as a problem. It is correct, and it is an extra step that is less narratively obvious than interpolating the variable [8].
The post puts its remedy in the gate. Better prompting helps but does not close the gap, it argues, and the fix is "catching the gap systematically, the same way we catch any other predictable class of bug" [17].
What to watch
- Whether the catalog gains measured results: a scanned corpus size, defect counts and a false-positive rate would turn seven observations into a base rate.
- Whether the route-consistency check is extended to authorization expressed in decorators, gateways or policy engines, where sibling comparison currently has no signal.
- Whether outside contributors add or revise entries in the versioned catalog, which is the extension path the post says it was published for.