The security benchmark for AI-generated code.
How leading AI models perform across 11 languages frameworks, and how much curated security rules reduce measured risk score


AI code vs human code
Every model tested wrote more vulnerabilities per 1,000 lines than human-only commits.
See AI vs human code
Security rules cut the risk
21-45% fewer vulnerabilities with security rules in context.
See the bell curve
Cost doesn’t buy security
Some of the cheapest models had the lowest risk.
See the cost chart
Framework changes the result
Across [N] frameworks, the same model can rank very differently.
Explore frameworks
[Framework] carries the most risk
Highest mean measured risk of the [N] frameworks: [risk].
See risk by framework
Cost varies by framework
Cheaper frameworks often aren’t safer.
See cost by framework
Which AI model writes the most secure code?
Every model runs in the same agent harness, with the same spec and prompt, across 11 frameworks and 10 runs each. The ranking is the baseline score: the model on its own, averaged across all frameworks. Lower measured risk is safer. Switch to + best rules to see how much each model improves from its own baseline.
How security rules shift the whole field
Distribution of measured risk across all models and frameworks: the baseline, and the same models with their best performing security rule per framework. The further left a curve sits, the safer the code that setting produces across the board.
Leaderboard
SCW AI Trust Index scores run from 0 to 100. A score of 100 means fewest vulnerabilities of all models tested in that context; 0 means most. Scores are normalized relative to all models in the current dataset and are not an absolute measure of security. Rankings reflect the full 32-model dataset. As new models are released and evaluated, we recalculate the scores for all models, so results here are always current. Click a model name to explore.
Measured average risk score over time
Baseline measured average risk score of every model by release date. Lines join versions of the same model. Click a model to explore it.
AI-generated code vs human-written code
Confirmed vulnerabilities per 1,000 lines of code under the selected guidance setting, against two figures from Stanford research: human-only commits (0.08) and unreviewed AI-assisted code (0.76).
Trust Index vs cost per run
Each circle is a model under the selected guidance setting. Higher is better security. Its size is the model’s functional correctness (share of runs that passed the functional checks).
OWASP vulnerability fingerprints
Where each model’s confirmed vulnerabilities concentrate across OWASP categories, compared with the average model. Baseline runs.
Explore by framework
Pick a framework to see how every model performs in it.
Risk score and vulnerabilities, all frameworks
Mean measured risk, total vulnerability count and unique CWE types across all models, under the selected guidance setting.
Average cost by framework
Average API cost per run across all models, under the selected guidance setting. With + Best rules, each framework uses the cost of the rule set that gave it the lowest risk. Cheapest first.
Vulnerability analysis
Unique CWEs identified across every generated codebase.
OWASP Top 10 distribution
True positives are confirmed vulnerabilities in the framework’s primary language. Average risk combines severity, spread and detection.
Top 10 CWEs by volume
What security guidance changes

OS command injection (CWE-78)
Fell 50–79% with security rules in context.

Sensitive data in log files (CWE-532)
Only fell 10–30% with security rules in context.

Unchecked exceptions (CWE-703)
Rose 3–25% with security rules in context.
How the AI Trust Index is measured
Every model gets the same app spec, the same agent harness (Pi), the same scanners and the same scoring.
How we test
Generate
Each model builds the ExpenseForge spec 10 times in each of 11 frameworks, inside Pi, a non-opinionated agent harness with file-system tools. One shared system prompt. No planning or supervising agents. The generated code is then checked against the functional spec. If it meets less than 90% of it, the model gets up to 5 more attempts to reach 90%.
Scan
Each codebase is scanned with Semgrep, Bearer and Bandit (Python). Only findings in the framework’s primary language are scored.
Verify
An AI verifier agent classifies each finding as a true or false positive in code context. Only confirmed findings are scored.
Score
Confirmed findings become a CWE-level risk score per framework. The baseline run gives the ranking; each security-rules run is compared with the same model’s baseline.
Baseline and security rules
The baseline is each model running in the agent harness with no security guidance at all. It is the main comparison on this page and the only run every model gets, so it is what the ranking is built on.
A subset of models is also run with secure-coding rules placed in the agent’s context. Each of those runs is compared with the same model’s baseline, so the figure you see is that model’s own improvement, not a comparison between models. Where a model was run with more than one set of rules, the index shows its best result, labelled + best rules. We ran enough models this way to measure how much security rules help on average; we no longer run every new model with rules.
Where a model has only a baseline run, the rules views say so rather than guessing.
How scores are built
Risk score
Each CWE a model introduces in a framework gets a risk score: R = V × I × L × Vol × C × 100.
Validation (V)
1 if at least one finding is confirmed as a true positive, otherwise 0.
Impact (I)
Potential impact if exploited, from the finding’s severity: Critical 1.0, High 0.8, Medium 0.6, Low 0.4.
Likelihood (L)
Share of runs with a confirmed finding.
Volume (Vol)
How far it spreads in the codebase: log10(files with a confirmed finding + 1), in the runs where it occurs.
Confidence (C)
Scanner agreement: 1 scanner 0.7, 2 scanners 0.85, 3 or more 1.0.
A model’s risk score in a framework is the sum across every CWE it introduced. It has no upper limit; lower is safer. Only confirmed findings in the framework’s primary language count.
Trust Index
A Trust Index (0–100) is computed via min-max normalization for each model within each framework, so higher is safer:
The Overall Trust Index (0–100) for a model is computed by averaging the normalized Trust Indexes across all frameworks. These normalized scores will change as new models get added to the evaluation set, as they reflect the relative position of each model within the set.
There are two versions. The baseline Trust Index uses each model’s baseline risk scores. The best rules Trust Index uses the same calculation with the risk score of each model’s best performing security rule in each framework, scaled between the best and worst best rule scores, so it isn’t directly comparable to the baseline version. The leaderboard shows whichever matches the Baseline / + Best rules switch.
Functional correctness
The share of generated apps that pass the functional checks for the spec. It sits beside the risk score so a model that writes safe code by writing less of it doesn’t win by default.
Vulnerability density
Confirmed vulnerabilities per 1,000 lines of generated code, from the baseline run. It lets AI-generated code be compared with published figures for human-written code: research from Stanford University found that human-only commits introduced roughly 0.08 vulnerabilities per 1,000 lines (Baumann et al., “SWE-chat,” arXiv preprint, April 2026). Methodologies differ, and the figures aren’t directly comparable.
What changed from the July 2026 study
The July 2026 study measured models called directly through their APIs. Those results are not comparable with the current index and are no longer shown.
Scope and providers
API providers
Models are accessed through their own providers, Amazon Bedrock or OpenRouter.
Temporal scope
Ongoing. New models are added to the dataset as their runs complete, and every score carries its test date.
Retired models
Models their provider has sunset, deprecated or retired are labelled as such and stay in the index as a point in time. They are not re-run.
Limitations
- One app spec (ExpenseForge): CRUD with auth, file upload and payments.
- Three open-source scanners. Commercial SAST may find more. Dependencies aren’t scanned.
- One harness (Pi). Vendor harnesses may produce different results.
- Code quality beyond security (maintainability, scalability, performance, modularity) isn’t evaluated.
- Security-rules runs cover a subset of models.
- Results are observed, not statistically tested.
- Models change. Every score is a point in time.
- Scanner coverage varies by language: Python also gets Bandit, the others don’t.
Changelog
Jul 2026
July 2026 study published: 16 models, 1,760 codebases
17 Nov 2026
Current index launched on the agent-harness method, 32 models
The paper
“Measuring the Security Cost of AI-Generated Code: A Multi-Model, Multi-Framework Empirical Study”, Secure Code Warrior and RMIT University. Covers the July 2026 study.
Switch model
O
GPT 6 Astra code security score
Trust Index
97
Higher is safer
Functional correctness
91%
Vulnerabilities per 1,000 lines
0.24
Cost per run
$8.43
#1 of 14
Ranks first of 14 models on its baseline run, across 11 frameworks.
As of Oct 2026.
Risk score and vulnerabilities by framework
Measured risk, total vulnerability count and unique CWE types for this model in each framework, lowest first.
What security rules change, by framework
Each framework’s measured risk with the best rule set, compared with this model’s own baseline. Left of centre means the rules cut the risk.
Measured risk vs cost per run, by framework
Each circle is a framework under the selected guidance setting; its size is this model’s functional correctness there. Bottom-left is best value: low risk, low cost.
OWASP vulnerability fingerprints by framework
Where this model’s confirmed vulnerabilities concentrate in each framework, compared with every model tested in the same framework.
Weaknesses it leaves most often
The CWEs with the most confirmed findings for this model across all frameworks.
Explore other models
Switch framework
Java
Java - Spring
Trust Index
97
Higher is safer
Unique CWE types
–
Average functional correctness
–
Average cost per run
–
#1 of 11
Ranks first of 11 frameworks on mean baseline risk, across 32 models.
As of Oct 2026.
Measured risk by model
Measured risk per model for this framework under the selected guidance setting. Lower is safer. Click a model to explore it.
Measured risk vs cost per run, by model
Each circle is a model in this framework under the selected guidance setting; its size is the model’s functional correctness here. Bottom-left is best value: low risk, low cost.
OWASP vulnerability fingerprints in this framework
Where each model’s confirmed vulnerabilities concentrate in this framework, compared with every model tested in it. Baseline runs.
Explore other frameworks
Provider
#
Model
Baseline risk
With best rules
vs baseline
Functional correctness
1
O
GPT 6 Astra
13.9
3.1
−78%
91%
Showing 10 of 32 models
C
C - Basic
Baseline risk
12.8
With best rules
5.8 · −55%
Explore framework →
#
CWE ID
Category
True positives
1
CWE-79
Cross-site scripting
1,771
#
Model
Baseline risk
2
O
GPT 6 Luna
OpenAI
19.1
O
#1
GPT 6 Astra
5.4
Baseline 21.2
Functional correctness 98%
From benchmark to better code
The AI Trust Index shows how AI models perform on security, and where each one falls short. The next step is acting on it. Steer your AI coding agents with guidance drawn from that research, so they write secure code the first time.
