/

CVE-2026-82028

Severity:

HIGH RISK

(8.8)

SQL Injection (CWE-89) in Magistrala Reader Services

CVE-2026-82028

Deferred

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

Unauthorized Database Access and Remote Code Execution

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Magistrala before 1.0.0 contains a SQL injection vulnerability in its timescale-reader and postgres-reader HTTP API services. An authenticated attacker, including one with a self-registered account where registration is enabled, may manipulate the format query parameter to execute unintended SQL and access or alter data beyond the intended tenant boundary.

Affected context

The vulnerability occurs in deployments using Magistrala's timescale-reader or postgres-reader HTTP APIs when the format query parameter is incorporated into a SQL FROM clause without parameterization or identifier quoting. Risk is higher when attackers can create accounts, the database role has superuser-level privileges, and the affected services can reach sensitive database files or loadable components.

Exploit preconditions

  • Attack surface: HTTP API endpoints exposed by the timescale-reader or postgres-reader services
  • Required access: An authenticated account; self-registration may make account creation possible where enabled
  • Trigger point: Processing a request containing the format query parameter
  • Why exploitation is possible: User-controlled input is inserted into a SQL FROM clause without safe parameterization or identifier validation
  • Privilege condition: The impact may be amplified when the application connects using a PostgreSQL superuser or an equivalently privileged role

Why this happens

The underlying bug is SQL injection caused by constructing a SQL statement with untrusted input in a structural database position. A format parameter intended to identify a relation or query source is interpolated directly into the FROM clause rather than being constrained to approved identifiers or represented through a safe query-building mechanism. This behavior maps to CWE-89 because attacker-controlled input can alter the intended SQL command and its execution semantics.

Potential impact

  • Attackers may read data belonging to other tenants
  • Attackers could access sensitive PostgreSQL system information, including password hashes
  • Attackers may modify or delete database records
  • The database process may read from or write to arbitrary files, subject to operating-system permissions
  • Attackers could execute code as the PostgreSQL operating-system user if database and host conditions permit
  • The broader service or platform may be compromised

General mitigation guidance

Mitigation generally focuses on removing user-controlled SQL structure and

reducing the privileges available to the affected services.

Common defensive patterns include:

  • Use parameterized queries for values and allowlisted, safely quoted identifiers for structural database elements
  • Replace free-form format expressions with a finite set of application-defined options
  • Validate input against an explicit schema before query construction
  • Use dedicated database roles with only the permissions required by each reader service
  • Avoid database superuser credentials for application connections
  • Restrict database file access, extension loading, and operating-system capabilities
  • Limit account self-registration and API exposure according to deployment needs
  • Apply tenant-isolation checks independently of client-supplied query parameters

How teams detect issues like this

Detection approaches may include:

  • Static analysis rules for string interpolation, concatenation, or formatting

used to build SQL statements

  • Code review checks for request parameters appearing in SQL identifiers,

table names, clauses, or other query structure

  • Testing that verifies unexpected format values are rejected and that tenant

boundaries remain enforced

  • Database audit logging for unusual query structures, system catalog access,

file functions, privilege changes, or extension-loading activity

  • API monitoring for repeated requests containing anomalous format values or

cross-tenant access patterns

  • Policy enforcement requiring parameterized queries, approved query builders,

and least-privilege database roles

Automated code-review and application-security tools may help identify

injection-prone query construction, but should be supplemented with runtime

authorization and database-privilege checks.

Sources

SourceLink
github.comgithub.com/absmach/magistrala/pull/3581
github.comgithub.com/absmach/magistrala/pull/3581/changes/aac9461aa561c3de7aa9a0dc814ac84c602e0cf9
github.comgithub.com/absmach/magistrala/releases/tag/v1.0.0
vulncheck.comvulncheck.com/advisories/magistrala-sql-injection-via-format-parameter-in-reader-api

Frequently asked

questions

It can be exploitable through the affected HTTP APIs when they are reachable by

an attacker who has an authenticated account. The practical scope depends on

network exposure, authentication policy, and database permissions.

No. The described attack requires authentication, and a self-registered account

may be sufficient where account registration is enabled. The resulting impact

depends heavily on the privileges of the database role used by the service.

Do not interpolate request-controlled text into SQL structure. Use allowlisted

application-defined formats, safe identifier handling, parameterized values,

and a narrowly privileged database role.

Combine secure query-construction standards with code review and static

analysis, negative security tests, tenant-isolation checks, database auditing,

and controls that prevent application services from using superuser

credentials.

Find out what's already
exploitable in your codebase.