A Nextcloud that receives a federated share from Cairn probably cannot open it #1070

Closed
opened 2026-11-02 12:10:51 +00:00 by Cordy · 6 comments
Owner

Problem. When a Cairn user shares with someone on a vanilla Nextcloud over Open Cloud Mesh, the Nextcloud user most likely sees the share but cannot open it.

  • Nextcloud reads a received share with Basic authentication: the share's secret as the user name and no password, at the WebDAV root its discovery names.
  • Cairn serves only at the per-share address (/dav/ocm/<providerId>/) with a Bearer secret. /dav/ocm/ with nothing after it answers 404.
  • ocm.Store.ShareOutBySecret exists for this case and has no caller.

Today.

  • internal/ocm/grant.go GrantHandler: rest == "" answers 404, and only Authorization: Bearer <secret> is compared.
  • Nextcloud side: apps/files_sharing/lib/External/Storage.php mounts a received share with user = the token and AUTH_BASIC at the discovery webdav root (read for #1057). The OCM spec lists this as the deprecated legacy access.
  • The ocm-live-nc workflow only tests the direction Nextcloud to Cairn.
  • Cairn as the receiver already speaks the legacy form (client.go remoteBase, authorize); only the serving side lacks it.

Proposal.

  • Live check first against the lab Nextcloud: share from a Cairn dogfood to a Nextcloud user, accept, open the file, and record the exact requests (method, path, Authorization form, Depth). Extend ocm-live-nc with this direction.
  • If the gap is confirmed: serve the legacy form at /dav/ocm/ and /dav/ocm/<rel>. A Basic user name that matches a share's secret is looked up with ShareOutBySecret (constant-time comparison) and served exactly like the per-share address: the same status gate, the #1057 pause, liveness and item guard, the same jail, methods, audit and scan.
  • Decide whether the legacy form is offered to every peer or only to peers whose discovery says legacy, and document it.
  • If Nextcloud uses the per-share address after all: close this issue with the live check's evidence and keep the test.

Acceptance.

  • Basic base64(<secret>:) reads a shared file and lists a shared folder at both paths.
  • A wrong secret answers 401, an ended share 401, a paused or replaced share 404.
  • No path outside the share is reachable (jail tests for both forms).
  • The live check passes from Cairn to the lab Nextcloud: open, download, and upload for a share with write.

Refs. #1057 (decision: separate issue after a live check), research-1057.md §0 and Q9, #117, OCM.md.

**Problem.** When a Cairn user shares with someone on a vanilla Nextcloud over Open Cloud Mesh, the Nextcloud user most likely sees the share but cannot open it. - Nextcloud reads a received share with Basic authentication: the share's secret as the user name and no password, at the WebDAV root its discovery names. - Cairn serves only at the per-share address (`/dav/ocm/<providerId>/`) with a Bearer secret. `/dav/ocm/` with nothing after it answers 404. - `ocm.Store.ShareOutBySecret` exists for this case and has no caller. **Today.** - `internal/ocm/grant.go` `GrantHandler`: `rest == ""` answers 404, and only `Authorization: Bearer <secret>` is compared. - Nextcloud side: `apps/files_sharing/lib/External/Storage.php` mounts a received share with `user` = the token and `AUTH_BASIC` at the discovery `webdav` root (read for #1057). The OCM spec lists this as the deprecated legacy access. - The `ocm-live-nc` workflow only tests the direction Nextcloud to Cairn. - Cairn as the receiver already speaks the legacy form (`client.go` `remoteBase`, `authorize`); only the serving side lacks it. **Proposal.** - **Live check first** against the lab Nextcloud: share from a Cairn dogfood to a Nextcloud user, accept, open the file, and record the exact requests (method, path, Authorization form, Depth). Extend `ocm-live-nc` with this direction. - **If the gap is confirmed:** serve the legacy form at `/dav/ocm/` and `/dav/ocm/<rel>`. A Basic user name that matches a share's secret is looked up with `ShareOutBySecret` (constant-time comparison) and served exactly like the per-share address: the same status gate, the #1057 pause, liveness and item guard, the same jail, methods, audit and scan. - **Decide** whether the legacy form is offered to every peer or only to peers whose discovery says legacy, and document it. - **If Nextcloud uses the per-share address after all:** close this issue with the live check's evidence and keep the test. **Acceptance.** - Basic `base64(<secret>:)` reads a shared file and lists a shared folder at both paths. - A wrong secret answers 401, an ended share 401, a paused or replaced share 404. - No path outside the share is reachable (jail tests for both forms). - The live check passes from Cairn to the lab Nextcloud: open, download, and upload for a share with write. **Refs.** #1057 (decision: separate issue after a live check), research-1057.md §0 and Q9, #117, `OCM.md`.
Author
Owner

Research done (research-1070.md). The gap is real, and it is wider than this issue says.

How other servers read a received share

  • Nextcloud 32 to 35 and ownCloud 10 always use the root webdav address from discovery (/dav/ocm/), never the per-share address. They log in with Basic auth: the secret as the user name, no password.
  • Nextcloud 35+ can exchange the secret for a token, but only if the sender advertises that. Cairn doesn't.
  • OpenCloud and oCIS use Bearer at the per-share address.
  • Seafile uses Basic with padded colons and sends no Depth header.

Two more blockers

  1. Cairn's share listing (bare links: no types, sizes, ETags or permissions) is unreadable to Nextcloud, OpenCloud and Seafile.
  2. With a Nextcloud on the allow-list, Cairn's /status.php presents Cairn as a Nextcloud. After any failed request, Nextcloud then calls /index.php/apps/files_sharing/shareinfo. Cairn has no such route and answers with an auth challenge, so Nextcloud deletes the share for good. A paused share (404) or a stale cache can therefore wipe it on the Nextcloud side.

Recommendation

  • Look the share up from the credential (Basic user or Bearer), with one code path serving both addresses and all #1057 checks.
  • Return a standard PROPFIND listing with permissions and a folder ETag.
  • Answer paused shares with 503, not 404.
  • Add a minimal shareinfo handler that never answers 401 or 403.
  • Accept Basic only for shares sent in the old protocol form.
  • Token exchange gets its own issue.

The live-check plan is in §7 of the research file. Decisions follow.

**Research done** (`research-1070.md`). The gap is real, and it is wider than this issue says. **How other servers read a received share** - Nextcloud 32 to 35 and ownCloud 10 always use the root `webdav` address from discovery (`/dav/ocm/`), never the per-share address. They log in with Basic auth: the secret as the user name, no password. - Nextcloud 35+ can exchange the secret for a token, but only if the sender advertises that. Cairn doesn't. - OpenCloud and oCIS use Bearer at the per-share address. - Seafile uses Basic with padded colons and sends no Depth header. **Two more blockers** 1. Cairn's share listing (bare links: no types, sizes, ETags or permissions) is unreadable to Nextcloud, OpenCloud and Seafile. 2. With a Nextcloud on the allow-list, Cairn's `/status.php` presents Cairn as a Nextcloud. After any failed request, Nextcloud then calls `/index.php/apps/files_sharing/shareinfo`. Cairn has no such route and answers with an auth challenge, so **Nextcloud deletes the share for good**. A paused share (404) or a stale cache can therefore wipe it on the Nextcloud side. **Recommendation** - Look the share up from the credential (Basic user or Bearer), with one code path serving both addresses and all #1057 checks. - Return a standard PROPFIND listing with permissions and a folder ETag. - Answer paused shares with 503, not 404. - Add a minimal `shareinfo` handler that never answers 401 or 403. - Accept Basic only for shares sent in the old protocol form. - Token exchange gets its own issue. The live-check plan is in §7 of the research file. Decisions follow.
Author
Owner

Decisions (Nikola, 2026-11-02): all recommendations approved.

  1. Quick fix first, as its own release. A shareinfo handler that never answers 401 or 403, and paused shares answer 503 instead of 404.
  2. Then the full #1070:
    • One code path serves both addresses. Basic auth is accepted only for old-form shares (the protocol form is recorded when a share is sent); Bearer covers the rest.
    • A standard WebDAV listing with permissions and folder ETags.
    • MKCOL on writable shares.
    • Depth defaults to 1 for Seafile.
  3. Token exchange gets its own issue.
  4. Live checks: Nikola runs one before and one after the change.
**Decisions (Nikola, 2026-11-02): all recommendations approved.** 1. **Quick fix first, as its own release.** A `shareinfo` handler that never answers 401 or 403, and paused shares answer 503 instead of 404. 2. **Then the full #1070:** - One code path serves both addresses. Basic auth is accepted only for old-form shares (the protocol form is recorded when a share is sent); Bearer covers the rest. - A standard WebDAV listing with permissions and folder ETags. - MKCOL on writable shares. - Depth defaults to 1 for Seafile. 3. **Token exchange** gets its own issue. 4. **Live checks:** Nikola runs one before and one after the change.
Author
Owner

Decisions on the full-build spec's open points (2026-11-02, all as recommended):

  1. No extra 401 throttle beyond the existing per-IP rate limit.
  2. No audit note for the access form; the once-a-day INFO ocm: share read with the deprecated Basic form covers it.
  3. An unknown secret answers 401.
  4. The provider-id name clash is documented.
  5. Merge order: after #1072 (v0.6.392); this ships as v0.6.393.
  6. CI: when the job log API answers 404, read the runner pod log.

The quick fix (shareinfo answers, pauses as 503) is in PR #1076 as v0.6.388; this issue stays open for the full build.

**Decisions on the full-build spec's open points (2026-11-02, all as recommended):** 1. No extra 401 throttle beyond the existing per-IP rate limit. 2. No audit note for the access form; the once-a-day INFO `ocm: share read with the deprecated Basic form` covers it. 3. An unknown secret answers 401. 4. The provider-id name clash is documented. 5. Merge order: after #1072 (v0.6.392); this ships as v0.6.393. 6. CI: when the job log API answers 404, read the runner pod log. The quick fix (shareinfo answers, pauses as 503) is in PR #1076 as v0.6.388; this issue stays open for the full build.
Author
Owner

The quick fix shipped in v0.6.388 (PR #1076, tag v0.6.388). Both dogfoods run it: pods ready, no restarts, no new WARN/ERROR lines.

The shareinfo endpoint answers 200 for a live share, 503 + Retry-After: 300 for any pause, an uncertain lookup or OCM off, and 404 only for ended or unknown shares. A Nextcloud recipient therefore keeps a share that is only paused. The live check with the lab Nextcloud is on #1005. This issue stays open for the full build (v0.6.393).

The quick fix shipped in **v0.6.388** (PR #1076, tag v0.6.388). Both dogfoods run it: pods ready, no restarts, no new WARN/ERROR lines. The shareinfo endpoint answers 200 for a live share, 503 + `Retry-After: 300` for any pause, an uncertain lookup or OCM off, and 404 only for ended or unknown shares. A Nextcloud recipient therefore keeps a share that is only paused. The live check with the lab Nextcloud is on #1005. This issue stays open for the full build (v0.6.393).
Author
Owner

Correction to decision 1 (no 401 throttle): the recommendation assumed an existing per-IP rate limit on /dav/ocm/. The build found there is none there; only shareinfo has one (240/min per IP). The outcome stays the same: share secrets are 128-bit from crypto/rand, so guessing is infeasible, and a miss costs one constant-time pass over the records. The remaining risk is request flooding, the same as before for unknown provider ids.

Kept as decided: no 401 throttle. Added to the backlog: make 401 volume on /dav/ocm/ visible to operators. Also fixed before release, from the final review: folder-ETag walks are limited to 4 at a time per instance, and the tag cache is bounded by total size.

**Correction to decision 1 (no 401 throttle):** the recommendation assumed an existing per-IP rate limit on `/dav/ocm/`. The build found there is none there; only shareinfo has one (240/min per IP). The outcome stays the same: share secrets are 128-bit from crypto/rand, so guessing is infeasible, and a miss costs one constant-time pass over the records. The remaining risk is request flooding, the same as before for unknown provider ids. Kept as decided: no 401 throttle. Added to the backlog: make 401 volume on `/dav/ocm/` visible to operators. Also fixed before release, from the final review: folder-ETag walks are limited to 4 at a time per instance, and the tag cache is bounded by total size.
Cordy closed this issue 2026-11-04 01:23:28 +00:00
Author
Owner

Shipped in v0.6.393 (PR #1095, merge fec99347). Both dogfoods run it, 0 restarts, no ERROR lines. On cairn-openbao (the OCM instance), /dav/ocm/ with no secret answers 401 with both challenges, an unknown secret 401 with Basic and Bearer, and discovery lists file with /dav/ocm/ only.

The hands-on check with the lab Nextcloud is section G on #1005, including the ocm-live-nc CI job (it needs the secrets CAIRN_URL, CAIRN_USER, CAIRN_APP_PW). Until it has passed, the docs describe the Nextcloud and ownCloud behaviour as expected. Follow-ups: #1089 (token exchange), #1090 (jwksUri), #1091 (Seafile), #1092 (OpenCloud URI), #1093 (delete/rename).

Closing.

Shipped in **v0.6.393** (PR #1095, merge fec99347). Both dogfoods run it, 0 restarts, no ERROR lines. On cairn-openbao (the OCM instance), `/dav/ocm/` with no secret answers 401 with both challenges, an unknown secret 401 with Basic and Bearer, and discovery lists `file` with `/dav/ocm/` only. The hands-on check with the lab Nextcloud is section **G** on #1005, including the `ocm-live-nc` CI job (it needs the secrets `CAIRN_URL`, `CAIRN_USER`, `CAIRN_APP_PW`). Until it has passed, the docs describe the Nextcloud and ownCloud behaviour as expected. Follow-ups: #1089 (token exchange), #1090 (jwksUri), #1091 (Seafile), #1092 (OpenCloud URI), #1093 (delete/rename). 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#1070
No description provided.