fix: validate displayId ownership on response creation (ENG-825) #8046

Openmattinannt wants to merge 1 commit into main from pull/8046/head· opened 2 days ago
+67−2
mattinannt commented 2 days agoAuthor

Summary

  • Adds a new getDisplayForResponseValidation helper in apps/web/lib/display/service.ts that fetches a Display by ID along with its workspace and existing response linkage
  • In POST /api/v1/client/{workspaceId}/responses and POST /api/v2/client/{workspaceId}/responses, validates the optional displayId parameter before creating the response: checks the display exists, belongs to the same workspace, belongs to the same survey, and is not already linked to another response
  • Fixes GHSA-43vf-x743-579v: without this, an attacker could link a display from their own workspace to a response in another workspace, polluting display statistics and circumventing survey frequency controls

Test plan

  • Submit a response with no displayId: should succeed as before
  • Submit a response with a valid displayId matching the correct workspace and survey: should succeed
  • Submit a response with a displayId from a different workspace: expect 400
  • Submit a response with a displayId from the correct workspace but a different survey: expect 400
  • Submit a response with a displayId already linked to another response: expect 400
mattinannt added 1 commit 2 days ago
fix: validate displayId ownership on response creation (ENG-825)a7640e9

Review required

Review the changes, then submit to get graded.

Some checks haven’t completed yet

1 check: dojo / review-grader

Keyboard shortcuts

Site-wide

Focus the search bar
/
Show this dialog
?

Pull request

Move to the next file
j
Move to the previous file
k
Filter changed files
t
Comment on the selected lines
c
Select a range of lines
Shiftclick