scan_sql_query
Scans SQL queries for security threats including injection patterns, destructive operations, and PII extraction before execution to prevent database vulnerabilities.
Instructions
Scans a SQL query before execution for security threats.
Checks for:
SQL injection patterns (UNION, stacked queries, tautologies, blind injection)
Destructive operations (DROP, TRUNCATE, DELETE without WHERE)
Privilege escalation (GRANT, CREATE USER)
PII extraction (queries on password/SSN/credit card columns)
Set allowDestructive=true to permit DROP/TRUNCATE for migrations.
Returns:
blocked: true/false
threat_type: sql_injection, etc.
severity: critical/high/medium/low
confidence: high/medium/low
guidance: actionable explanation
request_id: unique identifier
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The SQL query to scan | |
| database | No | Optional target database name for context | |
| allowDestructive | No | Allow destructive operations like DROP/TRUNCATE (default: false) |