Overview
Every syntactically named query/rawQuery/exec/executeQuery method call in collected custom PHP/PHTML uses one static string first argument, without direct concatenation or interpolation. Unresolved variables yield UNKNOWN. This does not prove parameter binding or SQL injection safety. Scope is completely collected app/code PHP/PHTML; missing, unreadable, oversized, linked, malformed or truncated eligible input prevents a clean PASS.
Why it Matters
Query-string concatenation and interpolation mix SQL structure with data and complicate review. Requiring literal structure creates an exact source policy reviewers can reproduce.
A literal query may still misuse bindings or authorization, so passing this syntax rule cannot establish SQL safety.
Verification Steps
Manual Verification
- Review every syntactically named query/rawQuery/exec/executeQuery call in the complete app/code PHP/PHTML scope.
- Require a static first string argument and assess variable/alias ambiguity as unresolved.
- Review bindings and dynamic identifiers separately.
Command / Review Sample
// Illustrative call structure; binding behavior still needs review:
$connection->query('SELECT entity_id FROM example WHERE entity_id = ?', [$id]);
Use the assessed Magento project and the appropriate application or read-only review account. Replace example hosts, paths and identifiers with the assessment scope; configuration and source fragments are illustrative.
Remediation / Fix Guidance
- Inspect each named call and argument at the reported file/line. Trace input origin, receiver identity, authorization and output use before deciding whether to replace the API or document an approved exception to this explicit coding policy. Confirm the receiver is a SQL interface before interpreting a query-named method as database access; verify binding and identifier handling separately.
- Test the affected behavior and its real trust boundary. Replacing an API or wrapping a call does not by itself validate input or remove an exploit path.
- Rerun MB-0786 against the same release, profile and relevant file/key/package scope; compare the new evidence and inspect any independent collection gaps.
Examples
Illustrative examples only. Interpret them within the current revision criterion above; missing collection evidence is unresolved, never PASS.
Fail Example
$connection->query('SELECT entity_id FROM example WHERE entity_id = ' . $id);
Pass Example
$connection->query('SELECT entity_id FROM example WHERE entity_id = ?', [$id]);
// Literal first argument meets this syntax policy.
// Binding and authorization still need review.
Scope and Evidence Limits
Rule revision: 1. Target modes: LOCAL.
Every syntactically named query/rawQuery/exec/executeQuery method call in collected custom PHP/PHTML uses one static string first argument, without direct concatenation or interpolation. Unresolved variables yield UNKNOWN. This does not prove parameter binding or SQL injection safety. Scope is completely collected app/code PHP/PHTML; missing, unreadable, oversized, linked, malformed or truncated eligible input prevents a clean PASS.
Exact opt-in coding policy, not a finding of confirmed exploitability or proof of the broader historical requirement. Runtime adapters, dependencies, generated code and files outside app/code remain outside this predicate.
Catalog coverage describes implementation capability, not a scan outcome. An incomplete manual review cannot establish that the criterion is satisfied.