GHSA-6Q46-MFMG-F8PH
Network whitelist and blacklist bypass through unfiltered login and AJAX requests and a forged X-Forwarded-For header
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-6Q46-MFMG-F8PH divulgada · CVSS 7.1 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
The network whitelist and blacklist (*Administration → Options → Networks*) did not protect the application. They were checked when a page was opened and by the REST API only. Login processing, every AJAX action and file downloads never checked them, so a user connecting from an excluded address could authenticate and then read and change data through the AJAX handlers. Behind a reverse proxy, TeamPass also took the client address from the leftmost value of `X-Forwarded-For`, a value the client can write itself, so a client could claim an allowed address. When the rule table could not be found, filtering was silently switched off.
Details
Paths and line numbers are those of 3.2.4.3.
- Incomplete enforcement. The only web-side check is in `app/sources/core.php:50-52` (`teampassGetClientIpForSecurity()`, `teampassLoadNetworkAclRules()`, `teampassEvaluateNetworkAclAccess()`). `core.php` is loaded by the page front controller only (`public/index.php:168`). The login handler (`app/sources/identify.php`), the AJAX handlers (`app/sources/*.queries.php`) and the download entry points do not load it, so they never evaluate the lists. A client whose address is refused on page load can still post its credentials to the login handler, and the resulting session works with every AJAX action, from any address. A session opened from an allowed network also keeps working after the client leaves it. The REST API (`app/api/index.php:106-108`) does evaluate the lists.
- Client-controlled address behind a reverse proxy. In *Reverse proxy / WAF* mode, when `REMOTE_ADDR` is a trusted proxy, `teampassGetClientIpForSecurity()` (`app/sources/main.functions.php:4917`) reads the configured header through `teampassExtractClientIpv4FromHeader()` (`:4861`), which returns the first valid IPv4 address of the list. A proxy configured with `proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;`, the setting the TeamPass documentation recommended, appends the real client address to the header the client sent. A client sending `X-Forwarded-For: <allowed address>` is therefore detected as that address, and passes the whitelist (or escapes the blacklist) on the page and API checks too. The same detected address is what `getClientIpServer()` (`:4267-4273`) returns in this mode, so the logs and the per-address brute-force counters recorded a client-chosen value.
- Fail open. `teampassEvaluateNetworkAclAccess()` (`:5006`) returns `allowed` whenever `teampassNetworkAclTableExists()` is false, even with a list enabled, and `teampassLoadNetworkAclRules()` returns empty lists in the same case.
Both lists come from 3.1.7.1. Points 1 and 2 are present since that release.
Credits: found and fixed by @guerricv (PR #5464).
Impact
An attacker holding valid credentials (for example stolen or phished ones) could use them from a network the administrator had excluded, and read every password the account can access or change its items, despite an enabled whitelist or blacklist. Behind a reverse proxy that appends to `X-Forwarded-For`, the attacker could also pass the page and API checks by forging the header, and choose the address recorded in the logs and counted by the brute-force protection.
Authentication, authorization and encryption are not bypassed: the attacker gets exactly the rights of the account used. Installations with both lists disabled are not affected by points 1 and 3. Point 2 only concerns *Reverse proxy / WAF* mode with the proxy listed in *Trusted proxies*.
Patches
Fixed in 3.2.4.4:
- the lists are enforced in the shared HTTP bootstrap (`app/sources/network_acl_guard.php`, called at the end of the `main.functions.php` bootstrap) before any authentication or action, for pages, login processing, AJAX actions, downloads and the API, CORS preflight requests included. The installation and upgrade scripts and the Secure Send recipient page, which carry their own authorization, are the only exceptions;
- `X-Forwarded-For` is read from right to left, skipping the addresses listed in *Trusted proxies*, and the first address that is not listed is used. An invalid or IPv6 hop, or a missing header, gives no usable address, and an enabled list then refuses access;
- an enabled list whose rule table is missing or unreadable refuses every request with `503`.
The release notes list the configuration to check before upgrading (trusted proxies, Nginx `X-Forwarded-For` setting).
Workarounds
Until the upgrade, enforce the address restriction on the web server, the reverse proxy or a firewall in front of TeamPass, for every path. On a single Nginx proxy facing the Internet, replace `proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;` with `proxy_set_header X-Forwarded-For $remote_addr;`, so the header carries only the address the proxy saw; with several proxies, the outer one must drop the forwarding headers sent by the client.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistnilsteampassnet/teampass |
Corregida | 3.2.4.4 | — | — |
3.2.4.4Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/nilsteampassnet/TeamPass/security/advisories/GHSA-6q46-mfmg-f8phLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
