GHSA-47XG-W656-J4V4
Stored XSS in Item Login Field via #card-item-login .html()
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-47XG-W656-J4V4 divulgada · CVSS 8.7 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Stored XSS in Item Login Field via #card-item-login .html()
Summary
When a non-administrator user opens an item's detail view, the item's login
field is rendered with jQuery's .html() using the raw value returned by the
show_details_item endpoint. The login is persisted with the PHP filter
FILTER_SANITIZE_FULL_SPECIAL_CHARS, which only HTML-entity-encodes the value;
the client-side decode path (purifyData, invoked inside decodeQueryReturn)
decodes those entities back to live markup before the value reaches the sink.
A login value containing an <img onerror> payload therefore renders as
executable HTML in the login card of every non-administrator who opens the
item. The login field is not covered by the client-side special-character
regex that protects the tags field, and the server applies no AntiXSS
stripping to the login, so the payload is plantable entirely through the
normal item creation / edit form.
Adjacent fields in the same detail block are defended correctly: the label
uses htmlEncode(), and the email and url fields use .text(). The login field
was missed, leaving it as an inconsistent, unencoded .html() sink.
Cross-user reach: the show_details_item handler sets show_details = 0 (and
omits the login) only when the requesting user is an administrator opening a
non-personal item. Any non-administrator with read access to the folder
receives show_details = 1 and the raw login, so any colleague who opens the
poisoned item executes the payload.
Affected Version
TeamPass 3.1.7.6
The same sink is present in the current git branch 3.2.1.6
(app/pages/items.js.php renders the login via
$('#card-item-login').html(data.login)).
PoC
The PoC requires the two accounts used below:
administrator : admin / admin123!
non-admin : deleter / deleter123! (write access to the shared
folder "E2E Folder", id 9002)
------------------------------------------------------------------
Step 1 - Attacker plants the payload (browser: New Item form)
------------------------------------------------------------------
1. Open teampass and log in as the non-administrator
(deleter / deleter123!).
2. Open the Items page.
(If a "generate the keys database for your account" prompt appears,
dismiss it; it does not affect item creation or the login field, which
is not encrypted.)
3. In the left folder tree, select the shared folder "E2E Folder" (id 9002).
4. Click "New item".
5. In the new-item form, fill:
Label = xssE2E
Login = <img src=x onerror=document.body.dataset.xssLogin=1>
Password = (any value that satisfies the folder complexity policy)
Leave Tags empty and click Save.
The server stores the login HTML-entity-encoded only
(FILTER_SANITIZE_FULL_SPECIAL_CHARS in sources/items.queries.php, case
new_item); no AntiXSS stripping is applied, and no database operation or
crafted request was used -- the value was typed into the standard login
input:
stored login = <img src=x onerror=document.body.dataset.xssLogin=1>
------------------------------------------------------------------
Step 2 - Victim triggers the payload (browser: open item)
------------------------------------------------------------------
1. Log in as a non-administrator who can see folder 9002 (the same "deleter"
account, or any colleague with read access).
2. Open the Items page, dismiss the keys prompt, and select folder 9002.
3. Click the item row "xssE2E" to open its detail view.
The application's own Details handler calls the show_details_item endpoint
and renders the login with the real sink in pages/items.js.php:
$('#card-item-login').html(data.login);
decodeQueryReturn runs purifyData() on the value first, which decodes the
HTML entities back to a live <img onerror> element string; .html() then
parses it as live DOM, so the onerror handler executes.
Expected result (observed in the browser DOM only, no database access):
document.body.dataset.xssLogin === "1"
document.querySelector('#card-item-login').innerHTML
=== '<img src="x" onerror="document.body.dataset.xssLogin=1">'
A live <img> element is present in the login card, confirming execution
through the application's own rendering path.
Root Cause Analysis
- Storage (sources/items.queries.php, cases new_item / update_item):
$post_login = filter_var($dataReceived['login'],
FILTER_SANITIZE_FULL_SPECIAL_CHARS);
- Read path (sources/items.queries.php, case show_details_item):
$arrData['login'] = $dataItem['login'];
The show_details gate only suppresses the login for administrators
opening non-personal items; every non-administrator with folder access
receives it.
- Client decode (includes/js/functions.js, purifyData / decodeQueryReturn):
- Sink (pages/items.js.php):
$('#card-item-login').html(data.login);
No htmlEncode() / escapeHtml() / .text() is applied at the sink, so the
decoded markup executes.
The encoding sentinel tests/Unit/ClientHtmlEncodingSentinelTest.php is meant
to enforce encoding at every sink, but its regex only matches the literal
concatenation pattern 'string' + ident.field and is blind to the direct
form .html(ident) used here, so this sink was not caught.
The minimal fix is to render the login via .text() or htmlEncode() at this
sink, matching the label (htmlEncode) and url (.text) fields in the same
detail block. (Hardening the shared simplePurifier "img" bypass would
additionally neutralise every sink that relies on it.)
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-47xg-w656-j4v4Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
