OUT-4047: scope deleteChannelMapsByIds to the caller's portal - #131
Open
SandipBajracharya wants to merge 2 commits into
Open
OUT-4047: scope deleteChannelMapsByIds to the caller's portal#131SandipBajracharya wants to merge 2 commits into
SandipBajracharya wants to merge 2 commits into
Conversation
deleteChannelMapsByIds soft-deleted channels and their file rows by id with no portal guard, so a service for one portal could delete another workspace's channel if a foreign id was passed. Scope both UPDATEs in the transaction to this.user.portalId. Current callers already pass owned ids, so their behavior is unchanged. Adds an integration regression test: a foreign-portal channel id is ignored, while the caller's own channel still cascade soft-deletes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR scopes channel-map soft deletion to the authenticated portal, preventing supplied foreign channel IDs from deleting another workspace’s records.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant Service as MapFilesService
participant DB
Caller->>Service: deleteChannelMapsByIds(ids)
Service->>DB: Begin transaction
Service->>DB: Soft-delete channels matching ids + caller portal
Service->>DB: Soft-delete file rows matching channel ids + caller portal
DB-->>Service: Commit
Service-->>Caller: Complete
Reviews (2): Last reviewed commit: "test(OUT-4047): cover mixed owned+foreig..." | Re-trigger Greptile |
deleteChannelMapsByIds takes a batch; assert a call mixing an owned and a foreign channel id deletes only the owned one. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator
Author
|
@greptileai review again |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
MapFilesService.deleteChannelMapsByIds(ids)soft-deleted channels and their file rows purely by id, with no portal guard. A service authenticated for one portal could soft-delete a channel (and all its file rows) owned by another workspace if a foreign channel id was passed — a tenant-isolation break on a destructive operation.Not currently exploitable (both callers pre-scope ids:
listFormattedChannelMapderives them from the portal-guardedgetAllChannelMaps, andSync.service.tspasses the channel being synced), but a destructive bulk method should enforce the boundary itself.Fix
Scope both UPDATEs in the transaction to
this.user.portalId:and(inArray(channelSync.id, ids), eq(channelSync.portalId, this.user.portalId))and(inArray(fileFolderSync.channelSyncId, ids), eq(fileFolderSync.portalId, this.user.portalId))Both existing callers pass owned ids, so their behavior is unchanged.
Test
New integration regression test (
test/flows/channel-cascade-portal-guard.integration.test.ts):deletedAt+status=false, file rows soft-deleted)Verified the guard test fails without the fix (foreign channel gets deleted) and passes with it.
Verification
pnpm test:integration test/flows/channel-cascade-portal-guard.integration.test.ts→ 2/2 passpnpm typecheckclean ·pnpm lintcleanContext
Surfaced by Greptile during review of the OUT-4044 test PR (#130); split out as a standalone production fix.
🤖 Generated with Claude Code