Skip to content
SQL injection Write-up Intermediate

ElectricSQL database takeover vulnerability found by AI

The order_by parameter in ElectricSQL's Shape API was vulnerable to error-based SQL injection, allowing any authenticated user to read, write, and destroy the full contents of the underlying PostgreSQL database. An attacker could also escalate privileges and cause denial of service.

casco.com

Published on casco.com

Written by Rene Brandel on Mon Apr 13 2026

Rene Brandel, on casco.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The validation function for order_by only explicitly allowed column and parameter references but had a catch-all clause that accepted all other SQL syntax tree nodes, and the raw user input was then concatenated directly into the SQL query.

Impact

An authenticated attacker could read, modify, or delete any data in the database, escalate privileges, and cause denial of service, affecting all tenants if application-level isolation is used.

What the attacker needed

Authenticated user; access to Shape API

The fix

The ElectricSQL team added explicit handlers for dangerous AST node types, and the fix was released and deployed.

How it was found

  1. Send a request to the Shape API with a crafted order_by value containing a SQL expression.
  2. The server parses the order_by into an AST and validates it, but the catch-all clause allows dangerous node types.
  3. The raw user string is concatenated into the SQL query and executed by PostgreSQL.
  4. PostgreSQL returns an error message that includes the result of the injected expression, leaking data.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

ElectricSQL lets apps subscribe to database changes. The order_by field, which sorts results, was not properly checked, so a user could sneak in extra database commands. This let them see or change any data in the database.

What is SQL injection?

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.