Space Deleted files invisible to members of app-managed spaces (trash checks read only groups) #911

Closed
opened 2026-10-15 16:27:16 +00:00 by Cordy · 3 comments
Owner

Found during the v0.6.343 local live check. This is not a batch A regression: internal/storage/trash/space.go has not changed since #95 (7027c887).

What happens

Setup: local mode, with a space whose members are set through POST /api/v1/spaces/Fin/members (spacestore).

  • Entries deleted inside Fin are missing from GET /api/v1/trash for every member: anna (writer), bob (reader) and admin (owner).
  • anna's POST /api/v1/trash/s:Fin:<id>/restore answers 404.
  • Only GET /api/v1/admin/trash lists the entries, and admin can restore them by id.

This contradicts the CHANGELOG for #95: "All members see space entries".

Cause

spacesFor, canSeeSpace and canModifySpace in internal/storage/trash/space.go read only u.Groups. They ignore spacestore roles. The scope layer and the change feed both use Spaces.RoleFor.

Reproduce (anna session)

POST   /api/v1/files?path=/spaces/Fin/t.txt
DELETE /api/v1/files?path=/spaces/Fin/t.txt
GET    /api/v1/trash                      -> no Fin entry
GET    /api/v1/admin/trash   (as admin)   -> entry s:Fin:<id>
POST   /api/v1/trash/s:Fin:<id>/restore   -> 404

Scope to check

  • Both dogfoods use IdP group spaces, which go through u.Groups, so this probably affects local and app-managed spaces only. Confirm the full matrix: IdP-managed, live groups, app-managed and local.
  • Check the rename alias too.
  • Research first, as usual.
Found during the v0.6.343 local live check. This is not a batch A regression: `internal/storage/trash/space.go` has not changed since #95 (7027c887). ## What happens Setup: local mode, with a space whose members are set through `POST /api/v1/spaces/Fin/members` (spacestore). - Entries deleted inside Fin are missing from `GET /api/v1/trash` for every member: anna (writer), bob (reader) and admin (owner). - anna's `POST /api/v1/trash/s:Fin:<id>/restore` answers 404. - Only `GET /api/v1/admin/trash` lists the entries, and admin can restore them by id. This contradicts the CHANGELOG for #95: "All members see space entries". ## Cause `spacesFor`, `canSeeSpace` and `canModifySpace` in `internal/storage/trash/space.go` read only `u.Groups`. They ignore spacestore roles. The scope layer and the change feed both use `Spaces.RoleFor`. ## Reproduce (anna session) ``` POST /api/v1/files?path=/spaces/Fin/t.txt DELETE /api/v1/files?path=/spaces/Fin/t.txt GET /api/v1/trash -> no Fin entry GET /api/v1/admin/trash (as admin) -> entry s:Fin:<id> POST /api/v1/trash/s:Fin:<id>/restore -> 404 ``` ## Scope to check - Both dogfoods use IdP group spaces, which go through `u.Groups`, so this probably affects local and app-managed spaces only. Confirm the full matrix: IdP-managed, live groups, app-managed and local. - Check the rename alias too. - Research first, as usual.
Author
Owner

Research (2026-10-15)

Full findings: cairn-work/scratch/b7e/batch907/911-research.md. Probes ran in a scratch copy (911copy); the repo was not touched.

Cause: trash has its own membership check (trash/space.go:86-134, trash.go:285-302). It reads only groups, assumes the -ro suffix, and treats the backend folder name as the space name. Scope, the real authority, also knows:

  • app-managed roles (SpaceAccess, scope.go:241-264);
  • that app-owned groups grant nothing (#690);
  • renamed spaces (#771).

Faults confirmed:

  1. App-managed spaces (this issue): owner, writers and readers see nothing; restore answers 404; only admins can recover.
  2. Renamed spaces: entries stay under s:Old:... and are invisible to members, including IdP-group members of the new name.
  3. SECURITY (over-grant): an app-owned group with the same name as an app space lets its members, even readers or non-members, see, restore and purge that space's trash. The change feed (changes.go:119-136) has the same hole and leaks the paths of changed files.
  4. Custom read-only suffix: it is never passed to trash (SetReadOnlySuffix is never called). Custom-suffix readers see nothing, while a stray -ro group sees deleted file names.
  5. Restore after a rename: recreates the orphan /spaces/Old/.

Peering send (main.go:1898-1909) probably has fault 3 too (found by reading the code, not run).

Market:

  • oCIS / OpenCloud: viewers see trash, editors restore, managers purge.
  • Seafile: any permission sees it, read-write restores, admin cleans.
  • Google shared drives: contributors restore, managers permanently delete.
  • SharePoint: edit rights to see and restore others' deletions.
  • Nextcloud had the same failure classes: groupfolders #610, and CVE-2025-66545 (read-only members could restore).

Standards: NIST AC-3/AC-6 and ISO 27002 5.15/8.3 call for one consistently enforced decision; nDSG Art. 8 / DSV Art. 3 means no deleted file names for non-members.

Recommended fix: scope exports one membership resolver (spaces for a person, plus a single-space check mapping folder to space). Trash, the change feed and peering all use it, and the trash's own logic goes away. Lists show the current space name and the person's own paths. Entry IDs carry the space ID. A space entry always restores inside its own space.

Decisions for Nikola:

  • D1: readers see space trash entries. Rec. keep, since they could read the files before deletion.
  • D2: purge rights. Rec.: the owner purges anything, writers purge only their own deletions, admins purge anything.
  • D3: include the change feed, peering and restore-after-rename in the fix. Rec. yes.
  • D4: entry IDs by space ID. Rec. yes.
  • D5: rows a person cannot change show disabled buttons with the reason, instead of hiding them. Rec. yes.

Mockup needed for D2/D5 (Deleted files rows). Size: backend M (1.5-2 days), UI +0.5-1 day.

Two small follow-ups to file:

  • When a grantee deletes in a shared folder, the deletion is recorded under the owner, so the real deleter is lost.
  • Restore activity is recorded with the backend path.

Fault 3 is a security bug: it should go first, ahead of batch B.

## Research (2026-10-15) Full findings: `cairn-work/scratch/b7e/batch907/911-research.md`. Probes ran in a scratch copy (`911copy`); the repo was not touched. **Cause:** trash has its own membership check (`trash/space.go:86-134`, `trash.go:285-302`). It reads only groups, assumes the `-ro` suffix, and treats the backend folder name as the space name. Scope, the real authority, also knows: - app-managed roles (`SpaceAccess`, `scope.go:241-264`); - that app-owned groups grant nothing (#690); - renamed spaces (#771). **Faults confirmed:** 1. **App-managed spaces (this issue):** owner, writers and readers see nothing; restore answers 404; only admins can recover. 2. **Renamed spaces:** entries stay under `s:Old:...` and are invisible to members, including IdP-group members of the new name. 3. **SECURITY (over-grant):** an app-owned group with the same name as an app space lets its members, even readers or non-members, see, restore and **purge** that space's trash. The change feed (`changes.go:119-136`) has the same hole and leaks the paths of changed files. 4. **Custom read-only suffix:** it is never passed to trash (`SetReadOnlySuffix` is never called). Custom-suffix readers see nothing, while a stray `-ro` group sees deleted file names. 5. **Restore after a rename:** recreates the orphan `/spaces/Old/`. Peering send (`main.go:1898-1909`) probably has fault 3 too (found by reading the code, not run). **Market:** - oCIS / OpenCloud: viewers see trash, editors restore, managers purge. - Seafile: any permission sees it, read-write restores, admin cleans. - Google shared drives: contributors restore, managers permanently delete. - SharePoint: edit rights to see and restore others' deletions. - Nextcloud had the same failure classes: groupfolders #610, and CVE-2025-66545 (read-only members could restore). **Standards:** NIST AC-3/AC-6 and ISO 27002 5.15/8.3 call for one consistently enforced decision; nDSG Art. 8 / DSV Art. 3 means no deleted file names for non-members. **Recommended fix:** scope exports one membership resolver (spaces for a person, plus a single-space check mapping folder to space). Trash, the change feed and peering all use it, and the trash's own logic goes away. Lists show the current space name and the person's own paths. Entry IDs carry the space ID. A space entry always restores inside its own space. **Decisions for Nikola:** - **D1:** readers see space trash entries. Rec. keep, since they could read the files before deletion. - **D2:** purge rights. Rec.: the owner purges anything, writers purge only their own deletions, admins purge anything. - **D3:** include the change feed, peering and restore-after-rename in the fix. Rec. yes. - **D4:** entry IDs by space ID. Rec. yes. - **D5:** rows a person cannot change show disabled buttons with the reason, instead of hiding them. Rec. yes. **Mockup** needed for D2/D5 (Deleted files rows). **Size:** backend M (1.5-2 days), UI +0.5-1 day. **Two small follow-ups to file:** - When a grantee deletes in a shared folder, the deletion is recorded under the owner, so the real deleter is lost. - Restore activity is recorded with the backend path. Fault 3 is a security bug: it should go first, ahead of batch B.
Author
Owner

Decisions (Nikola, 2026-10-15)

All recommendations accepted. #911 goes first, as a security patch ahead of batch B.

  • D1: readers see space trash entries.
  • D2: the owner purges anything, writers purge only their own deletions, admins purge anything. Enforced on the server.
  • D3: the fix also covers the change feed, peering send and restore after a rename (one membership resolver from scope).
  • D4: trash entry IDs carry the space ID.
  • D5: rows a person cannot change show disabled buttons with the reason. This needs a mockup first, so it is built after the backend patch, together with the #913 editor UI.
## Decisions (Nikola, 2026-10-15) All recommendations accepted. #911 goes first, as a security patch ahead of batch B. - **D1:** readers see space trash entries. - **D2:** the owner purges anything, writers purge only their own deletions, admins purge anything. Enforced on the server. - **D3:** the fix also covers the change feed, peering send and restore after a rename (one membership resolver from scope). - **D4:** trash entry IDs carry the space ID. - **D5:** rows a person cannot change show disabled buttons with the reason. This needs a mockup first, so it is built after the backend patch, together with the #913 editor UI.
Cordy closed this issue 2026-10-15 20:58:25 +00:00
Author
Owner

Shipped in v0.6.345 (PR #917, security patch). Both dogfoods run v0.6.345.

One membership rule, exported by scope, now drives the trash, the change feed and peering send.

The build and its reviews also closed these, which predate #911:

  • the peering send .. path bypass (and the same raw-path check in OCM send);
  • the peering send legal-hold check running on the virtual path;
  • retiring an old space name while it is still the space's folder (now 409 alias-in-use);
  • deactivated and deleted space names granting to directory groups;
  • legal holds and retention after a rename (both the recorded and the current path are checked).

Local live check (v0.6.345): 59 PASS, 0 FAIL. Full report: scratch/b7e/live345/report.md.

  • App-group namesake and stray -ro: no access to the space, its Deleted files or its change-feed entries.
  • Rights: readers see entries but cannot restore or purge (read-only); a writer purging someone else's deletion gets trash-not-yours; owner and admin can do everything; non-members get not-found. Every refusal writes exactly one log line.
  • Rename, before and after convergence:
    • members keep their entries;
    • a restore lands in the live folder and never recreates the old one;
    • alias-in-use before convergence, 204 after;
    • a hold on the new path protects an entry recorded under the old one.
  • Peering send: the .. bypass is refused and the audit records the cleaned path. Readers, the namesake and a held personal file are refused.

Found during the live check (not caused by this patch), filed:

  • #922: a version can be lost when two saves land in the same second.
  • #923: SECURITY. GET /api/v1/spaces lists every space to any signed-in user.

Follow-ups filed: #918, #919, #920, #921.

Still open: the D5 UI (disabled buttons with the reason in Deleted files) needs a mockup and stays with the #913 editor UI. Closing #911.

## Shipped in v0.6.345 (PR #917, security patch). Both dogfoods run v0.6.345. One membership rule, exported by scope, now drives the trash, the change feed and peering send. The build and its reviews also closed these, which predate #911: - the peering send `..` path bypass (and the same raw-path check in OCM send); - the peering send legal-hold check running on the virtual path; - retiring an old space name while it is still the space's folder (now 409 `alias-in-use`); - deactivated and deleted space names granting to directory groups; - legal holds and retention after a rename (both the recorded and the current path are checked). **Local live check (v0.6.345): 59 PASS, 0 FAIL.** Full report: `scratch/b7e/live345/report.md`. - **App-group namesake and stray `-ro`:** no access to the space, its Deleted files or its change-feed entries. - **Rights:** readers see entries but cannot restore or purge (`read-only`); a writer purging someone else's deletion gets `trash-not-yours`; owner and admin can do everything; non-members get `not-found`. Every refusal writes exactly one log line. - **Rename, before and after convergence:** - members keep their entries; - a restore lands in the live folder and never recreates the old one; - `alias-in-use` before convergence, 204 after; - a hold on the new path protects an entry recorded under the old one. - **Peering send:** the `..` bypass is refused and the audit records the cleaned path. Readers, the namesake and a held personal file are refused. **Found during the live check (not caused by this patch), filed:** - **#922:** a version can be lost when two saves land in the same second. - **#923:** SECURITY. `GET /api/v1/spaces` lists every space to any signed-in user. **Follow-ups filed:** #918, #919, #920, #921. **Still open:** the D5 UI (disabled buttons with the reason in Deleted files) needs a mockup and stays with the #913 editor UI. Closing #911.
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#911
No description provided.