T09 · Insecure Skill Coding Practices
- Location
SKILL.md:202- Finding
Raw SQL and Unparameterized Predicates Enable SQL Injection
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 202–219
Vulnerability Type: Raw SQL execution and unparameterized caller-controlled predicates
Risk Level: HighVulnerable Code
bash # Query python scripts/sql_linker.py query "SELECT * FROM <table> LIMIT 10" python scripts/sql_linker.py query "SHOW TABLES" python scripts/sql_linker.py query "DESC <table_name>" # Insert python scripts/sql_linker.py --user-label "<label>" --session-id "<session_id>" \ insert "<table>" "{\"field\":\"value\",\"field2\":123}" # Update python scripts/sql_linker.py --user-label "<label>" --session-id "<session_id>" \ update "<table>" "{\"field\":\"new_value\"}" "<where_clause>" # Delete python scripts/sql_linker.py --user-label "<label>" --session-id "<session_id>" \ delete "<table>" "<where_clause>"The document additionally states at line 243:
text Parameterized queries: always use `%s` + tuple to prevent SQL injectionHowever, the CLI examples accept complete SQL queries, table identifiers, and free-form
where_clausestrings. The documented CLI does not expose a value-binding mechanism for these predicates, so the parameterization claim is inconsistent with the instructed behavior.Technical Analysis
Table names and SQL predicates are syntactic SQL elements and cannot be made safe merely by placing them in shell quotes. If request content is substituted into these placeholders without strict parsing and validation, an attacker may supply a tautological predicate such as
1=1, add SQL comments, alter predicate logic, or potentially inject additional statements where the database driver permits stacked statements.UPDATE and DELETE are particularly dangerous because a malicious or empty predicate can expand a targeted operation into a table-wide modification. The same raw query interface can ...[truncated 1410 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the general-purpose raw SQL
queryinterface from Agent-facing instructions. - Replace free-form WHERE clauses with structured, typed JSON filters such as field, operator, and value tuples.
- Validate all table and field identifiers against explicit allowlists loaded from
table.json. - Permit only a small allowlist of filter operators and reject SQL comments, delimiters, subqueries, unions, and statement separators.
- Bind every data value through the database driver's parameter API; never concatenate values into SQL.
- Reject UPDATE and DELETE requests with missing, empty, tautological, or excessively broad predicates.
- Require confirmation and a preview of the affected row count before destructive operations.
- Add automated tests for tautologies, comments, stacked statements, malformed identifiers, and predicate-bypass payloads.
- Remove the general-purpose raw SQL
