GHSA-JR9Q-X7PJ-8QH9
Item access check accepts blocked ancestor folders: a user granted a subfolder reads the passwords of its parent folders
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-JR9Q-X7PJ-8QH9 divulgada · CVSS 6.5 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Security Disclosure: TeamPass — the item access check accepts a folder the user cannot access (CWE-863)
Summary
`getCurrentAccessRights()` authorized an item from the user's cached folder tree instead of the
user's folder scope. That cache deliberately also contains the folders the tree displays as
blocked — the non-accessible ancestors of an accessible folder — and the check only tested
membership, never the `disabled` flag that marks them.
A user granted access to a subfolder therefore obtained read access to the items stored in its
parent folders, up to the root: item content, passwords, and attachments. No role, no grant and
no interaction from another user is needed; the parent folder is simply the one the tree shows them
as blocked.
Details
When the folder tree is built, `buildVisibleFoldersFromTree()` (`app/sources/tree.php:758`) walks the
nodes the tree emitted and appends every one of them to the per-user cache
(`teampass_cache_tree.visible_folders`), marking the ones the user cannot access:
// app/sources/tree.php:802
'disabled' => (
!isset($accessibleFoldersSet[$folderId])
|| isset($readOnlyFoldersSet[$folderId])
) ? 1 : 0,A blocked ancestor is stored with `disabled = 1`; it is in the list because the tree has to draw the
path down to the folder the user *can* open.
`getCurrentAccessRights()` (`app/sources/items.queries.php:8751`) then authorized on that list:
// app/sources/items.queries.php:8799
$visibleFolders = getUserVisibleFolders($userId); // reads cache_tree.visible_folders
...
if (!in_array($treeId, array_column($visibleFolders, 'id'))) {
return getAccessResponse(false, false, false, false);
}
...
return getAccessResponse(false, true, $edit, $delete, $editionLock, $create);`array_column(..., 'id')` flattens the list to folder ids, so a blocked ancestor passes the test and
the function returns `access => true`. The rights that come with it are the ones
`getRoleBasedAccess()` resolves from `roles_values`, which holds no row for that folder, so `edit`,
`delete` and `create` stay `false`: the flaw grants read, not write.
Two consumers make that read worth a disclosure:
- `get_item_password` (`app/sources/items.queries.php`, `case 'get_item_password'`) gates on
- `userHasAccessToFile()` (`app/sources/main.functions.php:9466`) returns
Preconditions. An authenticated, non-administrator account holding at least one folder grant on a
folder that has an ancestor it cannot access, and a folder-tree cache already built for that account
— the normal state as soon as the user has loaded the Items page once. The fallback used while the
cache is empty or invalidated (`buildVisibleFoldersOnTheFly()`) rebuilds the list from
`roles_values` and `users_groups`, so it lists granted folders only and does not expose the
ancestor.
What is not affected. Items in folders that are not on the path between the root and a folder the
user can access are not reachable this way: they never enter that user's cached tree. Personal
folders of other users are not reachable either. Modification and deletion are refused, and an item
narrowed with the item-level restriction (`restricted_to` / `restriction_to_roles`) is refused before
this check on the web path — but see GHSA-gxc6-rgv6-wx99 for the REST API, which ignored that
restriction in the same releases.
Affected versions
All releases up to and including 3.2.2.3.
`getCurrentAccessRights()` has resolved item access from the cached tree since 3.1.2
(2024-10-03). Between 3.1.2 and the 3.1.7.x line the function had no membership test at all, so the
exposure is the same or wider there. The `disabled` flag that the check ignores was introduced with
the cache rewrite in 3.1.7.6.
TeamPass 2.x is out of scope: it does not have this code path.
Resolution
Fixed in 3.2.2.4 (commit `3b93a26fe`).
The folder is now checked against the scope TeamPass resolves for the request — accessible folders
and the user's own personal folders, minus explicit denials and other users' personal folders —
before any other rule, and the cached tree is no longer an authorization source:
// app/sources/items.queries.php, top of getCurrentAccessRights()
if (itemAccessFolderIsInScope(
$treeId,
(array) $session->get('user-accessible_folders'),
(array) $session->get('user-personal_folders'),
(array) $session->get('user-no_access_folders'),
(array) $session->get('user-forbiden_personal_folders')
) === false
) {
return getAccessResponse(false, false, false, false);
}The decision itself lives in the database-free module `app/sources/item_access_logic.php` and is
covered by `tests/Unit/ItemAccessLogicTest.php`.
Workaround for operators who cannot upgrade immediately
There is no configuration switch that closes this. Until you can upgrade:
- Do not store items directly in a folder that is an ancestor of a folder shared with users who must
- An item-level restriction (Restricted to on the item) is honoured before this check on the web
- Denying the folder to a role (forbidden folders) does not help: the vulnerable check never
Detection
The password reads are logged like any other. In the administration logs
(Monitoring → Logs → Items), or directly in `teampass_log_items`, look for `at_password_shown`,
`at_password_shown_edit_form`, `at_password_copied` and `at_shown` entries whose item belongs to a
folder the acting account has no grant on: a password cannot be obtained this way without one of
them. Attachment downloads are not logged (`app/sources/downloadFile.php` writes no audit
entry), so that part of the exposure cannot be reconstructed from the application logs; a web-server
access log showing `downloadFile.php` requests from the account is the only trace.
Credit
Found internally during the review of PR #5371.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistnilsteampassnet/teampass |
Sin parche | — | — | — |
Arsenal 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-jr9q-x7pj-8qh9Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
