SQL execution certificate firewall
POST /api/sql-guardReview a SQL statement an agent is about to run against production, and certify it. Returns a policy verdict (pass / warn / block) with named risks - unbounded UPDATE or DELETE, tautological WHERE, DROP, TRUNCATE, DROP COLUMN, statement stacking, COPY ... FROM PROGRAM, GRANT/role changes, session_replication_role and trigger/constraint bypass, writes to pg_catalog - and, when the verdict is pass, an Ed25519 certificate binding that verdict to the SHA-256 of the exact statement. Your database layer verifies the certificate with sql-cert-verify before executing, so the check cannot be skipped by a confused or compromised agent. Literals and comments are scrubbed before analysis, so a keyword inside a string is never a false alarm. HONEST SCOPE: a lexical guard over a fixed, published risk catalogue - it catches the shapes that destroy production data, it is not a SQL parser and cannot know that a WHERE clause names the wrong tenant.
Input
| Field | Type | Description |
|---|---|---|
sql * | string | the exact statement you are about to execute |
allow | array | risk ids to downgrade from block to warn (see riskCatalogue in the response) |
allowMultiStatement | boolean | permit more than one statement in the submission (default false) |
ttlSeconds | number | certificate lifetime, 30-3600 (default 300) |
Example output
{
"verdict": "pass",
"mutating": true,
"statementCount": 1,
"sha256": "635cf20a…",
"risks": [],
"certificate": {
"token": "eyJ2Ijox….signature",
"expiresAt": "2026-07-28T20:05:00Z"
}
}
Try it - see the 402 challenge (free)
curl -i -X POST https://base-sentinel-production.up.railway.app/api/sql-guard \
-H "Content-Type: application/json" \
-d '{"sql":"UPDATE users SET plan = 'pro' WHERE id = 42"}'
The response is HTTP 402 Payment Required with exact payment requirements. Any x402 v2 client pays automatically and retries:
Paid call (JavaScript agent)
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";
const client = new x402Client();
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);
const res = await payFetch("https://base-sentinel-production.up.railway.app/api/sql-guard", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"sql": "UPDATE users SET plan = 'pro' WHERE id = 42"
}),
});
Related tools
Email validate
POST /api/email-validateValidate an email address: syntax check plus live MX record lookup on the domain (deliverability signal, not a guarantee…
try in playground →URL parse
POST /api/url-parseParse a URL into components: protocol, host, port, path, query params (decoded), hash, origin, punycode hostname.
try in playground →IP info
POST /api/ip-infoClassify an IP address: version, public/private/loopback/link-local, integer form, and reverse-DNS (PTR) lookup.
try in playground →