Repository navigation
Description
Found during review of #241 by CodeRabbit. Pre-existing, not introduced there.
What happens
deleteDocCollection checks the workspace level doc:write capability, then emptyCollection updates every document whose collection_id matches, with no per document authorization:
packages/core/src/content/doc-service.ts emptyCollection / deleteDocCollection
Elsewhere a write goes through assertDocWritable, which honours doc_access and the document's visibility. This path does not. So a member who may manage documents can relocate a document they are not allowed to edit by deleting the collection it sits in.
What it does and does not do
- It changes where a document is filed. Nothing is deleted, no content is read, and no visibility changes.
- It predates Fix the docs outage, and let MCP actually file a document #241.
emptyCollectionalready moved every document in the collection to unfiled; Fix the docs outage, and let MCP actually file a document #241 only added the option to move them to a named collection instead.
The decision to make
The fix is not just adding a check, it is choosing what should happen when a collection holds a document the deleter cannot write:
- refuse the whole delete and name the documents in the way, or
- delete the collection, relocate only the documents the caller may write, and leave the rest where they are, which leaves rows pointing at a collection that no longer exists unless the column is nulled anyway, or
- restrict collection deletion to a role that can modify every document in the organisation.
Option 1 is the most predictable and the easiest to explain, but it makes a delete fail for a reason the person cannot see or fix. Worth deciding deliberately rather than picking one inside an outage fix.
Whichever is chosen needs a test that a member without write access to a document cannot move it by deleting its collection.
Activity
imshashank commentedon Aug 15, 2026
Re-verified on
3ba32cb. Still reproduces exactly as described, unchanged since filing.deleteDocCollectioninpackages/core/src/content/doc-service.tsstill checks only the workspace-level capability:and
emptyCollectionstill performs an unfiltered bulk update over every document in the collection, with noassertDocWritableand nodocReadFilter:Adding triage labels, since this arrived with only
bug. Markedsecurityandp1 highon the reasoning already in the description: it is a write that bypasses per-document authorization, which is a boundary the rest of the docs service enforces. The impact is genuinely limited, as the issue is careful to say, since it relocates rather than reads or deletes, so this is not urgent in the way a read leak would be.Marked
needs designbecause the fix is still the choice between the three options listed here rather than a check to drop in, and that choice has not been made. Option 1, refuse the delete and name the documents in the way, is the most defensible and is the one I would pick: it is the only one that leaves no surprising state, and the error message doubles as an explanation of why. Option 2 leaves rows pointing at a deleted collection, and option 3 changes who can manage collections at all, which is a larger product change than this bug warrants.Worth confirming with a test either way.
packages/core/tests/content/doc-service.test.tsalready builds principals with differing document access, so the fixtures for this exist.