HIGH · CVSS 3.1 8.1 EPSS 1.5% · 75th percentile CWE-89

CVE-2026-104129: pREST _groupby function-expression SQL injection (incomplete fix of CVE-2025-58450)

Published 2026-11-20 · Updated 2026-11-23 · Also known as GHSA-v9v2-98xq-627c, GO-2026-7020

Summary

The pREST API framework contains an incomplete fix for a SQL injection vulnerability in the _groupby parameter, allowing attackers to execute arbitrary SQL queries. Users of pREST version 1.5.5 and below, or pREST v2 before 2.4.0, should update immediately.

Who is affected

The vulnerability stems from the _groupby parameter being gated by an insufficient validation function that permits nested subqueries and UNION statements, unlike the correctly hardened _select parameter. An attacker with read access to the database can exploit this unauthenticated, provided the default configuration is enabled, to exfiltrate data or trigger a denial-of-service condition via functions like pg_sleep.

Exploitability

With a high CVSS base score of 8.1, the flaw is considered highly exploitable due to the low complexity of the attack and the lack of required privileges. The EPSS score of 0.004 indicates a low current probability of exploitation, and the vulnerability is not listed in the CISA Known Exploited Vulnerabilities catalog.

Remediation

How to check your project

Automated analysis of the published advisory data, generated 2026-11-23. Not human-reviewed; verify against the official advisory. How this works.

Affected packages

EcosystemPackageAffected versionsFixed inUpgrade
Go github.com/prest/prest >= 0, <= 1.5.5 not published -
Go github.com/prest/prest >= 0 (no fix published) not published -
Go github.com/prest/prest/v2 >= 0, < 2.4.0 2.4.0 go get github.com/prest/prest/[email protected]

CVSS 3.1 vector

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N

Attack vectorNetwork
Attack complexityLow
Privileges requiredLow
User interactionNone
ScopeUnchanged
ConfidentialityHigh
IntegrityHigh
AvailabilityNone

FAQ

Is this a new vulnerability or an old one?

This is an incomplete fix for a previous SQL injection vulnerability tracked as CVE-2025-58450, where the _groupby function was not properly secured during the initial remediation.

Does this require authentication to exploit?

In the default configuration, this injection is reachable without authentication, as the vulnerable code is processed after only a basic table read-permission check.

Can this vulnerability lead to remote code execution?

The provided record describes data exfiltration and denial-of-service via pg_sleep; it does not mention or confirm remote code execution.

Original advisory description
What the fix did and the gap ---------------------------- The v2.3.0 fix (commit e88dabb) routed the _select field through a strict new gate, sanitizeSelectField (postgres.go:947/1003/2097). The sibling _groupby path was left on the far weaker isSafeSQLExpression. adapters/postgres/postgres.go, GroupByClause (line 1946): a _groupby field that contains balanced parens takes the raw-SQL-expression branch (around lines 1999-2006), gated only by isSafeSQLExpression (line 2001, defined at 2043). That gate validates only the OUTERMOST function name against a 13-entry allowlist and uses a character allowlist that permits spaces, single quotes and parens. It blocks ;, --, /* , unbalanced parens and an outer pg_ prefix, but NOT a trailing UNION SELECT ..., a nested (SELECT ...) subquery, or an inner pg_ function. sanitizeSelectField (the CVE fix) rejects exactly those. Input and attacker ------------------- GET /{database}/{schema}/{table}?_select=id&_groupby=upper((SELECT+1))+UNION+SELECT+current_user. Sink trace: controllers/crud.go:131 calls GroupByClause unconditionally, concatenates it into sqlSelect (crud.go:133), executed at crud.go:176 with only the WHERE values parameterized. Reached after only a table read-permission check, passable unauthenticated in the default config (the same pipeline and attacker model as the anchor). Verification level ------------------ EXECUTED with negative controls (agent-run go test ./adapters/postgres/, PASS): isSafeSQLExpression wrongly accepts four payloads and GroupByClause emits them raw (e.g. GROUP BY upper((SELECT 1)) UNION SELECT current_user, and GROUP BY abs((SELECT 1 FROM pg_sleep(3)))); negative controls with ; and -- are rejected; and sanitizeSelectField (the CVE fix) rejects the exact UNION payload the sibling gate accepts. I independently re-confirmed at HEAD that _groupby is gated by isSafeSQLExpression (postgres.go:2001) while _select uses sanitizeSelectField (postgres.go:947). NOT verified: end-to-end UNION exfiltration against a live Postgres (needs column/type alignment, Postgres-gated). The pg_sleep DoS primitive is unconditional and needs no alignment; char-by-char blind extraction is constrained (commas are pre-split, and =/</> are blocked). Suggested fix ------------- Route _groupby through the same strict gate as _select (sanitizeSelectField-style: reject nested subqueries, UNION, inner pg_ functions, and anything past a single allowlisted function call), or parameterize/whitelist the group-by columns. Also checked and SOUND ---------------------- The other builders (WhereByRequest, OrderByRequest, JoinByRequest, CountByRequest, the jsonb/tsquery paths, ->>having, ident.IsValid) are sound; only the _groupby non-having function branch is the weak sibling. Advisory-source note -------------------- Five-source enumeration: CVE-2025-58450 (GHSA-p46v-f2x8-qp98, "Systemic SQL Injection", GO-2025-3941) and the newer GHSA-qvx3-q8vx-9q3c (which covers _select, fixed v2.3.0). Neither mentions _groupby / GROUP BY. The systemic advisory's own "nested queries can be performed" note supports the incomplete-fix framing. Not contested. Dedup ----- Dedup gate clean: no prest/prest blocking verdict in COVERED-INDEX, DISCLOSURE-INDEX or SCOUT-EXCLUDE. Tooling ------- AI assistance wsa used while investigating. The injection is executed-verified with negative controls (isSafeSQLExpression accepts four UNION/subquery/pg_sleep payloads that GroupByClause emits raw, while ;/-- are rejected and the _select gate rejects the same UNION payload), and I confirmed at HEAD that _groupby uses the weak isSafeSQLExpression while _select was hardened with sanitizeSelectField.

References

Source records: GHSA-v9v2-98xq-627c, GO-2026-7020 (OSV.dev) · EPSS by FIRST, 2026-11-26.