Evals for how well LLMs can judge security issues in code
Repo glideapps/security-bench, read from GitHub 14 h ago. glideapps has not joined Take My Repo.
glideapps/security-bench is a public repo on GitHub by glideapps. Evals for how well LLMs can judge security issues in code. It declares no license on GitHub. Public does not mean open source: without a license, nobody is granted the right to reuse it. It is written mainly in TypeScript, has 2 stars and last changed on 2025-09-26. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-23.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
A comprehensive evaluation framework for testing Large Language Models' ability to identify security vulnerabilities in code, with a focus on SQL injection, access control, and multi-tenant data isolation issues.
This benchmark suite evaluates how well LLMs can detect security vulnerabilities in database queries and other code fragments. It tests various security patterns including:
npm install
.env:OPENROUTER_API_KEY=your-api-key-here
The system supports multiple evaluation prompts to test different prompting strategies. Prompts are stored in the eval-prompts/ directory:
default.txt - Standard evaluation prompt covering common vulnerabilitieschain-of-thought.txt - Step-by-step analysis prompt with 10 structured stepsconcise.txt - Minimal prompt for quick evaluation (1-2 sentence explanations)rule-by-rule.txt - Analyzes code against each individual security rule from the specificationsecurity-checklist.txt - Uses a checklist approach marking each control as PASS/FAIL/N.A.attacker-mindset.txt - Evaluates code from an attacker's perspective looking for exploitsWhen you run evaluations, the system automatically iterates through ALL prompts in the eval-prompts/ directory. Each model × prompt combination is evaluated and tracked separately.
To add your own evaluation prompts:
.txt file in the eval-prompts/ directoryexplanation and assessment fields (in that order)Example custom prompt (eval-prompts/security-focused.txt):
Focus specifically on authentication and authorization vulnerabilities.
Check if the query properly validates user identity and permissions.
Look for any way an attacker could bypass access controls.
Respond with a JSON object:
- "explanation": describe any authorization issues found
- "assessment": "good" if secure, "bad" if vulnerable
Here is the code to evaluate:
Run the full benchmark suite against a specific model (uses all prompts automatically):
npm run evaluate -- --model gpt-4o-mini
# Force re-evaluation even if results already exist
npm run evaluate -- --model gpt-4o-mini --force
Run evaluations with multiple models:
# Evaluate with multiple models sequentially
npm run evaluate -- --model gpt-4o --model claude-3-opus --model gemini-pro
# Multiple models with filter
npm run evaluate -- --model gpt-4o-mini --model claude-3-haiku --filter approve-po
Run a filtered subset of tests:
# Only run tests matching a pattern
npm run evaluate -- --model claude-3-opus --filter approve-po
# Only run "good" test cases
npm run evaluate -- --model gpt-4o-mini --filter 01-good
Note: When using multiple models, each model is evaluated sequentially with clear separation in the output. All results are stored independently in the database for each model.
Generate an HTML report from evaluation results:
npm run report
Reports are saved in the reports/ directory with timestamps. Each report includes:
The fix command can automatically rewrite test code when a model's assessment differs from the expected result:
# Fix using default model (anthropic/claude-opus-4.1) and default prompt
npm run fix approve-po-01-good.md
# Fix using a specific model
npm run fix approve-po-01-good.md -- --model gpt-4o
# Fix using a specific prompt
npm run fix approve-po-01-good.md -- --prompt chain-of-thought.txt
# Fix using both specific model and prompt
npm run fix approve-po-01-good.md -- --model gpt-4o --prompt concise.txt
# Fix using full or relative path
npm run fix tests/purchase-order/approve-po-01-good.md
How it works:
The fix command will:
The verify command runs all test queries against an actual database to ensure that:
npm run verify
This command:
The autofix command finds and fixes multiple test files based on their correctness percentage:
# Fix all files with ≤50% correctness using default model and prompt
npm run autofix -- 50
# Fix all files with 0% correctness (completely failing)
npm run autofix -- 0
# Use a specific model for autofix
npm run autofix -- 30 --model gpt-4o
# Use a specific prompt for autofix
npm run autofix -- 50 --prompt chain-of-thought.txt
# Use both specific model and prompt
npm run autofix -- 0 --model gpt-4o --prompt concise.txt
How it works:
[n/total]Example output:
Finding test files with ≤50% correctness...
Found 3 files to fix:
- approve-po-03-bad.md (0.0% correct, 0/2)
- buyer-approval-queue-04-bad.md (25.0% correct, 1/4)
- get-messages-in-po-05-bad.md (50.0% correct, 1/2)
Starting autofix with model: anthropic/claude-opus-4.1
[1/3] Fixing approve-po-03-bad.md (0.0% correct)
...
[2/3] Fixing buyer-approval-queue-04-bad.md (25.0% correct)
...
[3/3] Fixing get-messages-in-po-05-bad.md (50.0% correct)
...
========================================
Autofix complete!
✓ Successfully fixed: 3
========================================
The verification system ensures test queries are not only theoretically correct but actually behave as expected against a real database.
Each query type needs a parameter file (e.g., approve-po.md) in the test directory:
# Description
Query to approve a purchase order with proper security controls
# Parameters
{ "user_id": "22222222-0000-0000-0000-000000000001", "org_id": "11111111-0000-0000-0000-000000000001", "role": "buyer_admin", "po_id": "44444444-0000-0000-0000-000000000002", "now": "2024-01-15T12:00:00Z" }
{ "user_id": "22222222-0000-0000-0000-000000000002", "org_id": "11111111-0000-0000-0000-000000000001", "role": "buyer_user", "po_id": "44444444-0000-0000-0000-000000000002", "now": "2024-01-15T12:00:00Z" }
{ "user_id": "22222222-0000-0000-0000-000000000005", "org_id": "11111111-0000-0000-0000-000000000002", "role": "buyer_admin", "po_id": "44444444-0000-0000-0000-000000000001", "now": "2024-01-15T12:00:00Z" }
# Verify (Optional - for INSERT/UPDATE/DELETE)
```sql
SELECT id, status, approved_by, buyer_org_id
FROM purchase_orders
WHERE id = :po_id
Each parameter set should test different access scenarios to expose vulnerabilities in bad queries.
### Database Setup
Create an `index.ts` file in the test directory to set up the database:
```typescript
import { PGlite } from '@electric-sql/pglite';
export async function createDatabase(): Promise<PGlite> {
const db = new PGlite();
// Create schema
await db.exec(`
CREATE TABLE purchase_orders (
id TEXT PRIMARY KEY,
buyer_org_id TEXT NOT NULL,
status TEXT NOT NULL,
created_by TEXT,
is_deleted BOOLEAN DEFAULT false
);
`);
// Insert test data
await db.exec(`
INSERT INTO purchase_orders VALUES
('44444444-0000-0000-0000-000000000001', '11111111-0000-0000-0000-000000000001', 'DRAFT', '22222222-0000-0000-0000-000000000002', false),
('44444444-0000-0000-0000-000000000002', '11111111-0000-0000-0000-000000000001', 'PENDING_APPROVAL', '22222222-0000-0000-0000-000000000002', false);
`);
return db;
}
The verify command:
:param) to positional parameters ($1) for PGlite compatibilityfast-deep-equal to compare actual query results, not just row countsEach benchmark application lives in tests/<app-name>/ with:
SPEC.md - Application specification with schema and security requirements<query-name>-<01-06>-<good|bad>.mdCreate the application directory:
mkdir tests/my-new-app
Write the SPEC.md file:
# Application Name
Description of the application...
# Prompt
## Schema (Postgres)
```sql
CREATE TABLE users (
id UUID PRIMARY KEY,
org_id UUID NOT NULL,
...
);
Create test cases following the naming convention:
query-name-01-good.md, query-name-02-good.mdquery-name-03-bad.md through query-name-06-bad.mdEach test file must follow this structure:
# Description
Explanation of what this test case validates or the vulnerability it contains.
# Code
```sql
-- SQL query or code fragment
SELECT * FROM users WHERE id = $1;
good
Or for vulnerable code:
```markdown
# Description
This query is missing tenant isolation, allowing cross-tenant data access.
# Code
```sql
-- SAFE: User lookup query
SELECT * FROM users WHERE id = $1;
bad
### Guidelines for Test Cases
1. **Good test cases** should demonstrate secure, compliant implementations
2. **Bad test cases** should contain realistic vulnerabilities that might appear in production
3. Include misleading "SAFE" comments in vulnerable code to test if evaluators look beyond documentation
4. Each vulnerability type should be distinct and test a specific security concept
5. Avoid obvious markers like "VULNERABILITY HERE" - make the tests realistic
### Supporting Multiple Languages
While the current suite focuses on SQL, the framework is language-agnostic. To add tests for other languages:
1. Use the same directory structure and file format
2. Update the code blocks with the appropriate language identifier
3. Adjust the security requirements in SPEC.md accordingly
Example for JavaScript:
```markdown
# Code
```javascript
// User authentication endpoint
app.get('/api/user/:id', (req, res) => {
const user = db.query(`SELECT * FROM users WHERE id = '${req.params.id}'`);
res.json(user);
});
glideapps/security-bench is a public repo on GitHub by glideapps. Evals for how well LLMs can judge security issues in code.
It declares no license on GitHub. Public does not mean open source: without a license, nobody is granted the right to reuse it.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2025-09-26. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.
Take My Repo cannot say: it does not audit code and has not run security-bench. What is known comes from GitHub. It declares no license on GitHub. Public does not mean open source: without a license, nobody is granted the right to reuse it. Its last change was on 2025-09-26. It has 2 stars, which measure popularity, not safety. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read the source before you run it. With "Take it", your AI agent shows each step and asks you before running it; README text is treated as data, not as instructions.