GHSA-5VF9-RXQV-G8WP
Stored XSS in Search Results Expand Card (label, login, url)
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-5VF9-RXQV-G8WP divulgada · CVSS 8.7 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Stored XSS in Search Results Expand Card (label, login, url)
Summary
The "Find" (search) page renders an expandable detail card for each search
result. When a user clicks the eye icon on a result row, the showItemInfo()
handler queries show_details_item and builds an HTML string (return_html) by
concatenating the returned item fields DIRECTLY, then inserts it with
jQuery .html(). Three plantable fields are written unencoded into that one
string:
'<h5 id="item-label">' + data.label + '</h5>' // label
'<span ... id="login-item_' + data.id + '">' + data.login + '</span>' // login
'<span ... id="url-item_' + data.id + '">' + data.url + '</span>' // url
...
$(tr).next('tr').html(return_html); // pages/search.js.php
The response is decoded with prepareExchangedData('decode'), which runs
purifyData/simplePurifier. simplePurifier decodes HTML entities back to live
characters and, for any value containing the substring "img", returns the
value UNCHANGED (no tag stripping). An entity-encoded payload such as
<img src=x onerror=...> is therefore decoded back to a live
<img onerror> element string before it reaches the .html() sink.
This search-expand render path is a DISTINCT, undefended surface from the
item detail card. The detail card (pages/items.js.php) defends the same
fields: label via htmlEncode(), url via .text(), and only login is left as
.html() (the separately-reported item-login XSS). The search-expand card
applies NONE of those defences, so it re-exposes label and url -- two fields
that are safe everywhere else -- and adds a second sink for login. All three
fields flow into the SAME single .html(return_html) call, so this is one
sink exposing three fields.
All three fields are plantable through the normal New Item / Edit form:
label and login are stored via FILTER_SANITIZE_FULL_SPECIAL_CHARS (entity
encode only, no AntiXSS strip); url is stored via FILTER_SANITIZE_URL (which
keeps < > = " / and only strips spaces). The client-side field purifier does
not block these payloads because simplePurifier's "img" bypass returns any
value containing "img" unmodified, and the tags field's character regex
does not apply to label/login/url. A spaceless, double-quoted url payload
survives FILTER_SANITIZE_URL intact.
Cross-user reach: the show_details_item handler suppresses the login only
for administrators opening non-personal items; every non-administrator with
read access to the folder receives show_details = 1 and the raw label,
login and url. Any colleague who searches for the poisoned item and expands
the result 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/search.js.php showItemInfo: data.label, data.login, data.url
concatenated into return_html and inserted via .html()).
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 payloads (browser: New Item form)
------------------------------------------------------------------
For each field, log in as the non-administrator (deleter / deleter123!),
open the Items page, select folder "E2E Folder" (id 9002), click "New
item", and fill:
LABEL item:
Label = xssLblE2E<img src=x onerror=document.body.dataset.xssLabel=1>
Login = (anything)
Password = (any value satisfying the folder complexity policy)
Save.
LOGIN item:
Label = xssLoginE2E
Login = <img src=x onerror=document.body.dataset.xssLogin=1>
Password = (any value)
Save.
URL item:
Label = xssUrlE2E
Login = (anything)
URL = http://x/<img/src="x"/onerror="document.body.dataset.xssUrl=1">
Password = (any value)
Save.
Notes on the URL payload:
- FILTER_SANITIZE_URL strips spaces, so a spaced <img src=x onerror=...>
is stored as the broken <imgsrc=xonerror=...>. A SPACELESS payload is
required.
- "/" after the tag name separates attributes; double-quoted attribute
values terminate cleanly and do not break the single-quoted JS string
that builds return_html. Hence:
<img/src="x"/onerror="document.body.dataset.xssUrl=1">
is stored verbatim and parses as a live <img> element.
- A bare tag value is rejected by the type="url" input's validity check,
so a short http://x/ prefix is used; it becomes inert text before the
<img> element.
The server stores each value HTML-entity-encoded (label/login via
FILTER_SANITIZE_FULL_SPECIAL_CHARS; url via FILTER_SANITIZE_URL which keeps
< > = " /). No AntiXSS stripping is applied to any of the three fields, and
no database operation or crafted request was used -- the values were typed
into the standard item form inputs.
------------------------------------------------------------------
Step 2 - Victim triggers the payloads (browser: search + expand)
------------------------------------------------------------------
1. Log in as a non-administrator who can see folder 9002.
2. Open the Find page (top navigation -> Find).
3. Type the item label (e.g. "xssLblE2E") into the results search box.
4. Click the eye icon (.item-detail) on the matching result row.
The application's own showItemInfo() handler calls the show_details_item
endpoint, decodes the response with prepareExchangedData('decode'), builds
return_html with the raw field values, and inserts it with the real sink:
$(tr).next('tr').html(return_html); // pages/search.js.php
decodeQueryReturn/purifyData decodes the stored entities back to live
<img onerror> markup (the "img" bypass returns the value unchanged), and
.html() parses it as live DOM. The onerror handlers execute. Repeat steps
3-4 for the LOGIN item (search "xssLoginE2E") and the URL item (search
"xssUrlE2E") to fire the login and url payloads.
Expected result (observed in the browser DOM only, no database access):
LABEL (item "xssLblE2E", searched and expanded):
document.body.dataset.xssLabel === "1"
document.querySelector('#item-label').innerHTML
=== 'xssLblE2E<img src="x" onerror="document.body.dataset.xssLabel=1">'
LOGIN (item "xssLoginE2E", searched and expanded):
document.body.dataset.xssLogin === "1"
document.querySelector('[id^="login-item_"]').innerHTML
=== '<img src="x" onerror="document.body.dataset.xssLogin=1">'
URL (item "xssUrlE2E", searched and expanded):
document.body.dataset.xssUrl === "1"
document.querySelector('[id^="url-item_"]').innerHTML
=== 'http://x/<img src="x" onerror="document.body.dataset.xssUrl=1">'
In each case a live <img> element is present in the expanded search-result
card and the onerror handler fired, confirming execution through the
application's own search-expand rendering path.
Root Cause Analysis
- Storage (sources/items.queries.php, cases new_item / update_item):
- label : filter_var(..., FILTER_SANITIZE_FULL_SPECIAL_CHARS) (entity
- login : FILTER_SANITIZE_FULL_SPECIAL_CHARS (same)
- url : filter_var(htmlspecialchars_decode(...), FILTER_SANITIZE_URL)
- Read path (sources/items.queries.php, case show_details_item):
- Client decode (includes/js/functions.js, simplePurifier / purifyData,
- Sink (pages/search.js.php, showItemInfo):
The item detail card (pages/items.js.php) defends these same fields
(label via htmlEncode, url via .text()), which is why this search-expand
path was missed: it is a parallel render function that never inherited
those defences. The encoding sentinel tests/Unit/ClientHtmlEncodingSentinel
Test.php does not cover search.js.php and only matches the literal
'string' + ident.<WATCHED_FIELD> concatenation pattern, so the direct
concatenations here are not caught.
The minimal fix is to wrap data.label, data.login and data.url in
htmlEncode() (or render them via .text()) in showItemInfo, matching the
defences already present in the item detail card. (Hardening the shared
simplePurifier "img" bypass would additionally neutralise this and the
other sinks that rely 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-5vf9-rxqv-g8wpLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
