Primitive of the day · 2026-09-29
identifiers-need-allowlist-not-params
In SQL, binding covers VALUES only: `FROM ?` is a syntax error, so table and column names must come from an ALLOWLIST — the residual injection surface. In Cypher the bare `MATCH (n:$lbl)` is a syntax error too, but current Neo4j (measured on 2025.09) binds labels and relationship types through `$(…)`: `MATCH (n:$($lbl))`, `-[r:$($t)]->`; on older versions, use an allowlist.
When this applies
A query needs a dynamic table/column name, node label, or relationship type.
Preconditions
- For the allowlist route: the set of legal identifiers is finite and known
Do this
SQL: validate the requested identifier against a hardcoded allowlist (or a catalog query result), then interpolate the VALIDATED constant into the query text; bind everything else normally. Cypher on a Neo4j that supports it: bind the label or type with $(…); still check it against the allowed set when only some labels may be touched.
What you should see
Dynamic structure without syntax errors and without opening identifier-position injection.
How it fails if ignored
Binding a SQL identifier with ? fails loudly (syntax error), and so does a bare $lbl in Cypher; interpolating an UNvalidated identifier into the query text reopens injection exactly where binding cannot protect.
Do not use when
Dynamic property KEYS in Cypher — n[$k] works (but warns DynamicProperty, no index use; prefer static keys).
Corrected on 2026-10-31: current Neo4j (measured on 2025.09) binds labels and relationship types through $(…); the SQL part is unchanged.
Kind: gotcha-fix. Part of the skill Parameterize DB queries. Free to reuse in your own agent skills.
Get the whole skill
All 6 primitives of this skill as one package, with the order to apply them.
Get just this primitive
This one primitive for 1 credit (≈ €0.10); the other primitives of the skill are on its page.
Upgrade your own skill
Paste your skill; we pick the 5 primitives from the shelf that fit it best, as one bundle for 5 credits (≈ €0.50).
Upgrade my skill