llamaCVEVulnerability Intelligence
/
Advisory · GitHub · Packagist · phpmyfaq/phpmyfaq

GHSA-5HX6-C293-588H

PostgreSQL search backend declares the wrong LIKE ESCAPE character, so the wildcard-escaping fix is inert on that backend

Parche disponible
Descargar PNG JSON
CVSS 3.1
5.3
Media
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L Fuente: GitHub
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche1 versión4.1.7
Exposición108 dDesde la divulgación, 4 ago 2026, 1:06 p. m.
Detección108 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada
Explotación
Remediación
Monitoreo
Detectada +1
4 ago 26
20 nov 26
21 nov 26
4 ago 26
31 ago 26
27 sept 26
24 oct 26
21 nov 26
FechaFaseEventoDetalle
Divulgación Publicada GHSA-5HX6-C293-588H divulgada · CVSS 5.3 (GitHub)
Monitoreo Detectada Ingresó al índice
Monitoreo Verificada Última verificación contra las fuentes
Resumen
Descripción del advisory
Texto original · GitHub · en inglés
Summary

PostgreSQL search backend declares the wrong LIKE ESCAPE character, so the wildcard-escaping fix is inert on that backend

Affected versions and vulnerable location

  • Confirmed on default branch `main` at `5d4a975cdc53dca26383f2b8a56596b1272fcac2` (tag `4.1-nightly-2026-07-30`).
  • Sink: `phpmyfaq/src/phpMyFAQ/Search/Database/Pgsql.php:77` builds `(%s) ILIKE ('%%%s%%') ESCAPE '='`.
  • Escaper: `phpmyfaq/src/phpMyFAQ/Search/SearchDatabase.php:311` `escapeLikeWildcards()` escapes with the `|` prefix: `str_replace(['|', '%', '_'], ['||', '|%', '|_'], $term)`.
  • Called at `phpmyfaq/src/phpMyFAQ/Search/Database/Pgsql.php:88`.
  • Correct sibling for contrast: `phpmyfaq/src/phpMyFAQ/Search/Database/PdoPgsql.php:77` declares `ESCAPE '|'`, which matches the escaper.

Root cause

`escapeLikeWildcards()` neutralizes user-supplied `%` and `_` by prefixing them with `|` (turning `%` into `|%`), which relies on the SQL statement declaring `ESCAPE '|'`. The PDO PostgreSQL backend does exactly that (`PdoPgsql.php:77`). The native `pgsql`-extension backend instead declares `ESCAPE '='` (`Pgsql.php:77`). Under `ESCAPE '='`, PostgreSQL treats `|` as an ordinary literal, so:

  • The inserted `|` characters become literal noise in the pattern.
  • The user's original `%` and `_` are never escaped and remain active LIKE wildcards.

The escaping is therefore a no-op on the native driver. This is a broken fix rather than a missing one: the same term is correctly escaped on the PDO driver and mis-escaped on the native driver purely because of the mismatched `ESCAPE` character.

Attacker model and reachability

  • Unauthenticated. The public FAQ search form drives `SearchService` -> the DB-type-selected backend. When the site runs PostgreSQL on the native `pgsql` PHP extension (not PDO), `Search\Database\Pgsql::search($searchTerm)` runs.
  • `$searchTerm` is the public `search` request parameter. The only gate before the ILIKE path is `is_numeric($searchTerm)` at `Pgsql.php:60` (the solution-id shortcut); any non-numeric term reaches the vulnerable pattern.
  • Impact is limited to LIKE-wildcard injection: quotes are still escaped by `getDb()->escape()`, so there is no quote-breaking SQL injection and no data exfiltration beyond match broadening. An attacker submits `%`/`_` to force maximally broad pattern matches and expensive sequential scans (a cheap way to drive load / a mild denial-of-service on a large FAQ corpus), the same class the maintainer published as GHSA-gcp9-5jc8-976x but on a distinct backend with a distinct root cause.

Reproduction

Source-verified. No runtime query was executed against a live PostgreSQL instance in this pass. Command output showing the mismatch:

rg -n "ESCAPE '='|ESCAPE '\|'|escapeLikeWildcards" \
  phpmyfaq/src/phpMyFAQ/Search/Database/Pgsql.php \
  phpmyfaq/src/phpMyFAQ/Search/Database/PdoPgsql.php \
  phpmyfaq/src/phpMyFAQ/Search/SearchDatabase.php

Observed:

Search/Database/Pgsql.php:77:      (%s) ILIKE ('%%%s%%') ESCAPE '='
Search/Database/Pgsql.php:88:      self::escapeLikeWildcards($this->configuration->getDb()->escape($searchTerm)),
Search/Database/PdoPgsql.php:77:   (%s) ILIKE ('%%%s%%') ESCAPE '|'
Search/SearchDatabase.php:311:     return str_replace(['|', '%', '_'], ['||', '|%', '|_'], $term);

The escaper prefixes with `|`; the native backend declares `ESCAPE '='`; the PDO backend declares `ESCAPE '|'`. Only the PDO backend's declaration matches the escaper.

Suggested fix

Change the native backend's clause at `Pgsql.php:77` from `ESCAPE '='` to `ESCAPE '|'` so it matches `escapeLikeWildcards()` and the PDO backend. Alternatively, centralize the escape character as a constant shared by the escaper and every backend so the two cannot drift again. A regression test that runs a `%`/`_`-bearing term through both PostgreSQL backends and asserts identical, wildcard-neutralized results would catch this class.

Severity and CVSS reasoning

Suggested severity: Low.

Suggested CVSS:3.1 vector: `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L` (5.3) if the search corpus is large enough for wildcard-forced scans to matter, otherwise `A:N` (0.0 practical). I suggest Low overall: no confidentiality or integrity impact (quotes remain escaped), only pattern-match broadening and query-cost amplification, and only on deployments using the native `pgsql` extension rather than PDO.

How I found it and a note on tooling

I audited every `sprintf`/concatenation SQL sink in the tree; all quote-relevant sinks route through `->escape()`, integer casts, or identifier whitelists, so no classic SQL injection remains. The one broken control I found is this LIKE-escape mismatch: the wildcard escaper and the native PostgreSQL backend disagree on the escape character, which I confirmed by diffing the two PostgreSQL backends against the shared escaper. I used AI assistance for the sink sweep and drafting and manually verified the three cited lines at HEAD. Verification is source-only; I did not run the query against a live PostgreSQL database.

Vector CVSS 3.1

Desglose de métricas

Opción resaltada = valor del vector · izquierda = peor caso · GitHub
Vector de ataqueAV:N
RedAdyacenteLocalFísica
ComplejidadAC:L
BajaAlta
PrivilegiosPR:N
NingunoBajosAltos
InteracciónUI:N
NingunaRequerida
AlcanceS:U
CambiadoSin cambio
ConfidencialidadC:N
AltoBajoNinguno
IntegridadI:N
AltoBajoNinguno
DisponibilidadA:L
AltoBajoNinguno
Versiones

Rangos afectados

Afectada Corregida
phpmyfaq/phpmyfaq≥ 4.2.0-alpha < 4.1.7
4.1.7
4.2.0-alpha
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
Packagistphpmyfaq/phpmyfaq
Corregida 4.1.7 — —
Versiones corregidas4.1.7
Explotación

Arsenal público

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

Referencias
Advisoryhttps://github.com/thorsten/phpMyFAQ/security/advisories/GHSA-5hx6-c293-588h

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