llamaCVEVulnerability Intelligence
/
Advisory · GitHub · Packagist · egroupware/egroupware

GHSA-23HJ-XM9R-GWX6

Authenticated SQL injection via col_filter string-key in Base::search() !'' branch (sibling of GHSA-rvxj not covered by its fix)

Texto original en inglés · Ver en español

Parche disponible
Descargar PNG JSON
CVSS
—
high
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche2 versiones23.1.20260710 · 26.7.20260710
Exposición98 dDesde la divulgación, 14 ago 2026, 6:27 a. m.
Detección96 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Modificada
Explotación
Remediación
Monitoreo
Detectada +1
14 ago 26
19 ago 26
18 nov 26
21 nov 26
14 ago 26
8 sept 26
2 oct 26
27 oct 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-23HJ-XM9R-GWX6 divulgada
Divulgación Modificada Última actualización del registro
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés

[HIGH] Authenticated SQL injection via col_filter string-key in `Base::search()` `!''` branch (sibling of GHSA-rvxj, uncovered by its fix)

  • CWE: CWE-89 SQL Injection.
  • CVSS v3.1: `AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:L` = 8.1 High
  • Affected component:
  • Sink: `api/src/Storage/Base.php::search()` filter loop, line 891 —
  • Emitter: `api/src/Db.php::column_data_implode()` line 1772 —
  • Entry: `api/src/Etemplate/Widget/Nextmatch.php::ajax_get_rows()` → app `get_rows` →
  • Relationship: Sibling of GHSA-rvxj-7f72-mhrx (Nextmatch col_filter type-juggling). That

## Summary
The Nextmatch widget forwards the client-controlled `col_filter` map (both keys and values) into the
storage layer. The GHSA-rvxj fix removes integer-numeric keys (the type-juggling vector) but leaves
arbitrary string keys intact. In `Base::search()`, a filter whose value is the special string
`!''` takes a branch that concatenates the filter key directly into the SQL WHERE clause:

foreach($data2db_filter as $col => $val) {
    if ($val !== '') {
        if (!is_int($col) && ($c = array_search($col,$this->db_cols))) { $col = $this->table_name.'.'.$c; }
        if (is_int($col))            { $db_filter[] = $val; }
        elseif ($val === "!''")      { $db_filter[] = $col." != ''"; }   // <-- raw key
        else                         { $db_filter[$col] = $val; }
    }
}

For a key that is not a real column, `array_search` fails, so `$col` stays as the attacker's raw
string; the `!''` branch appends `"<payload> != ''"` with an integer array key. `column_data_implode`
emits integer-keyed elements verbatim (no `quote`, no `name_quote`, and the string-key "unknown
column" `InvalidSql` throw is bypassed). The payload lands unescaped in the query.

## Reachability (hop-by-hop)
1. Authenticated user (no admin). Open any list backed by the default storage `get_rows`
(e.g. resources list `resources.resources_ui.get_rows` → `resources_bo::get_rows` →
`so->get_rows`; timesheet; any so_sql app not overriding `get_rows`).
2. `Nextmatch::ajax_get_rows($id,$range,$filters,…)` — `filters['col_filter']` is attacker JSON.
Guards: `Nextmatch.php:413` and `:1365` strip only integer keys. A string key survives. `order`/`sort`/`search`
are separately whitelisted and are not the vector. *(guard bypassed — key is a string)*
3. App `get_rows` leaves unknown col_filter keys untouched (`resources_bo` line 187 merges into,
never rebuilds, col_filter) and calls `so->get_rows` → `Base::get_rows:1653`:
`search($criteria, …, $query['col_filter'], …)` — col_filter passed verbatim. *(no key filtering)*
4. `Base::search` filter loop → `!''` branch → raw key concatenation (int-keyed).
5. `db->select(… $where …)` → `column_data_implode(' AND ', $where, True, …)` → int-key branch emits raw.
6. Injected SQL executes.

## Root cause
Trusting col_filter keys as safe column identifiers. The `!''` convenience branch builds SQL by
string concatenation of the key without validating it against the table schema or quoting it, and the
integer-keyed emit path in `column_data_implode` has no safety net.

## Impact
UNION-based extraction of arbitrary tables, notably `egw_accounts.account_pwd` (password hashes) and
session/credential tables → full authentication compromise. Blind/boolean and error-based techniques
also apply. Stacked write statements are blocked by the driver, capping direct integrity/availability
impact.

## Preconditions
- Any authenticated non-admin session; default configuration; a list view using the default so_sql
`get_rows` (resources, timesheet, and others).

## Evidence
- `api/src/Storage/Base.php:876-895` (filter loop, `!''` branch line 891), `:1653` (col_filter → search).
- `api/src/Db.php:1772-1775` (int-key raw emit).
- `api/src/Etemplate/Widget/Nextmatch.php:413,1365` (int-key-only strip — the incomplete guard).
- `resources/inc/class.resources_bo.inc.php:187-188` (col_filter passthrough to `so->get_rows`).

## Proof of Concept (safe, local; generated-SQL marker)
`scratchpad/sqli_poc.php` reproduces the `Base::search` filter loop and the `column_data_implode`
int-key branch verbatim. Input:
`col_filter = { "0=1) UNION SELECT account_lid,account_pwd,3,4,5,6,7 FROM egw_accounts -- " : "!''" }`
(after applying the real int-key strip, the string key survives). Output SQL:

SELECT ts_id,ts_title,ts_owner FROM egw_timesheet
WHERE (0=1) UNION SELECT account_lid,account_pwd,3,4,5,6,7 FROM egw_accounts --  != '')

The injected UNION reaches the WHERE clause unescaped and the trailing `-- ` comments out the
appended `!= '')`. Marker confirmed. No live database was queried.

## Adversarial re-read
- *Does `data2db($filter)` drop/alter the malicious key?* `data2db` maps only known timestamp/columns;
an unknown key is identity — it passes through. (Verified: non-column key untouched.)
- *Does `array_search($col,$db_cols)` neutralize it?* Only if the key matches a real column; the SQL
payload is not a column name, so `array_search` returns false and `$col` is left raw.
- *Does `column_data_implode` throw "unknown column" for it?* That throw is only on the string-key
path; the `!''` branch produced an integer key, which takes the verbatim-emit branch. Confirmed.
- *Is the value `!''` filtered by the Nextmatch fix?* No — only keys are filtered (and only int keys);
values are untouched.
- *Do the apps rebuild col_filter?* resources_bo merges into col_filter (line 187) and never strips
unknown keys; Base::get_rows forwards them verbatim.
- Result: no concrete blocker. CONFIRMED.

## Remediation
In the `!''` branch, validate `$col` against `$this->db_cols`/`$this->table_def` and reject or
`name_quote` it (never concatenate a raw key). Additionally, at the Nextmatch boundary validate
col_filter keys against the widget's known columns/schema rather than only stripping integer keys;
and add a schema check to the integer-keyed branch of `column_data_implode`.

## Confidence
High — sink and emitter reproduced verbatim; injected SQL generated. Live DB confirmation of the
UNION read requires a running instance with a populated `egw_accounts`.

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Versiones

Rangos afectados

Afectada Corregida
egroupware/egroupware< 23.1.20260710
egroupware/egroupware< 26.7.20260710
23.1.20260710
26.7.20260710
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
Packagistegroupware/egroupware
Corregida 23.1.20260710, 26.7.20260710 — —
Versiones corregidas23.1.2026071026.7.20260710
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://github.com/EGroupware/egroupware/security/advisories/GHSA-23hj-xm9r-gwx6

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.