Skip to content

Bug: game_id in URL does not impact access to game state so long as player_id is valid #2514

@khushal-winner

Description

@khushal-winner

Describe the bug
Broken Access Control (IDOR - Insecure Direct Object Reference) in Phoenix LiveView route /games/:game_id/players/:id.

The :game_id parameter from the URL is completely ignored in the socket handle_params/3. The code fetches the player by :id only, then loads the game using player.game_id instead of verifying the URL-provided game_id. This allows any user to view any player's full game state (cards, hand, status, etc.) by forging the game_id part of the URL while keeping a valid player_id.

Steps to Reproduce

  1. Open a player view page, for example:
    /games/01KJQJAR0B57E96P7YJBDCEVYG/players/01KJQJBZGWBQBEKFYE7AMZ01S0
  2. Copy the full URL and change only the game_id segment to any random/invalid string, e.g.:
    /games/999999999999999999/players/01KJQJBZGWBQBEKFYE7AMZ01S0
  3. Load the modified URL in the same browser/session.
  4. Observe that the page loads successfully and displays the correct player data, including:
    • Full hand/cards
    • Player status
    • Game-specific state
      (despite the game_id in the URL being completely wrong/forged)

Video Demo

2026-03-05.03-34-40.mp4

Expected behavior
When a user visits /games/:game_id/players/:id, the application must verify that the provided :game_id exactly matches the game_id associated with that player_id in the database. If they do not match, the socket should return a 404 Not Found, redirect to a safe page, or show an access denied message.

Desktop (please complete the following information):

  • OS: any (Windows / macOS / Linux / iPadOS etc.)
  • Browser: any modern browser (Chrome, Firefox, Safari, Edge)
  • Version: any recent version

Additional context

  • Reproducible by changing only the game_id segment in the URL → same player data/cards still load correctly
  • Only basic rate limiting appears to be present

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions