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://agent402.tools/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://agent402.tools/api/sql-guard", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"sql": "UPDATE users SET plan = 'pro' WHERE id = 42"
}),
});
No wallet? Pay with compute
This is a pure-CPU tool, so an agent without a wallet can pay with proof-of-work instead of USDC: fetch a challenge, solve the sha256 puzzle (16 leading zero bits - a fraction of a second of CPU, no money, no AI tokens), and resend with the X-Pow-Solution header.
import { createHash } from "node:crypto";
const lz = (b) => { let t = 0; for (const x of b) { if (!x) { t += 8; continue; } t += Math.clz32(x) - 24; break; } return t; };
const c = await (await fetch("https://agent402.tools/api/pow/challenge?slug=sql-guard")).json();
let n = 0;
while (lz(createHash("sha256").update(c.challenge + ":" + n).digest()) < c.difficulty) n++;
await fetch("https://agent402.tools/api/sql-guard", { method: "POST", headers: { "X-Pow-Solution": c.token + ":" + n, "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…
URL parse
POST /api/url-parseParse a URL into components: protocol, host, port, path, query params (decoded), hash, origin, punycode hostname.
IP info
POST /api/ip-infoClassify an IP address: version, public/private/loopback/link-local, integer form, and reverse-DNS (PTR) lookup.