From 63a88bc91d5579c54fbe081b44cb4cd51212c757 Mon Sep 17 00:00:00 2001 From: bchanot Date: Mon, 19 Oct 2026 12:17:56 +0200 Subject: [PATCH] fix(guardrails): CONCAT before RAW, probe row newline kept, malformed urls handled, sa.text matched --- ...2026-10-18-guardrails-a11y-split-design.md | 9 ++++--- lib/tests/guardrails-probe.test.sh | 11 +++++++- lib/tests/guardrails-scan.test.sh | 10 ++++++++ skills/guardrails/scripts/checks/injection.py | 7 +++--- skills/guardrails/scripts/probe.py | 25 +++++++++++++------ 5 files changed, 47 insertions(+), 15 deletions(-) diff --git a/docs/superpowers/specs/2026-10-18-guardrails-a11y-split-design.md b/docs/superpowers/specs/2026-10-18-guardrails-a11y-split-design.md index 38fbbcb..0c8ff08 100644 --- a/docs/superpowers/specs/2026-10-18-guardrails-a11y-split-design.md +++ b/docs/superpowers/specs/2026-10-18-guardrails-a11y-split-design.md @@ -68,16 +68,17 @@ option. `--domain a11y` is now a usage error (exit 2). Applies when the tree has a source file (`SOURCE_EXTS`) or a `.sql` file. Skips test, spec, fixture and mock paths. One finding per (path, line): -when two rules match the same line the first in this order wins. +when two rules match the same line the first in this order wins, so a +interpolation inside a raw escape stays INJ-SQL-CONCAT (FAIL). | Rule | Sev | Catches | |---|---|---| -| INJ-SQL-RAW-UNSAFE | WARN | a raw escape fed a non-literal first argument: `$queryRawUnsafe(`, `$executeRawUnsafe(`, `knex.raw(`, `.raw(`, `.extra(`, `sequelize.query(`, `Sequelize.literal(`, `text(` when `sqlalchemy` is imported; WARN: a variable may hold a constant | | INJ-SQL-CONCAT | FAIL | a SQL statement string built from an expression: untagged template literal with `${`, quoted SQL followed by `+ identifier`, Python f-string, `%` operator or `.format(`, PHP `"… $var"` or `. $var`, Ruby `#{}` (including ActiveRecord `.where("… #{`), Rust `format!(`, Go `fmt.Sprintf(` | +| INJ-SQL-RAW-UNSAFE | WARN | a raw escape fed a non-literal first argument: `$queryRawUnsafe(`, `$executeRawUnsafe(`, `knex.raw(`, `.raw(`, `.extra(`, `sequelize.query(`, `Sequelize.literal(`, `text(` when `sqlalchemy` is imported; WARN: a variable may hold a constant | | INJ-SQL-DYNAMIC-EXEC | WARN | plpgsql `EXECUTE` whose statement uses `\|\|` and is not `format(…)` (SQL files, comments blanked) | | INJ-POSTGREST-FILTER | WARN | supabase-js `.or(`, `.filter(`, `.not(`, `.match(`, `.textSearch(` with a template `${` or a `+` concatenation | | INJ-NOSQL-OPERATOR | WARN | Mongo `$where:` with a string, or `find`/`findOne`/`update*`/`delete*`/`countDocuments` whose filter is `req.body`, `req.query`, `req.params` or one field taken straight from them | -| INJ-SHELL-DB-TOOL | FAIL | `exec`, `execSync`, `spawn`, `spawnSync`, `system`, `popen`, `subprocess.*`, `os.system`, `Command::new`, `shell_exec`, `passthru`, `proc_open` naming psql, mysql, mysqldump, pg_dump, pg_restore, mongosh, mongo, mongodump, redis-cli, sqlite3 or clickhouse-client on a line that also interpolates (`${`, `+ x`, `#{`, `{x}`, `%s`, `$x`) | +| INJ-SHELL-DB-TOOL | FAIL | `exec`, `execSync`, `spawn`, `spawnSync`, `system`, `popen`, `subprocess.*`, `os.system`, `Command::new`, `shell_exec`, `passthru`, `proc_open` naming psql, mysql, mysqldump, pg_dump, pg_restore, mongosh, mongo, mongodump, redis-cli, sqlite3 or clickhouse-client on a line that also interpolates (`${`, `+ x`, `#{`, `{x}`, `%s`, `$x`); outside PHP an uppercase `$NAME` is an env reference and stays silent | Silent by design: tagged templates (`sql\`…\``, `prisma.$queryRaw\`…\``), placeholders (`$1`, `?`, `%s` with a separate tuple), an argv array @@ -114,7 +115,7 @@ defaults). Still GET only, same host, shared budget, `--authorized`. |---|---| | `sourcemap: