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
Summary
getDisplayForResponseValidationhelper inapps/web/lib/display/service.tsthat fetches a Display by ID along with its workspace and existing response linkagePOST /api/v1/client/{workspaceId}/responsesandPOST /api/v2/client/{workspaceId}/responses, validates the optionaldisplayIdparameter 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 responseTest plan
displayId: should succeed as beforedisplayIdmatching the correct workspace and survey: should succeeddisplayIdfrom a different workspace: expect 400displayIdfrom the correct workspace but a different survey: expect 400displayIdalready linked to another response: expect 400