The change feed can name a /shared path whose grant the item guard refuses #1059

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

Problem. Since #835 the /shared overlay asks the item guard before it serves a personal grant (scope.Driver.WithItemGuard): a grant whose item was replaced is not there for its recipient. The change feed (SharedViewFor, #974) does not ask the guard, so a recipient's sync client can still see changes at a /shared/... path that then does not open (404). Also: when two of one owner's grants appear under the same /shared name, only the grant pickGrant serves is asked, so a refused pick hides a same-named sibling grant that would serve (accepted for v0.6.376, spec §5.2).

Proposal. Ask the same guard in SharedViewFor (with a per-request cache of item ids by folder, as the share lists do), or drop entries whose grant is marked Replaced. For the sibling case, try the next grant for the name when the pick is refused.

Acceptance. A test: a grant on a.pdf, a.pdf replaced outside Cairn; the recipient's change feed no longer lists changes at the grant's /shared path; a second grant of the same name that serves is listed and reachable.

Refs. #835 spec §14 (last item) and §5.2, #974.

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

**Problem.** Since #835 the `/shared` overlay asks the item guard before it serves a personal grant (`scope.Driver.WithItemGuard`): a grant whose item was replaced is not there for its recipient. The change feed (`SharedViewFor`, #974) does not ask the guard, so a recipient's sync client can still see changes at a `/shared/...` path that then does not open (404). Also: when two of one owner's grants appear under the same `/shared` name, only the grant `pickGrant` serves is asked, so a refused pick hides a same-named sibling grant that would serve (accepted for v0.6.376, spec §5.2). **Proposal.** Ask the same guard in `SharedViewFor` (with a per-request cache of item ids by folder, as the share lists do), or drop entries whose grant is marked `Replaced`. For the sibling case, try the next grant for the name when the pick is refused. **Acceptance.** A test: a grant on a.pdf, a.pdf replaced outside Cairn; the recipient's change feed no longer lists changes at the grant's `/shared` path; a second grant of the same name that serves is listed and reachable. **Refs.** #835 spec §14 (last item) and §5.2, #974. Follow-up of #835 (v0.6.376).
Author
Owner

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

  • Confirmed: SharedViewFor (scope/shared.go:224-264) never asks the item guard, so after an item is replaced outside Cairn the feed keeps naming /shared/... paths that answer 404. With a folder grant whose folder was replaced it also shows names and change times of files in the new folder (path-reuse shape, metadata only; low risk, needs an outside change or the #742 lost-update residual).
  • The sibling fallback is unsafe on its own: the feed would still name the refused path, HolderWrites (locate.go:108-133) would grant a write right on it through the sibling without checking the resolved path, and Shared with me (shares.go:345-386) would still list the refused row. A legacy grant (no item id) on the same path would fail open.
  • Google, Graph, Dropbox, Nextcloud and PingDirectory never name a path their own read path refuses; NIST AC-3/AC-3(8), OWASP ASVS 5.0 8.2.2/8.3.2 and complete mediation point the same way.

Recommended: one function decides which grant serves /shared/<owner>/<name>; a path serves if any id-carrying grant passes the guard or no grant carries an id; if every id-carrying grant is refused, legacy grants on that path don't serve either; resolve, owner listing, feed and Shared with me all use it; the feed asks the guard at most once per grant per poll; HolderWrites also compares the resolved backend path. No UI, no new state. Questions are being asked now. Full file: research-1059.md.

**Research (2026-10-31, code at v0.6.380).** - Confirmed: `SharedViewFor` (`scope/shared.go:224-264`) never asks the item guard, so after an item is replaced outside Cairn the feed keeps naming `/shared/...` paths that answer 404. With a folder grant whose folder was replaced it also shows names and change times of files in the *new* folder (path-reuse shape, metadata only; low risk, needs an outside change or the #742 lost-update residual). - The sibling fallback is unsafe on its own: the feed would still name the refused path, `HolderWrites` (`locate.go:108-133`) would grant a write right on it through the sibling without checking the resolved path, and Shared with me (`shares.go:345-386`) would still list the refused row. A legacy grant (no item id) on the same path would fail open. - Google, Graph, Dropbox, Nextcloud and PingDirectory never name a path their own read path refuses; NIST AC-3/AC-3(8), OWASP ASVS 5.0 8.2.2/8.3.2 and complete mediation point the same way. **Recommended:** one function decides which grant serves `/shared/<owner>/<name>`; a path serves if any id-carrying grant passes the guard or no grant carries an id; if every id-carrying grant is refused, legacy grants on that path don't serve either; resolve, owner listing, feed and Shared with me all use it; the feed asks the guard at most once per grant per poll; `HolderWrites` also compares the resolved backend path. No UI, no new state. Questions are being asked now. Full file: research-1059.md.
Author
Owner

Decisions (Nikola, 2026-10-31): all research recommendations approved. One function decides which grant serves /shared/<owner>/<name>, used by resolve, the owner listing, the change feed and Shared with me; the sibling case is fixed on every surface; fail closed for the whole path when every id-carrying grant on it is refused (legacy grants there don't serve); an unreadable item id drops that grant's feed entries; a poll may set the Replaced marker, audit and bell once; the per-person delete on first refusal is handled by #1063; HolderWrites also checks the resolved path; two nearby gaps go to the backlog file. No UI; spec and build next.

**Decisions (Nikola, 2026-10-31): all research recommendations approved.** One function decides which grant serves `/shared/<owner>/<name>`, used by resolve, the owner listing, the change feed and Shared with me; the sibling case is fixed on every surface; fail closed for the whole path when every id-carrying grant on it is refused (legacy grants there don't serve); an unreadable item id drops that grant's feed entries; a poll may set the Replaced marker, audit and bell once; the per-person delete on first refusal is handled by #1063; `HolderWrites` also checks the resolved path; two nearby gaps go to the backlog file. No UI; spec and build next.
Cordy closed this issue 2026-11-01 10:13:57 +00:00
Author
Owner

Released in v0.6.382 (PR #1065), live on both dogfoods.

scope.servedOf is now the single serving decision for /shared/<owner>/<name>. The overlay, the change feed (SharedViewFor), Shared with me and HolderWrites all ask it. So a grant the item guard refuses is no longer named in the feed, and a same-named sibling grant that serves takes its place. Names are compared in NFC; listings drop duplicates.

The switch between same-named grants is reported in the feed since v0.6.383 (#1063). Live checks are in #1005.

Released in **v0.6.382** (PR #1065), live on both dogfoods. `scope.servedOf` is now the single serving decision for `/shared/<owner>/<name>`. The overlay, the change feed (`SharedViewFor`), Shared with me and `HolderWrites` all ask it. So a grant the item guard refuses is no longer named in the feed, and a same-named sibling grant that serves takes its place. Names are compared in NFC; listings drop duplicates. The switch between same-named grants is reported in the feed since v0.6.383 (#1063). Live checks are in #1005.
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#1059
No description provided.