Skip to content

fix: enforce ownership check on /accounts/:id to close IDOR#103

Open
hacktron-app-stg[bot] wants to merge 1 commit into
add-payments-rbfrom
hacktron/fix-299ce0ed
Open

fix: enforce ownership check on /accounts/:id to close IDOR#103
hacktron-app-stg[bot] wants to merge 1 commit into
add-payments-rbfrom
hacktron/fix-299ce0ed

Conversation

@hacktron-app-stg

Copy link
Copy Markdown

Vulnerability

GET /accounts/:id (payments.rb:24-27) returned the JSON representation of any account addressed by id, with no check that the account belongs to the authenticated user. Since account ids are enumerable, an attacker could request /accounts/1, /accounts/2, … and read other users' balances and private details — a classic Insecure Direct Object Reference / broken access control (high severity).

Fix

Add an object-level authorization check to the handler:

  • halt 401 when there is no authenticated session[:user].
  • halt 403 unless the requested params[:id] matches the authenticated user.

Only then is the account returned. This matches how the existing /transfer handler already treats session[:user] as the account key in ACCOUNTS, so the ownership comparison is correct for this data model.

Verification

Reviewed the surrounding code to confirm ACCOUNTS is keyed by user id (see /transfer, which uses ACCOUNTS[session[:user]]). Ruby is not installed in the sandbox, so ruby -c could not be run; the change uses only standard Sinatra halt/session idioms already present in the file. No test infrastructure exists in the repo, so no regression test was added.


Automated fix by Hacktron for finding: https://staging.hacktron.ai/testestesttest/findings/299ce0ed-6707-4305-9285-7963cd0ccf2d

The /accounts/:id endpoint returned any account by id without verifying
ownership, allowing id enumeration to leak other users' account data.
Reject requests with 401 when unauthenticated and 403 unless the
requested id matches session[:user] before returning the account.
@hacktron-app-stg
hacktron-app-stg Bot requested a review from maekuss July 23, 2026 04:15
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.

0 participants