fix: reject access to documents not owned by current user#135
fix: reject access to documents not owned by current user#135greatjourney589 wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughImports ChangesCross-tenant document access fix
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Per issue MkDev11#133's Expected behavior, the rejection should mirror the get(doc_id) endpoint and return "Document not found!" so an unauthorized caller cannot distinguish an existing-but-not-owned document from a non-existent one (cross-tenant ID enumeration). DocumentService.accessible already returns False uniformly for both cases, so this is the correct, non-leaking message. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
I am going to close this PR as not applicable |
Summary
Fixes a cross-tenant document access vulnerability in the SDK document
endpoint. The handler looked up a document by
document_idwithout checkingthat the document belonged to the current user, so any authenticated user
could read another tenant's document by supplying its ID.
This adds an ownership check via
DocumentService.accessible(document_id, current_user.id)before the document is fetched, returning an error resultwhen the current user does not own the document.
current_useris importedfrom
api.appsto support the check.Related Issues
Fixes #133
Type of Change
Testing
pnpm buildpassesownership check rejects access to documents not owned by the requesting
user and still allows owned documents.
Checklist
Summary by CodeRabbit