forked from bchanot/claude
fix(guardrails): CONCAT before RAW, probe row newline kept, malformed urls handled, sa.text matched
This commit is contained in:
1 parent
9275e0d82b
commit
63a88bc91d
5 files changed
+47
-15
No files matched your search
@@ -108,6 +108,8 @@ class H(BaseHTTPRequestHandler):
|
||||
if path == "/offhost.js":
|
||||
return self._send(200, b"x();\n//# sourceMappingURL="
|
||||
b"http://other.invalid/o.map\n")
|
||||
if path == "/badmap.js":
|
||||
return self._send(200, b"z();\n//# sourceMappingURL=http://[x\n")
|
||||
if path == "/trunc.js":
|
||||
return self._send(200, b"a" * 1_000_001)
|
||||
if path == "/bigmap.js":
|
||||
@@ -312,7 +314,7 @@ echo "== exposure probes: map channels and fail-closed paths"
|
||||
cat > "$WORK/maps.json" <<EOF
|
||||
{"base_url": "$BASE",
|
||||
"exposure": {"scripts": ["/embed.js", "/redir.js", "/hdr.js", "/cmt.js",
|
||||
"/offhost.js", "/trunc.js", "/bigmap.js"], "error_routes": []}}
|
||||
"/offhost.js", "/trunc.js", "/bigmap.js", "/badmap.js"], "error_routes": []}}
|
||||
EOF
|
||||
OUT="$(probe --authorized "$WORK/maps.json")"
|
||||
check "a sourceMappingURL string inside code is CLOSED, not an inline map" \
|
||||
@@ -325,6 +327,10 @@ check "a map named by the trailing comment is OPEN" \
|
||||
"$(verdict "$OUT" 'sourcemap:/cmt.js')" OPEN
|
||||
check "a map url on another host is SKIPPED" \
|
||||
"$(verdict "$OUT" 'sourcemap:/offhost.js')" SKIPPED
|
||||
check "a malformed map url is SKIPPED, no traceback" \
|
||||
"$(verdict "$OUT" 'sourcemap:/badmap.js')" SKIPPED
|
||||
check "the message line keeps its newline and 11-space indent" \
|
||||
"$(printf '%s\n' "$OUT" | grep -A1 'sourcemap:/offhost.js' | tail -1 | grep -c '^ [^ ]')" 1
|
||||
check "a truncated script is SKIPPED" \
|
||||
"$(verdict "$OUT" 'sourcemap:/trunc.js')" SKIPPED
|
||||
check "an oversize map is SKIPPED" \
|
||||
@@ -349,6 +355,9 @@ echo "== plan validation and host guard"
|
||||
printf '{"base_url": "file:///tmp"}\n' > "$WORK/file.json"
|
||||
probe --authorized "$WORK/file.json" >/dev/null 2>&1
|
||||
check "a file:// base_url exits 2" "$?" 2
|
||||
printf '{"base_url": "http://[x"}\n' > "$WORK/v6.json"
|
||||
probe --authorized "$WORK/v6.json" >/dev/null 2>&1
|
||||
check "a malformed base_url exits 2" "$?" 2
|
||||
printf '{"base_url": 5}\n' > "$WORK/num.json"
|
||||
ERR="$(probe --authorized "$WORK/num.json" 2>&1 >/dev/null)"
|
||||
check "a non-string base_url exits 2 without a traceback" \
|
||||
|
||||
@@ -191,6 +191,14 @@ mutant sql-ruby-where-interp FAIL INJ-SQL-CONCAT \
|
||||
"printf '%s\n' 'User.where(\"name = #{name}\")' > src/lib/users.rb"
|
||||
mutant shell-db-php-upper-var FAIL INJ-SHELL-DB-TOOL \
|
||||
"printf '%s\n' '<?php shell_exec(\"mysqldump --host=\$Host app\");' > src/lib/dump.php"
|
||||
mutant concat-in-sqla-text FAIL INJ-SQL-CONCAT \
|
||||
"printf '%s\n' 'import sqlalchemy' 'conn.execute(text(f\"select id from notes where owner = {owner}\"))' > src/lib/db.py"
|
||||
mutant concat-in-objects-raw FAIL INJ-SQL-CONCAT \
|
||||
"printf '%s\n' 'User.objects.raw(f\"select id from notes where owner = {name}\")' > src/lib/db.py"
|
||||
mutant concat-in-knex-raw FAIL INJ-SQL-CONCAT \
|
||||
"printf '%s\n' 'knex.raw(base + \" where id = \" + id);' >> $API"
|
||||
mutant sql-sqla-sa-text WARN INJ-SQL-RAW-UNSAFE \
|
||||
"printf '%s\n' 'import sqlalchemy as sa' 'conn.execute(sa.text(q))' > src/lib/db.py"
|
||||
mutant sql-dynamic-exec WARN INJ-SQL-DYNAMIC-EXEC \
|
||||
"printf '%s\n' \"execute 'select count(*) from ' || tbl into n;\" >> $SQL"
|
||||
mutant postgrest-filter WARN INJ-POSTGREST-FILTER \
|
||||
@@ -324,6 +332,8 @@ benign long-line-bundle \
|
||||
|
||||
benign sqla-text-method \
|
||||
"printf '%s\n' 'import sqlalchemy' 'label = project.text(path)' > src/lib/db.py"
|
||||
benign sqla-resp-text \
|
||||
"printf '%s\n' 'import sqlalchemy' 'body = resp.text(x)' > src/lib/db.py"
|
||||
benign shell-db-argv-spawn \
|
||||
"printf '%s\n' 'spawn(\"psql\", [\"-f\", file], {env});' > src/lib/backup.ts"
|
||||
benign shell-db-argv-python \
|
||||
|
||||
Reference in new issue
Block a user