fix(feedback): scope getAllChatMessageFeedback to the caller workspace - #6701
Open
pri12ya871 wants to merge 1 commit into
Open
fix(feedback): scope getAllChatMessageFeedback to the caller workspace#6701pri12ya871 wants to merge 1 commit into
pri12ya871 wants to merge 1 commit into
Conversation
/api/v1/feedback is in WHITELIST_URLS, so getAllChatMessageFeedback was reachable without authentication and performed no ownership check, letting anyone read feedback for any chatflow by id. Mirror the getAllLeadsForChatflow pattern: resolve req.user.activeWorkspaceId and verify the chatflow belongs to that workspace before reading feedback. This fails closed for anonymous callers without changing WHITELIST_URLS, so the public POST path used by embedded chatbots is unaffected. Adds tests covering the anonymous caller, a chatflow outside the caller's workspace, and the authorized path. Fixes FlowiseAI#6694
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
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.
What
GET /api/v1/feedback/:chatflowidwas reachable without authentication and performed no ownership check, so anyone could read feedback for any chatflow by id.Fixes #6694
Why this shape
/api/v1/feedbackis inWHITELIST_URLS(packages/server/src/utils/constants.ts:20), soauthenticateTokennever runs andgetAllChatMessageFeedbackreceivedchatflowidstraight from the URL with no workspace scoping.The obvious fix — dropping the entry from
WHITELIST_URLS— would break embedded chatbots, becausePOST /api/v1/feedback(routes/feedback/index.ts:6) is how public widgets submit feedback and has to stay anonymous. The GET and the POST share one whitelist entry at two different trust levels./api/v1/leadssits immediately below feedback in that same whitelist and is not vulnerable —getAllLeadsForChatflowresolvesreq.user?.activeWorkspaceIdand verifies chatflow ownership before reading, which fails closed for an anonymous caller. This PR mirrors that pattern in the GET handler and leavesWHITELIST_URLSuntouched.Tests
Adds
packages/server/src/controllers/feedback/index.test.ts(5 tests): anonymous caller, chatflow outside the caller's workspace, workspace scoping of the ownership lookup, missing id, and the authorized path.I checked that the tests actually catch the bug rather than passing vacuously — reverting the controller change makes 3 of the 5 fail, including the anonymous-caller case.
tsc --noEmitandprettier --checkare both clean.Still open
updateChatMessageFeedbackForChatflow(the PUT on the same whitelisted path) also performs no workspace check —validateFeedbackForUpdateonly confirms the feedback row exists. I left it out to keep this PR to a single concern; happy to fold it in here or follow up separately, whichever you prefer.Also asked on the issue: given the responsible-disclosure policy in
SECURITY.md, tell me if you would rather handle security fixes internally and I will close this.