PatchClock

PHP security digest · 25 Nov 2026

livewire-powergrid: SQL injection via sortDirection in naturalSort queries

High CVE-2026-65971

Package
power-components/livewire-powergrid
Fixed in
6.10.4
Published
Wed 25 Nov 2026, 19:44 LisbonUpdated Thu 26 Nov 2026, 00:45 Lisbon
Installs on Packagist
2M

In plain words

An attacker who can access a PowerGrid table using naturalSort and control its sortDirection property can inject SQL into sorting queries. This lets them read any data accessible to the database connection, including password hashes, tokens and other tenants' data.

Affected versions

PackageAffectedFixed in
power-components/livewire-powergrid>= 6.0.0, < 6.10.46.10.4

How serious is it?

High is a CVSS score of 7.0 to 8.9: serious impact with few preconditions. Plan the update within days, ahead of feature work, and check the logs for signs it was tried.

power-components/livewire-powergrid has 2M installs on Packagist, so the advisory reaches a large number of projects: expect scanners to look for it soon.

Am I affected?

Check composer.lock for power-components/livewire-powergrid at version 6.0.0 or later but below 6.10.4; 6.10.4 is fixed. Search your PowerGrid table definitions for columns using ->naturalSort(true) and check whether an attacker can access those tables and control the Livewire-bound sortDirection property. The advisory demonstrates the issue on MariaDB.

Did you install power-components/livewire-powergrid, or did a dependency?

Composer says why a package is in your project:

composer why power-components/livewire-powergrid

If the output names your own project, you required power-components/livewire-powergrid directly and the update is yours to make. If it names another package, power-components/livewire-powergrid came in through it, and that package's version constraint decides which release you can install. To see what stands between you and the fix, ask Composer directly:

composer why-not power-components/livewire-powergrid 6.10.4

Every line it prints is a constraint that blocks 6.10.4. Update the package it names, or raise your own constraint, and run it again until it prints nothing.

What to do

Check which version you have, then update to a fixed release for your branch (6.10.4):

composer show power-components/livewire-powergrid | grep versions
composer update power-components/livewire-powergrid

If your version constraint in composer.json keeps you below a fixed release, raise it first. Whether your configuration is affected, and the exact version ranges, are in the advisory itself.

Check the whole project at once

Composer 2.4 and later can list every installed package with a known advisory, this one included once Packagist has it:

composer audit --locked

--locked reads composer.lock instead of the vendor folder, so you can run it on a release tag or in CI without installing anything. It exits with a non-zero code when it finds an advisory, which is enough to fail a build. Run it on every branch you still support, not only the newest: an older release your customers run is affected in the same way.

Under the Cyber Resilience Act

CRA Article 14 timeline: aware of exploitation at hour 0, early warning within 24 hours, notification within 72 hours, final report within 14 days after the fix.

No exploitation of this vulnerability is known, so on its own it does not start the Article 14 reporting clock, which covers actively exploited vulnerabilities. That changes if you learn it is being exploited through your product: then the 24-hour early warning applies.

Either way, if power-components/livewire-powergrid ships inside a product you sell, the CRA treats its vulnerabilities as yours. Article 13(5) asks for due diligence on the components you include, and from 11 December 2027 Annex I asks you to ship security fixes without delay and free of charge for the support period you declared. A short note in your changelog saying which release updated power-components/livewire-powergrid, and why, is the evidence you will want later.

What goes in each Article 14 report · Does the CRA apply to your product?

power-components/livewire-powergrid's record

This is the only advisory for power-components/livewire-powergrid since the digest started following Composer packages in September 2026. One advisory says little about a package's quality; what matters is how fast the fix came, and here it is out.

The advisory's description

[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.

Weakness: CWE-89 Improper Neutralization of Special Elements used in an SQL Command. Reported by BiiTts.

CWE-89. SQL injection: input reaches a database query as SQL, so the attacker can read or change data the query was never meant to touch.

The advisory

From OSV.dev, which gathers the GitHub Advisory Database, FriendsOfPHP and Drupal security advisories; the summary is theirs. The description, affected versions, weakness and credits are from the GitHub Advisory Database (CC BY 4.0). "In plain words", "Am I affected?" and "If you cannot update yet" are based on that advisory, and checked to name no version it does not.