Skip to content

fix(platform): hide project-scoped files from the WebDAV tree - #2559

Merged
yannickmonney merged 1 commit into
mainfrom
fix/webdav-project-scope-2545
Jul 7, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
fix/webdav-project-scope-2545

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

Problem

Project files (documents.projectId set) carry no folderId, so the WebDAV tree — which filtered on lifecycle only — treated them as root-level hub documents. Any org member with an app password could:

  • list them (PROPFIND on the root via tree_queries.listCollection),
  • read them (leaf resolution by title resolved project docs for GET),
  • overwrite them (tree_mutations.ingestPutBlob bound a colliding PUT to the project row and replaced its blob),
  • delete/move/copy them (softDeleteDocument, moveResource, copyResource and the name-collision lookups had no project gate).

Fix

Make WebDAV a hub-only surface, mirroring the REST API's opaque 404s. The visibility predicate — active AND not project-scoped — lives in convex/webdav/visibility.ts (isWebdavVisibleDocument), built on the canonical scope check isProjectScopedDocument in convex/documents/access.ts.

  • tree_queries: listCollection (both the documents and .trash namespaces), leaf resolution (title match and the <title>_<docId> disambiguation form), the .trash leaf lookup, and getDocumentProps exclude project docs — every method handler (PROPFIND/GET/PUT/DELETE/MOVE/COPY/LOCK/PROPPATCH) routes through these, so a project file's path behaves as not-found everywhere.
  • tree_mutations: the ingestPutBlob overwrite lookup and findCollision are blind to project docs, so a PUT whose filename collides with a project file creates an independent hub document and MKCOL/MOVE/COPY are neither blocked by nor overwrite-trash them; softDeleteDocument, moveResource, and copyResource answer NOT_FOUND for a project-scoped target; the folder cascade/copy/fixup recursions skip project rows (defense-in-depth — project docs carry no folderId today).
  • convex/webdav/README.md documents the hub-only rule next to the Hono-trust split.

WebDAV cannot evaluate project membership (the Hono-trust split asserts only organizationId + userId), so per the issue the rule is uniform not-found for every caller; project members reach their files through the project surfaces. Note: documents/access.ts here is a minimal extraction of isProjectScopedDocument — identical name/signature/doc comment to the fuller file PR #2549 introduces, so whichever lands second resolves trivially to the superset.

Tests (red → green)

New convex/webdav/tree_queries.test.ts and a tree_mutations.test.ts project-scope block, all failing on main (13 failed) and passing with the fix:

  • root and in-folder listCollection exclude project docs; hub docs still list,
  • resolvePath not_found for a project doc (root, in-folder, <title>_<docId> form); hub docs still resolve,
  • getDocumentProps returns null for a project doc,
  • .trash neither lists nor resolves a trashed project doc,
  • PUT collision creates an independent hub doc; the project row and blob are untouched,
  • DELETE/MOVE/COPY of a project doc → NOT_FOUND, row unchanged,
  • MOVE with Overwrite: T onto a project file's name never trashes it; MKCOL is not blocked by one.

Verified: all 14 webdav suites green (247 tests), convex/documents suite green (226 tests), platform tsc --noEmit clean, oxlint --type-aware clean, knip clean, oxfmt --check clean.

Closes #2545

Project files (documents.projectId set) carry no folderId, so every
WebDAV lookup — filtering on lifecycle only — treated them as root-level
hub documents: any org member with an app password could list, read,
overwrite (PUT name collision), delete, move, and copy them (#2545).

Make WebDAV a hub-only surface, mirroring the REST API's opaque 404s:

- visibility.ts owns the predicate (active AND not project-scoped),
  built on documents/access.ts isProjectScopedDocument — the same
  canonical scope check PR #2549 gives the platform surfaces.
- tree_queries: listCollection (documents and .trash), leaf resolution
  (title and <title>_<docId> forms), the .trash leaf lookup, and
  getDocumentProps all exclude project docs.
- tree_mutations: ingestPutBlob's overwrite lookup and findCollision
  are blind to project docs (a colliding PUT creates an independent hub
  document); softDeleteDocument, moveResource, and copyResource answer
  NOT_FOUND for a project-scoped target; the folder cascade/copy/fixup
  recursions skip project rows.

Regression tests cover root and in-folder list/resolve, props, trash,
PUT collision, delete, move, copy, and MKCOL against seeded project
docs.

Closes #2545
@yannickmonney
yannickmonney merged commit 66cc4f5 into main Jul 7, 2026
14 of 16 checks passed
@yannickmonney
yannickmonney deleted the fix/webdav-project-scope-2545 branch July 7, 2026 12:27
larryro added a commit that referenced this pull request Jul 8, 2026
documents/access and webdav/visibility landed in #2559 without the
regenerated _generated/api.d.ts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: WebDAV exposes project-scoped files at the tree root — listable, readable, and overwritable by any org member

1 participant