Home/Research/Post

GHSA-7fgc-3h6c-698r: livewire-powergrid: SQL injection via sortDirection in naturalSort queries

  • Severity: HIGH
  • CVE: CVE-2026-65971
  • Ecosystems: composer
  • Packages: power-components/livewire-powergrid

## [Description]

The public Livewire property `sortDirection` is interpolated **verbatim** into a
raw SQL `ORDER BY` clause and is not restricted to `asc`/`desc`, allowing arbitrary
SQL injection through `POST /livewire/update`.

**Data flow**

– **Source** — `src/Concerns/Sorting.php`: `public string $sortDirection;` is a
Livewire-bound property with no whitelist/validation (it is only assigned and
flipped by `reverseSort()`), so it is fully attacker-controlled via the standard
Livewire update endpoint.
– **Taint** — `src/DataSource/Processors/Database/Pipelines/ColumnRawQueries.php`,
`resolvePlaceholders()`:
“`php
preg_replace_callback(‘/\{(\w+)\}/’, fn ($m) => data_get($this->component, $m[1], ”), $sql);
“`
substitutes `{sortDirection}` with the raw property value.
– **Sink** — `src/DataSource/Support/Sql.php::getSortSqlByDriver()` builds the
`naturalSort` expression, e.g. `”… {sortDirection}”` / `”CAST(…) {sortDirection}”`,
which is passed to `orderByRaw()`. The tainted direction lands directly in the SQL
string.

**Why the framework mitigation does not apply (the bypass)**

Normally the `Sorting` pipeline calls `orderBy(resolveSortField($sortField), $sortDirection)`,
and Laravel validates the direction (`Order direction must be “asc” or “desc”.`).
Setting **`sortField=””`** makes the `Sorting` pipeline skip (`filled(”)` is false),
so the validating `orderBy` never runs — but the `ColumnRawQueries` pipeline still
applies the `naturalSort` `orderByRaw`…

Source: GitHub Security Advisories · 2026-11-25