/

CVE-2026-104129

Severity:

HIGH RISK

(8.1)

SQL Injection (CWE-89) in pREST PostgreSQL REST API _groupby

CVE-2026-104129

Received

Vulnerability type

Category:

SQL Injection

CWE:

CWE-89

Impact:

SQL injection, with potential data exposure and denial of service

Severity:

HIGH RISK

(8.1)

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

pREST's _groupby handling can allow attacker-controlled SQL structure into a PostgreSQL query because its validation does not sufficiently constrain function expressions. Depending on access controls and the expression used, this may expose data or cause denial of service; default configuration permits unauthenticated access.

Affected context

The issue affects pREST versions before 2.4.0 in the PostgreSQL adapter's handling of the _groupby parameter. The function-expression branch uses a weaker check than the validator used for _select, while the CRUD controller concatenates the GROUP BY expression into the query rather than parameterizing its SQL structure.

Exploit preconditions

  • Attack surface: A pREST endpoint that processes _groupby for a PostgreSQL query.
  • Required access: Default configuration permits unauthenticated access; restricted installations may require a low-privilege account with table-read access.
  • Trigger point: The application builds and executes a query containing the supplied GROUP BY expression.
  • Why exploitation is possible: Validation checks the outer function name but can permit nested subqueries, trailing UNION syntax, and inner pg_ functions; parameterization of WHERE values does not protect this SQL clause.
  • Limitations: UNION-based extraction depends on compatible column counts and types and was not verified end to end. A delay-producing function may cause denial of service without that alignment.

Why this happens

This is a SQL injection flaw (CWE-89). The adapter applies a comparatively weak expression check to the _groupby function-expression branch, validating only the outer function against an allowlist while leaving parts of the expression insufficiently constrained. The controller then concatenates that expression into SQL, allowing input to alter query structure; parameterized WHERE values do not make separately concatenated clauses safe.

Potential impact

  • An attacker may be able to cause SQL execution beyond the intended GROUP BY expression.
  • Data could be exposed if query manipulation succeeds and database permissions allow access.
  • Delay-producing expressions could cause slow queries or denial of service.
  • The practical impact may be limited by endpoint access controls, database privileges, and query compatibility requirements.

General mitigation guidance

Defensive patterns focus on preventing untrusted input from defining SQL structure:

  • Prefer fixed, application-defined GROUP BY choices or map input to a strict set of approved identifiers and expressions.
  • Reject unsupported expression forms rather than relying only on an outer function-name allowlist.
  • Use parameter binding for data values, while recognizing that SQL identifiers and clause structure generally require safe mapping or query construction rather than value parameters.
  • Reduce trust in request parameters and apply strict validation before query construction.
  • Restrict database roles to the minimum permissions required and limit access to sensitive endpoints.

How teams detect issues like this

  • Use static analysis to find request-derived values concatenated into SQL clauses, especially GROUP BY and other structural query components.
  • Review validators for differences between related parameters, such as _groupby and _select, and check whether validation covers the complete expression rather than only its outer function.
  • Monitor query construction and database activity for unexpected subqueries, UNION operations, or unusually long-running requests.
  • Enforce code-review and CI policies requiring safe query builders or approved mappings for SQL structure.

Sources

SourceLink
github.comgithub.com/prest/prest/commit/084348fa82701b098492fc520557ff290b7691e2
github.comgithub.com/prest/prest/commit/73e4b2aea81e2dbd33942efcb1a313fe3b151a41
github.comgithub.com/prest/prest/pull/1014
github.comgithub.com/prest/prest/releases/tag/v2.4.0
github.comgithub.com/prest/prest/security/advisories/GHSA-v9v2-98xq-627c

Frequently asked

questions

It may be reachable through an exposed pREST API endpoint that accepts _groupby. Default configuration permits unauthenticated access, though deployments with tighter controls may require an authorized table reader.

Access depends on deployment configuration. In the default configuration, authentication is not required; restricted installations may require low-privilege read access.

Do not concatenate request-controlled SQL expressions. Map accepted choices to fixed, application-defined expressions and reject anything outside that set.

Treat SQL structure as trusted application logic, validate the full input against a narrow schema, use parameter binding for data values, and apply least-privilege database permissions.

Find out what's already
exploitable in your codebase.