DEV Community

Livewire PowerGrid's sortDirection bypassed Laravel's order-direction check

Livewire PowerGrid used a public Livewire property as an SQL sort direction. In affected versions, an attacker could send a value other than asc or desc and reach a raw ORDER BY expression.

The framework's normal direction validation did not stop the request because the validating path was skipped. The issue is CVE-2026-65971. Versions from 6.0.0 through 6.10.3 are affected, and 6.10.4 contains the fix. GitHub rates the advisory High.

The bypass came from two sort paths

The ordinary sorting pipeline calls Laravel's orderBy() with the requested direction. Laravel rejects values other than asc and desc.

PowerGrid also has a natural-sort path that builds a raw SQL expression from placeholders. When sortField is empty, the ordinary sorting pipeline treats the field as unfilled and skips it. The natural-sort query processor still runs. It substitutes the public sortDirection property into {sortDirection} and passes the resulting string to orderByRaw().

That means an attacker does not need to defeat Laravel's check. The attacker needs to send a request that reaches the unvalidated natural-sort branch. The advisory identifies the standard Livewire update endpoint as the transport.

What an ORDER BY injection can change

ORDER BY is not just a display preference. Depending on the database driver, permissions and query construction, injected expressions can change which rows sort first, cause expensive queries, or expose data through conditional ordering.

A read-only reporting account limits the damage compared with an application account that can call stored procedures or modify data. The application must therefore fix the component and review its database role.

A sort control should accept a small enumeration of fields and directions. It should never interpolate a Livewire-bound property directly into SQL, even when another framework layer appears to validate it.

Remediation and regression tests

Upgrade PowerGrid to 6.10.4 or later. Search application code for custom natural-sort templates and any package code that calls orderByRaw() with component state. Replace raw placeholders with a whitelist mapping. If a custom driver needs a generated SQL expression, choose that expression from server-controlled code and bind values separately.

Add tests that submit sortDirection values outside the expected set through the Livewire endpoint. The test should prove that the request is rejected before a query reaches the database, not merely that the page looks normal. Also test empty sortField, because that condition caused the bypass in this advisory.

Review database logs for unusual ORDER BY clauses, repeated expensive sorts, or requests to /livewire/update that arrive with unexpected component payloads. Rotate database credentials only if the logs show a successful injection; changing them without evidence can break the application while leaving the vulnerable component online.

The fix is narrow, but the operational lesson is broader. Validation performed in one pipeline does not protect another pipeline that shares attacker-controlled state.

References

  • Livewire PowerGrid advisory GHSA-7fgc-3h6c-698r
  • NVD: CVE-2026-65971
  • Laravel query builder orderBy
Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.