SECURITY: GET /api/v1/spaces lists every space (names, sizes, former names, descriptions) to any signed-in user #923

Closed
opened 2026-10-15 21:22:17 +00:00 by Cordy · 3 comments
Owner

Found in the v0.6.345 local live check (live345 Finding 2). Confirmed with users zed and xan, who are members of no space.

What happens: GET /api/v1/spaces answers every space with its name, size, former names and description to any signed-in person. File contents are not exposed, and the file tree shows these users nothing.

Cause: in internal/api/spaces_lifecycle.go, list adds every folder of the unfiltered /spaces tree. This has been the case since a372ec87 (#771).

Why it matters: space names and descriptions can themselves be confidential (case names, projects, clients). This is the same nDSG / least-privilege point as #911.

To do (small, security patch):

  • A person sees only the spaces the scope membership gives them a role in. Admins see all spaces in Administration only.
  • Check the other space endpoints for the same leak: details, members, quota, activity and alerts.
  • Tests: non-member, app-group namesake, stray -ro, reader, deactivated and deleted spaces, admin by Basic and by session.
Found in the v0.6.345 local live check (live345 Finding 2). Confirmed with users zed and xan, who are members of no space. **What happens:** `GET /api/v1/spaces` answers every space with its name, size, former names and description to any signed-in person. File contents are not exposed, and the file tree shows these users nothing. **Cause:** in `internal/api/spaces_lifecycle.go`, `list` adds every folder of the unfiltered `/spaces` tree. This has been the case since a372ec87 (#771). **Why it matters:** space names and descriptions can themselves be confidential (case names, projects, clients). This is the same nDSG / least-privilege point as #911. **To do (small, security patch):** - A person sees only the spaces the scope membership gives them a role in. Admins see all spaces in Administration only. - Check the other space endpoints for the same leak: details, members, quota, activity and alerts. - Tests: non-member, app-group namesake, stray `-ro`, reader, deactivated and deleted spaces, admin by Basic and by session.
Author
Owner

Research (2026-10-16)

Full findings: cairn-work/scratch/b7e/batch907/923-research.md. Probes are in 923copy; the repo was not touched.

Leaking endpoints (v0.6.345):

  1. GET /api/v1/spaces returns every /spaces folder with its size, description, subtitle, former names and quota.
    • It runs a live IdP group listing on every call.
    • Its orphan flag tells anyone which folders have no group.
    • Introduced in v0.6.84 (6364f4d1/ca2d8561, merged as a372ec87). Before that, the list went to owners and admins only.
  2. GET /api/v1/spaces/{name}/meta returns the description, subtitle, image token, member count, quota and kind for any name. For a former name it answers with the current name, so a rename is disclosed (spaces.go:614, since v0.6.286).
  3. GET /api/v1/spaces/{name}/image returns the picture for any name, including former names.
  4. The members, candidates, state, rename and description endpoints answer 403 for an existing app space but 404 otherwise. That difference lets anyone enumerate space names.

Already filtered by the membership rule: the file listing, search, activity, quota, trash, change feed, WebDAV and notifications. Admin endpoints are session-only, and limited devices are blocked.

Found alongside, filed separately:

  • #927 (SECURITY): a space takeover through POST /api/v1/spaces. It ships together with this issue.
  • #928: the recipient picker lists every group name.
  • #929: a discoverable-spaces feature (later, opt-in).

Market:

  • OpenCloud: GET /drives without elevated rights behaves the same as /me/drives.
  • Google: drives.list returns only your own drives unless you pass useDomainAdminAccess.
  • Nextcloud and Dropbox team folders: members only.
  • Teams: private-team discovery is off by default.
  • GitLab: it keeps shipping CVEs for private project names leaking through side endpoints.
  • GitHub: answers 404 rather than 403, to hide that a private repository exists.

Standards: OWASP API1/API3/API5:2023, NIST AC-3/AC-6, ISO 27002 5.15/8.3, nDSG Art. 6/7/8.

Recommended fix:

  • One gate on every /api/v1/spaces/{name}/* endpoint: a session admin, or a member according to Membership.SpaceNamed. Anyone else gets the identical 404 that a missing space gets.
  • The list: returns SpacesOf(u) with a role field, and makes no IdP call for non-admins.
  • Create: refuses a name that already exists as a folder or as a directory space (#927).
  • UI: nothing visible changes for members or admins, so no mockup is needed.
  • Size: about 1 day.

Decisions for Nikola:

  • D1, the list for people: (a) their own spaces with role (rec.), (b) 403, (c) owned only.
  • D2: session admins see everything; Basic admins count as ordinary users (rec. yes).
  • D3, existence: (a) identical 404 everywhere, (b) plus one generic 409 "This name is already in use. Choose another." on create for non-admins (rec.).
  • D4, takeover: (a) refuse create over an existing folder for everyone, admins use "Take over and deactivate" (rec.), (b) still allow admins through create.
  • D5: discoverable spaces as a separate feature (#929).
  • D6, flat mode: same rule, plus a handbook line that flat mode has no space privacy.
  • D7: the recipient picker as a separate issue (#928).
  • D8, former names: visible to the owner and admins only (rec.), or to all members.
## Research (2026-10-16) Full findings: `cairn-work/scratch/b7e/batch907/923-research.md`. Probes are in `923copy`; the repo was not touched. **Leaking endpoints (v0.6.345):** 1. **`GET /api/v1/spaces`** returns every `/spaces` folder with its size, description, subtitle, former names and quota. - It runs a live IdP group listing on every call. - Its `orphan` flag tells anyone which folders have no group. - Introduced in v0.6.84 (6364f4d1/ca2d8561, merged as a372ec87). Before that, the list went to owners and admins only. 2. **`GET /api/v1/spaces/{name}/meta`** returns the description, subtitle, image token, member count, quota and kind for any name. For a former name it answers with the current name, so a rename is disclosed (`spaces.go:614`, since v0.6.286). 3. **`GET /api/v1/spaces/{name}/image`** returns the picture for any name, including former names. 4. **The members, candidates, state, rename and description endpoints** answer 403 for an existing app space but 404 otherwise. That difference lets anyone enumerate space names. **Already filtered by the membership rule:** the file listing, search, activity, quota, trash, change feed, WebDAV and notifications. Admin endpoints are session-only, and limited devices are blocked. **Found alongside, filed separately:** - **#927 (SECURITY):** a space takeover through `POST /api/v1/spaces`. It ships together with this issue. - **#928:** the recipient picker lists every group name. - **#929:** a discoverable-spaces feature (later, opt-in). **Market:** - **OpenCloud:** `GET /drives` without elevated rights behaves the same as `/me/drives`. - **Google:** `drives.list` returns only your own drives unless you pass `useDomainAdminAccess`. - **Nextcloud and Dropbox team folders:** members only. - **Teams:** private-team discovery is off by default. - **GitLab:** it keeps shipping CVEs for private project names leaking through side endpoints. - **GitHub:** answers 404 rather than 403, to hide that a private repository exists. **Standards:** OWASP API1/API3/API5:2023, NIST AC-3/AC-6, ISO 27002 5.15/8.3, nDSG Art. 6/7/8. **Recommended fix:** - **One gate on every `/api/v1/spaces/{name}/*` endpoint:** a session admin, or a member according to `Membership.SpaceNamed`. Anyone else gets the identical 404 that a missing space gets. - **The list:** returns `SpacesOf(u)` with a `role` field, and makes no IdP call for non-admins. - **Create:** refuses a name that already exists as a folder or as a directory space (#927). - **UI:** nothing visible changes for members or admins, so no mockup is needed. - **Size:** about 1 day. **Decisions for Nikola:** - **D1, the list for people:** (a) their own spaces with role (rec.), (b) 403, (c) owned only. - **D2:** session admins see everything; Basic admins count as ordinary users (rec. yes). - **D3, existence:** (a) identical 404 everywhere, (b) plus one generic 409 "This name is already in use. Choose another." on create for non-admins (rec.). - **D4, takeover:** (a) refuse create over an existing folder for everyone, admins use "Take over and deactivate" (rec.), (b) still allow admins through create. - **D5:** discoverable spaces as a separate feature (#929). - **D6, flat mode:** same rule, plus a handbook line that flat mode has no space privacy. - **D7:** the recipient picker as a separate issue (#928). - **D8, former names:** visible to the owner and admins only (rec.), or to all members.
Author
Owner

Decisions (Nikola, 2026-10-16)

All recommendations accepted. This ships with #927 as one security release.

  • D1: the list shows a person only their own spaces, with their role.
  • D2: session admins see every space; Basic admins count as ordinary users.
  • D3: every /spaces/{name} endpoint answers the same 404 as a missing space. Creating a taken name answers one generic 409: "This name is already in use. Choose another."
  • D4: creating a space over an existing folder or directory space is refused for everyone. Admins keep "Take over and deactivate".
  • D5, D7: separate issues, #929 and #928.
  • D6: flat mode follows the same rule, plus a handbook line that flat mode has no space privacy.
  • D8: former names are visible to the owner and admins only.
## Decisions (Nikola, 2026-10-16) All recommendations accepted. This ships with #927 as one security release. - **D1:** the list shows a person only their own spaces, with their role. - **D2:** session admins see every space; Basic admins count as ordinary users. - **D3:** every `/spaces/{name}` endpoint answers the same 404 as a missing space. Creating a taken name answers one generic 409: "This name is already in use. Choose another." - **D4:** creating a space over an existing folder or directory space is refused for everyone. Admins keep "Take over and deactivate". - **D5, D7:** separate issues, #929 and #928. - **D6:** flat mode follows the same rule, plus a handbook line that flat mode has no space privacy. - **D8:** former names are visible to the owner and admins only.
Cordy closed this issue 2026-10-16 00:51:54 +00:00
Author
Owner

Shipped in v0.6.346 (PR #937, security patch). Both dogfoods run v0.6.346.

Local live check: 50 PASS, 1 FAIL (scratch/b7e/live346).

  • Lists: non-members, app-group namesakes, stray -ro and Basic admins see [] or only their own spaces.
  • Refusals: 1577 hidden-name answers compared with a missing name across all 19 routes; all are byte-identical 404 not-found, including NFC, NFD and case variants. One log line per refusal.
  • Former names: members get back the name they asked for; the owner and session admin get the current name.
  • Member web flows: unchanged.
  • Admin inventory: identical to v0.6.345 on the same data.
  • Control run on v0.6.345: the old leaks reproduce (zed sees every space; /meta reveals the rename; 403 vs 404).

The one FAIL is admin-only and older: a take-over of an NFD-named folder creates a space nobody can open (#934, fix next). Small inconsistencies are filed as #938. Closing.

## Shipped in v0.6.346 (PR #937, security patch). Both dogfoods run v0.6.346. **Local live check: 50 PASS, 1 FAIL** (`scratch/b7e/live346`). - **Lists:** non-members, app-group namesakes, stray `-ro` and Basic admins see `[]` or only their own spaces. - **Refusals:** 1577 hidden-name answers compared with a missing name across all 19 routes; all are byte-identical 404 `not-found`, including NFC, NFD and case variants. One log line per refusal. - **Former names:** members get back the name they asked for; the owner and session admin get the current name. - **Member web flows:** unchanged. - **Admin inventory:** identical to v0.6.345 on the same data. - **Control run on v0.6.345:** the old leaks reproduce (zed sees every space; `/meta` reveals the rename; 403 vs 404). The one FAIL is admin-only and older: a take-over of an NFD-named folder creates a space nobody can open (#934, fix next). Small inconsistencies are filed as #938. Closing.
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Cordy/Cairn#923
No description provided.