Skip to content

Fix: authorization check in toggle_vote to prevent cross-game voting#2625

Open
xovishnukosuri wants to merge 1 commit intoOWASP:masterfrom
xovishnukosuri:fix/toggle-vote-authorization-check
Open

Fix: authorization check in toggle_vote to prevent cross-game voting#2625
xovishnukosuri wants to merge 1 commit intoOWASP:masterfrom
xovishnukosuri:fix/toggle-vote-authorization-check

Conversation

@xovishnukosuri
Copy link

Summary

  • Adds an authorization check in the toggle_vote event handler in player_live/show.ex to verify that the dealt_card_id belongs to a player in the current game before allowing the vote
  • If the dealt card does not belong to the current game, the vote is silently rejected and a warning is logged
  • Adds a test that creates two separate games and confirms that voting on a card from another game is rejected

Details

The toggle_vote handler previously fetched a dealt card using only the dealt_card_id from the event payload without any authorization check. A player could forge the dealt_card_id in browser devtools to cast votes on cards from any game.

The fix collects all dealt card IDs from the current game's players (already preloaded on the socket) and checks membership before proceeding with the vote logic. This follows the same pattern as the approach suggested in the issue.

Fixes #2520

Test plan

  • Existing toggle_vote test (add/remove vote on own game's card) still passes
  • New test: toggle_vote rejects vote on a dealt card from another game — creates a second game with a dealt card and confirms that voting on it from game 1 results in zero votes on that card

🤖 Generated with Claude Code

The toggle_vote event handler previously accepted any dealt_card_id without
verifying it belonged to the current game. A player could forge the
dealt_card_id in browser devtools to vote on cards from other games.

This adds a check that collects all dealt card IDs from the current game's
players and rejects the vote with a warning log if the dealt_card_id does
not belong to the game.

Fixes OWASP#2520

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Missing authorization check in toggle_vote allows players to vote on cards from any game

1 participant