with one click
security-audit
// Audit backend code for security vulnerabilities — DoS vectors, query performance, connection pool exhaustion, injection, missing rate limits, and resource exhaustion
// Audit backend code for security vulnerabilities — DoS vectors, query performance, connection pool exhaustion, injection, missing rate limits, and resource exhaustion
| name | security-audit |
| description | Audit backend code for security vulnerabilities — DoS vectors, query performance, connection pool exhaustion, injection, missing rate limits, and resource exhaustion |
| disable-model-invocation | true |
Perform a security audit of the backend codebase, focusing on vulnerabilities that could be exploited by external attackers. Check every category below systematically.
Scan all files in src/query-builders/ and any raw SQL in src/controllers/ or src/utils/.
For each query, check:
ORDER BY on a CTE wrapper force full materialization before LIMIT is applied? PostgreSQL must fully materialize and sort before it can limit, turning a lazy evaluation into a full scan.For each issue found, explain:
Check src/utils/connect.ts and database configuration:
statement_timeout set on the database connection or individual queries?Check src/index.ts and all route files in src/routes/:
Check all controllers in src/controllers/ and route definitions:
Prisma.raw() used with user-controlled values? (This bypasses parameterization)Check controllers and middleware:
server.requestTimeout appropriate for all endpoints?Check error handling and responses:
/health endpoint expose sensitive information in production?Present findings as a prioritized list:
## Findings
### [CRITICAL/HIGH/MEDIUM/LOW] Title
- **Location**: file:line
- **Vulnerability**: What's wrong
- **Exploit scenario**: How an attacker would use this
- **Impact**: What happens if exploited
- **Suggested fix**: How to fix it
If no issues are found in a category, briefly state that the category was checked and is clean.
ORDER BY on recursive CTE wrapper in buildKeysQuery (src/query-builders/keys.ts) forced full materialization, enabling DoS via connection pool exhaustion. Fixed by removing the redundant ORDER BY.