Repository navigation
Description
What happens
poll:vote is the only poll handler that does not check the socket's own session. Every other one calls authorizeOrganizerAction, which binds the action to client.sessionId. The vote handler reads sessionId straight out of the message payload:
// apps/ws-server/src/utils/handleMessages.ts
case 'poll:vote': {
const { sessionId, pollId, optionId, participantId } = payload;
const voterId = client.participantId || participantId;
if (!voterId || !sessionId || !pollId || !optionId) break;
const result = votePoll(sessionId, pollId, optionId, voterId);Compare with the helper every other poll handler uses:
// apps/ws-server/src/utils/organizerAuth.ts
if (payload?.sessionId && payload.sessionId !== client.sessionId) {
sendError(client, "SESSION_MISMATCH", "This message is for a different session.");
return null;
}Why it matters
A participant joined to session A can send poll:vote with session B's id. If they can guess or observe a poll id in another session, their vote lands there. votePoll looks the poll up purely by the payload's sessionId and never asks whether the socket belongs to it.
The vote also broadcasts to the other session, so participants in B see a vote count move for someone who was never in the room.
Reproducing
- Join session A as a participant
- Have a host start a poll in session B, note its
pollIdandsessionId(both are in thepoll:startedbroadcast to B's participants) - From A's socket send
{ type: 'poll:vote', payload: { sessionId: B, pollId: B's poll, optionId: ..., participantId: <A's id> } } - The vote is counted in B
The fix
Use the socket's own session, the same as every other handler:
case 'poll:vote': {
if (!client.sessionId || !client.participantId) break;
const { pollId, optionId } = payload;
if (!pollId || !optionId) break;
const result = votePoll(client.sessionId, pollId, optionId, client.participantId);Note the second half: client.participantId || participantId also lets a client supply someone else's participant id when the socket has none, which both ballot-stuffs and overwrites another player's vote. The id should come only from the socket, which is set at join time.
A test in apps/ws-server/src/utils/handleMessages.poll.test.ts should cover both: a vote with a foreign sessionId is refused, and a vote with a foreign participantId is attributed to the socket's own participant.
Files
apps/ws-server/src/utils/handleMessages.ts— thepoll:votecaseapps/ws-server/src/utils/handleMessages.poll.test.ts— tests
Activity
divyanshAgarwal123 commentedon Nov 25, 2026
Could you assign #251 to me? I checked main
dc7a83c: the vote handler still derives routing/identity from the payload, while the existing organizer guard binds other actions to the socket. No test or source fix is claimed yet. I would bind the vote and broadcast to the joined socket session, require its participant identity, reject a mismatched supplied session consistently, and add focused regressions for cross-session messages, spoofed/missing identities, valid votes and duplicate votes, followed by the complete ws-server and existing CI gates. This stays separate from #252 storage work, which should integrate this narrow change first.My #242 configuration/dependency-triage stage is delivered in ready #265 with all 15 checks passing; stored CodeQL source triage is waiting on the single read-access handoff. Please confirm your active-issue limit when allocating further work. #251 already has your
nsoc26/level3; I will wait for actual assignment before coding and will not publish exploit detail beyond the issue you already opened.