Dynamic SQL is built by concatenating a routine parameter into the statement text
What it finds
Dynamic SQL built by pasting a routine's parameter into the statement text, as in EXECUTE IMMEDIATE 'DELETE FROM t WHERE name = ''' || p_name || '''' or EXEC('SELECT * FROM ' + @table): a caller who controls the parameter controls the statement, which is SQL injection. Bind variables (USING, sp_executesql parameters, format('%L')) pass values without that risk; names can go through a quoting function.
The parameter may reach the statement directly or through a local variable assigned in the same routine. Parameters of numeric and date types, and values passed through a quoting function such as QUOTENAME, quote_ident, quote_literal or DBMS_ASSERT, are not counted.
From the rule's source, dynamic_sql_injection.rs.
Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/sql:dynamic-sql-injection" = "error"To keep one finding, suppress it with a reason: tx0 suppress ID --reason "..." writes the comment for it.
tx0 explain tx0/sql:dynamic-sql-injection shows the same in the terminal. Found a false positive? Report it.