Query examples

Queries Vericto blocks and why.

These are real examples of queries that AI agents (LangChain, Vercel AI SDK, OpenAI function calling, MCP servers, etc.) generate when connecting to production databases. We have anonymized table names but the pattern of each query is identical to the original.

DELETE queries

Mass DELETE without condition

BLOCKED
DELETE FROM users;
Offending AST node DeleteStmt > WhereClause = NULL
Rule VERICTO-001 CRITICAL
Suggested safe query
DELETE FROM users WHERE id = $1;

DELETE in CTE without WHERE

BLOCKED
WITH old_orders AS (
  DELETE FROM orders
  RETURNING id
)
SELECT COUNT(*) FROM old_orders;
Offending AST node WithClause > DeleteStmt > WhereClause = NULL
Rule VERICTO-001 CRITICAL
Suggested safe query
WITH old_orders AS (
  DELETE FROM orders
  WHERE created_at < NOW() - INTERVAL '90 days'
  RETURNING id
)
SELECT COUNT(*) FROM old_orders;

DELETE with always-true WHERE

BLOCKED
DELETE FROM products WHERE 1=1;
Offending AST node DeleteStmt > WhereClause > BoolExpr = ALWAYS_TRUE
Rule VERICTO-003 CRITICAL
Suggested safe query
DELETE FROM products WHERE id = $1;

DELETE with subquery and no external predicate

BLOCKED
DELETE FROM logs
WHERE id IN (SELECT id FROM logs);
Offending AST node DeleteStmt > WhereClause > SubLink — sin predicado adicional
Rule VERICTO-033 HIGH
Suggested safe query
DELETE FROM logs
WHERE id IN (
  SELECT id FROM logs
  WHERE created_at < NOW() - INTERVAL '30 days'
);

UPDATE queries

UPDATE role on all users

BLOCKED
UPDATE users SET role = 'admin';
Offending AST node UpdateStmt > WhereClause = NULL
Rule VERICTO-042 CRITICAL
Suggested safe query
UPDATE users SET role = 'admin' WHERE id = $1;

UPDATE price to zero across the entire catalog

BLOCKED
UPDATE products SET price = 0;
Offending AST node UpdateStmt > WhereClause = NULL
Rule VERICTO-042 CRITICAL
Suggested safe query
UPDATE products SET price = $1 WHERE id = $2;

Mass UPDATE of status in CTE without WHERE

BLOCKED
WITH affected AS (
  UPDATE orders SET status = 'cancelled'
  RETURNING id
)
SELECT id FROM affected;
Offending AST node WithClause > UpdateStmt > WhereClause = NULL
Rule VERICTO-031 HIGH
Suggested safe query
WITH affected AS (
  UPDATE orders SET status = 'cancelled'
  WHERE status = 'pending' AND created_at < NOW() - INTERVAL '7 days'
  RETURNING id
)
SELECT id FROM affected;

DROP queries

DROP TABLE in production

BLOCKED
DROP TABLE users;
Offending AST node DropStmt (nodo presente)
Rule VERICTO-010 CRITICAL
Suggested safe query
-- Usar migración versionada con herramienta de migración
-- (Flyway, Liquibase, Prisma Migrate, Alembic, Rails migrations)
-- Nunca ejecutar DROP TABLE directamente desde un agente

DROP production DATABASE

BLOCKED
DROP DATABASE production;
Offending AST node DropStmt (nodo presente, object_type = DATABASE)
Rule VERICTO-010 CRITICAL
Suggested safe query
-- Las operaciones a nivel de DATABASE nunca deben ejecutarse
-- desde agentes de IA. Requieren intervención humana con acceso
-- administrativo explícito y autorización documentada.

TRUNCATE queries

TRUNCATE on orders table

BLOCKED
TRUNCATE TABLE orders;
Offending AST node TruncateStmt (nodo presente)
Rule VERICTO-011 CRITICAL
Suggested safe query
DELETE FROM orders
WHERE created_at < NOW() - INTERVAL '90 days';

TRUNCATE with CASCADE

BLOCKED
TRUNCATE TABLE users CASCADE;
Offending AST node TruncateStmt (nodo presente)
Rule VERICTO-011 CRITICAL
Suggested safe query
DELETE FROM users WHERE created_at < $1
AND NOT EXISTS (
  SELECT 1 FROM subscriptions
  WHERE subscriptions.user_id = users.id
    AND subscriptions.status = 'active'
);

Allowed safe queries

Vericto does not block legitimate queries. Any operation that includes specific predicates and does not present mass destruction patterns passes without modification. The added latency is less than 2ms p99.

DELETE with specific WHERE

ALLOWED
DELETE FROM users WHERE id = $1;
AST node DeleteStmt > WhereClause > ColumnRef (id)
Result PASS

UPDATE with specific WHERE

ALLOWED
UPDATE users SET name = $1 WHERE id = $2;
AST node UpdateStmt > WhereClause > ColumnRef (id)
Result PASS

SELECT with time filter

ALLOWED
SELECT * FROM orders
WHERE created_at > NOW() - INTERVAL '7 days';
AST node SelectStmt > WhereClause > A_Expr (temporal)
Result PASS

INSERT with explicit columns

ALLOWED
INSERT INTO events (user_id, action) VALUES ($1, $2);
AST node InsertStmt > Cols = [user_id, action]
Result PASS

Edge cases

Some patterns deserve additional explanation because Vericto's behavior may not be intuitive at first glance.

WHERE 1=1: always true

BLOCKED
DELETE FROM temp_table WHERE 1=1;
Offending AST node DeleteStmt > WhereClause > Integer(1) = Integer(1)
Rule VERICTO-003 CRITICAL
Why it is blocked

A WHERE with an always-true condition (1=1, true, 'a'='a') is semantically equivalent to no WHERE.

DELETE with LIMIT in MySQL

ALLOWED
DELETE FROM mysql_table LIMIT 10;
AST node DeleteStmt > LimitCount = 10 (MySQL)
Result PASS, MySQL solamente
Why it is allowed

In MySQL, DELETE ... LIMIT N is a SQL extension that limits the number of deleted rows. Vericto detects LIMIT 0 as a special case: although it deletes no rows, it is syntactically indistinguishable from a misconfigured DELETE.

DELETE in CTE with valid WHERE

ALLOWED
WITH deleted AS (
  DELETE FROM sessions
  WHERE expired_at < NOW()
  RETURNING id
)
SELECT COUNT(*) FROM deleted;
AST node WithClause > DeleteStmt > WhereClause > A_Expr (temporal)
Result PASS
Why it is allowed

The DELETE inside the CTE includes a WHERE with a real temporal predicate (expired_at < NOW()).