{"id":"CVE-2026-104129","aliases":["CVE-2026-104129","GHSA-v9v2-98xq-627c","GO-2026-7020"],"related":[],"kind":"vulnerability","state":"published","title":"pREST _groupby function-expression SQL injection (incomplete fix of CVE-2025-58450)","summary":"pREST (PostgreSQL REST) is an API that delivers an application on top of a Postgres database. Prior to 2.4.0, the vulnerable parameter is _groupby, handled by GroupByClause in adapters/postgres/postgres.go. adapters/postgres/postgres.go uses the weaker isSafeSQLExpression check for this function-expression branch instead of the stricter single-field validator used for _select. That check validates only the outer function name against a 13-function allowlist and permits nested subqueries, trailing UNION syntax, and inner pg_ functions. controllers/crud.go concatenates the GROUP BY expression while parameterizing only WHERE values, allowing attacker-controlled SQL structure into the clause. Default configuration permits unauthenticated access; a restricted installation may require a low-privilege table reader. UNION-based extraction requires compatible column counts and types and was not verified end to end, but a delay-producing function can cause denial of service without that alignment. This issue is fixed in 2.4.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"pREST (PostgreSQL REST) is an API that delivers an application on top of a Postgres database. Prior to 2.4.0, the vulnerable parameter is _groupby, handled by GroupByClause in adapters/postgres/postgres.go. adapters/postgres/postgres.go uses the weaker isSafeSQLExpression check for this function-expression branch instead of the stricter single-field validator used for _select. That check validates only the outer function name against a 13-function allowlist and permits nested subqueries, trailing UNION syntax, and inner pg_ functions. controllers/crud.go concatenates the GROUP BY expression while parameterizing only WHERE values, allowing attacker-controlled SQL structure into the clause. Default configuration permits unauthenticated access; a restricted installation may require a low-privilege table reader. UNION-based extraction requires compatible column counts and types and was not verified end to end, but a delay-producing function can cause denial of service without that alignment. This issue is fixed in 2.4.0.","source":"cvelist"},{"lang":"en","text":"What the fix did and the gap\n----------------------------\nThe 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.\n\nInput and attacker\n-------------------\nGET /{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).\n\nVerification level\n------------------\nEXECUTED 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).\n\nSuggested fix\n-------------\nRoute _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.\n\nAlso checked and SOUND\n----------------------\nThe 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.\n\nAdvisory-source note\n--------------------\nFive-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.\n\nDedup\n-----\nDedup gate clean: no prest/prest blocking verdict in COVERED-INDEX, DISCLOSURE-INDEX or SCOUT-EXCLUDE.\n\nTooling\n-------\nAI 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.","format":"markdown","source":"ghsa"},{"lang":"en","text":"pREST _groupby function-expression SQL injection (incomplete fix of CVE-2025-58450) in github.com/prest/prest","format":"markdown","source":"go"}],"published":"2026-11-19T18:49:03.472Z","modified":"2026-11-23T20:40:45.638Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N","score":8.1,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N","score":8.1,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N","score":8.1,"rating":"HIGH"}],"cwes":["CWE-89"],"affected":[{"ranges":[{"version":"< 2.4.0","status":"affected"}],"vendor":"prest","product":"prest","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","lastAffected":"1.5.5"}],"ecosystem":"Go","package":"github.com/prest/prest","purl":"pkg:golang/github.com/prest/prest","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"2.4.0"}],"ecosystem":"Go","package":"github.com/prest/prest/v2","purl":"pkg:golang/github.com/prest/prest/v2","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected"}],"ecosystem":"Go","package":"github.com/prest/prest","purl":"pkg:golang/github.com/prest/prest","source":"go"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"2.4.0"}],"ecosystem":"Go","package":"github.com/prest/prest/v2","purl":"pkg:golang/github.com/prest/prest/v2","source":"go"}],"references":[{"url":"https://github.com/prest/prest/security/advisories/GHSA-v9v2-98xq-627c","tags":["advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/prest/prest/pull/1014","tags":["fix","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/prest/prest/commit/084348fa82701b098492fc520557ff290b7691e2","tags":["fix","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/prest/prest/commit/73e4b2aea81e2dbd33942efcb1a313fe3b151a41","tags":["fix","web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/prest/prest/releases/tag/v2.4.0","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-104129","tags":["advisory"],"sources":["ghsa","go"]},{"url":"https://github.com/prest/prest","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"total","date":"2026-11-19T19:29:22.412Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-104129","url":"https://www.cve.org/CVERecord?id=CVE-2026-104129","licence":"CVE Terms of Use","modified":"2026-11-19T19:29:30.372Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-v9v2-98xq-627c","url":"https://github.com/advisories/GHSA-v9v2-98xq-627c","licence":"CC-BY-4.0","modified":"2026-11-23T20:40:45.638Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-7020","url":"https://pkg.go.dev/vuln/GO-2026-7020","licence":"CC-BY-4.0","modified":"2026-11-23T20:30:17.320Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-104129","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-104129","licence":"Public domain","modified":"2026-11-19T20:17:14.067Z"}],"updatedAt":"2026-11-25T22:59:52.171Z","epss":{"score":0.01503,"percentile":0.74641,"date":"2026-11-30T12:00:22.000Z"}}