Tags and favourites do not follow moves and renames on every surface #1055

Closed
opened 2026-10-31 07:48:15 +00:00 by Cordy · 4 comments
Owner

Problem. Tags are rekeyed only by the REST rename handler (internal/api/api.go, h.Tags.Rekey(from, to)); a WebDAV MOVE, the editor and every other surface that renames through the storage stack leave the tags on the old path, so the item loses them and a later item at the old path inherits them. Favourites (internal/favorites/favorites.go, entries keyed by path) are never rekeyed: a starred file renamed anywhere drops out of Favourites, and a new item under the old name appears starred.

Today. Since #835 (v0.6.376) personal shares and links follow renames and moves through actrec's move hook on every surface (cmd/cairnd/personalsharehooks.go, composeShareHooks), as space records have since #1035; Activity is rekeyed there too. Tags and favourites are the remaining path-keyed per-item state outside that chokepoint.

Proposal.

  • Move the tag rekey from the REST handler onto actrec's move hook, so REST, WebDAV, TUS finalize and the editor all carry tags (exact path plus directory prefix, as tags.Store.Rekey does).
  • Add a rekey to favourites on the same hook (every user's entries at or under the old path; record-level writes for #742).
  • Decide what a move out of a Personal folder does with favourites of other people (likely: drop the entries that the person can no longer reach).
  • Optionally key both by the ownermeta item id instead of the path once a global id exists; not needed for this fix.

Acceptance. Tests over the production decorator chain (internal/stacktest): a tagged and starred file renamed over WebDAV and moved through the editor keeps its tags and its star at the new path; a new file at the old path has neither.

Refs. #835 decision 12, research-835.md §5.2 (side findings) and Q12.

Follow-up of #835 (v0.6.376).

**Problem.** Tags are rekeyed only by the REST rename handler (`internal/api/api.go`, `h.Tags.Rekey(from, to)`); a WebDAV MOVE, the editor and every other surface that renames through the storage stack leave the tags on the old path, so the item loses them and a later item at the old path inherits them. Favourites (`internal/favorites/favorites.go`, entries keyed by path) are never rekeyed: a starred file renamed anywhere drops out of Favourites, and a new item under the old name appears starred. **Today.** Since #835 (v0.6.376) personal shares and links follow renames and moves through actrec's move hook on every surface (`cmd/cairnd/personalsharehooks.go`, `composeShareHooks`), as space records have since #1035; Activity is rekeyed there too. Tags and favourites are the remaining path-keyed per-item state outside that chokepoint. **Proposal.** - Move the tag rekey from the REST handler onto actrec's move hook, so REST, WebDAV, TUS finalize and the editor all carry tags (exact path plus directory prefix, as `tags.Store.Rekey` does). - Add a rekey to favourites on the same hook (every user's entries at or under the old path; record-level writes for #742). - Decide what a move out of a Personal folder does with favourites of other people (likely: drop the entries that the person can no longer reach). - Optionally key both by the ownermeta item id instead of the path once a global id exists; not needed for this fix. **Acceptance.** Tests over the production decorator chain (`internal/stacktest`): a tagged and starred file renamed over WebDAV and moved through the editor keeps its tags and its star at the new path; a new file at the old path has neither. **Refs.** #835 decision 12, research-835.md §5.2 (side findings) and Q12. Follow-up of #835 (v0.6.376).
Author
Owner

Research (2026-10-31, code at v0.6.380).

  • The proposal as written can't work: tags (api/tags.go:29-77) and favourites (api/favorites.go:45-55) are keyed by each person's view path (/home/x), while actrec's move hook sees backend paths (/home/<user>/x). Both stores must first be keyed by real location (home path, or space id + path), as Activity was in #971.
  • Likely security bug: tags are one instance-wide map, so Anna's and Ben's /home/Offer.pdf share one entry: each can see and change the other's tags, tag: search crosses accounts, and the personal data export includes them (dxTagPath). Same class as Nextcloud CVE-2025-66547 (CWE-639). Red test first.
  • Tags don't cross a share or survive a space rename; favourites have no rekey/remove at all; WebDAV COPY doesn't carry tags; owner transfer and space renames run below actrec; both stores load once and rewrite the whole file (#742 lost updates).
  • Market: Nextcloud, Google, OpenCloud key tags/favourites by item id (follow moves, lost on copy+delete); Seafile keys stars by path and cleans lazily; favourites are private everywhere.

Recommended: key by real location; follow every rename at the hook (editor-backup rule); pause in Deleted files, resume on restore, drop on purge; carry tags on copy on every surface and both on transfer; convert old files once under a claim; record-level read-merge-write. No new UI. Questions are being asked now. Full file: research-1055.md.

**Research (2026-10-31, code at v0.6.380).** - The proposal as written can't work: tags (`api/tags.go:29-77`) and favourites (`api/favorites.go:45-55`) are keyed by each person's *view* path (`/home/x`), while actrec's move hook sees backend paths (`/home/<user>/x`). Both stores must first be keyed by real location (home path, or space id + path), as Activity was in #971. - **Likely security bug:** tags are one instance-wide map, so Anna's and Ben's `/home/Offer.pdf` share one entry: each can see and change the other's tags, `tag:` search crosses accounts, and the personal data export includes them (`dxTagPath`). Same class as Nextcloud CVE-2025-66547 (CWE-639). Red test first. - Tags don't cross a share or survive a space rename; favourites have no rekey/remove at all; WebDAV COPY doesn't carry tags; owner transfer and space renames run below actrec; both stores load once and rewrite the whole file (#742 lost updates). - Market: Nextcloud, Google, OpenCloud key tags/favourites by item id (follow moves, lost on copy+delete); Seafile keys stars by path and cleans lazily; favourites are private everywhere. **Recommended:** key by real location; follow every rename at the hook (editor-backup rule); pause in Deleted files, resume on restore, drop on purge; carry tags on copy on every surface and both on transfer; convert old files once under a claim; record-level read-merge-write. No new UI. Questions are being asked now. Full file: research-1055.md.
Author
Owner

Decisions (Nikola, 2026-10-31): all research recommendations approved. The cross-user tag leak is fixed as a security fix (red test first); tags and favourites keyed by real location (space id for spaces); follow renames on every surface; pause/resume/drop with Deleted files; tags carried on copy (incl. WebDAV COPY) and both on owner transfer; union of tags on overwrite; Recents included; /tags/all limited to reachable items; old personal tags kept only where exactly one Personal folder has that path, the rest dropped with a logged count; other people's favourites follow and are hidden where unreachable; item-id guard later with #1056; deleted-account favourites a separate follow-up. Next: whole-page mockups (behaviour frames), then spec and build.

**Decisions (Nikola, 2026-10-31): all research recommendations approved.** The cross-user tag leak is fixed as a security fix (red test first); tags and favourites keyed by real location (space id for spaces); follow renames on every surface; pause/resume/drop with Deleted files; tags carried on copy (incl. WebDAV COPY) and both on owner transfer; union of tags on overwrite; Recents included; `/tags/all` limited to reachable items; old personal tags kept only where exactly one Personal folder has that path, the rest dropped with a logged count; other people's favourites follow and are hidden where unreachable; item-id guard later with #1056; deleted-account favourites a separate follow-up. Next: whole-page mockups (behaviour frames), then spec and build.
Author
Owner

Mockup approved (Nikola, 2026-11-01): 1055-tags-follow-mockup.html (no new strings) and the open points as recommended: only editors may change tags (403 read-only, enforced on the server); the Tags column filled in Favourites, Recents and tag search; other instances refuse tag/favourite writes with 503 state-converting during the one-time conversion; no bell for dropped legacy tags (CHANGELOG + log count); over 20 combined tags on an overwrite the destination's win. Next: spec and build.

**Mockup approved (Nikola, 2026-11-01):** `1055-tags-follow-mockup.html` (no new strings) and the open points as recommended: only editors may change tags (403 `read-only`, enforced on the server); the Tags column filled in Favourites, Recents and tag search; other instances refuse tag/favourite writes with 503 `state-converting` during the one-time conversion; no bell for dropped legacy tags (CHANGELOG + log count); over 20 combined tags on an overwrite the destination's win. Next: spec and build.
Cordy closed this issue 2026-11-01 23:38:40 +00:00
Author
Owner

Released in v0.6.384 (PR #1067), live on both dogfoods since 00:50 UTC.

  • Security fix: tags were keyed by path, so people with the same path saw each other's tags, and /tags/all listed everyone's. Tags, favourites and recents are now keyed by real location (tags-v2.json, favorites-v2.json, recents-v2.json) and re-checked on every read. Viewers and Add files only devices cannot change tags on existing items. Bound devices search and suggest only inside their folder.
  • Tags, favourites and recents follow their item on every surface: REST, WebDAV, editor, Deleted files, space rename and purge, owner transfer.
  • The one-time conversion ran on both dogfoods (claim itemlocs-upgrade.json):
    • files: no tags, no favourites; recents 13 read, 12 unresolved.
    • files-bao: 3 tags (1 dropped, because more than one person's Personal folder could own it); 1 favourite kept; recents 24 read, 19 unresolved.
    • "Unresolved" recents point at items that are gone. They are dropped as decided.
  • Research-backed fix before release (research-1055-b1): the conversion never waits on the directory. Local accounts count as known where the directory holds no such person; unknown groups are attributed by the tag rules. Background retries get 30 min.

Live checks are in #1005. Follow-ups: deleted-account favourites (D12) and the name-reuse cleanup land with #1054.

Released in **v0.6.384** (PR #1067), live on both dogfoods since 00:50 UTC. - **Security fix:** tags were keyed by path, so people with the same path saw each other's tags, and `/tags/all` listed everyone's. Tags, favourites and recents are now keyed by real location (`tags-v2.json`, `favorites-v2.json`, `recents-v2.json`) and re-checked on every read. Viewers and Add files only devices cannot change tags on existing items. Bound devices search and suggest only inside their folder. - Tags, favourites and recents follow their item on every surface: REST, WebDAV, editor, Deleted files, space rename and purge, owner transfer. - The one-time conversion ran on both dogfoods (claim `itemlocs-upgrade.json`): - files: no tags, no favourites; recents 13 read, 12 unresolved. - files-bao: 3 tags (1 dropped, because more than one person's Personal folder could own it); 1 favourite kept; recents 24 read, 19 unresolved. - "Unresolved" recents point at items that are gone. They are dropped as decided. - Research-backed fix before release (research-1055-b1): the conversion never waits on the directory. Local accounts count as known where the directory holds no such person; unknown groups are attributed by the tag rules. Background retries get 30 min. Live checks are in #1005. Follow-ups: deleted-account favourites (D12) and the name-reuse cleanup land with #1054.
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#1055
No description provided.