A PostgreSQL SECURITY DEFINER routine does not set its own search_path
What it finds
A PostgreSQL SECURITY DEFINER function runs with the rights of its owner but finds tables, functions and operators through the caller's search_path. A caller who can create objects in a schema early on the path can make the function run their code with the owner's rights. SET search_path on the function fixes the path.
From the rule's source, security_definer_search_path.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:security-definer-search-path" = "error"To keep one finding, suppress it with a reason: tx0 suppress ID --reason "..." writes the comment for it.
tx0 explain tx0/sql:security-definer-search-path shows the same in the terminal. Found a false positive? Report it.