Skip to content

[server] - Security: Staking Endpoints Accept user_id from Request Body #631

Description

@Hydrax117

Description

StakeBody.user_id and ClaimBody.user_id in staking_handler.rs come from the JSON request body. Any authenticated user can stake or claim rewards on behalf of any other user by supplying a different UUID. There is no verification that the calling user owns the user_id in the payload.

// staking_handler.rs — current (INSECURE)
pub struct StakeBody {
    pub user_id: String,  // ← client-controlled
    pub stellar_address: String,
    pub amount: i64,
}

Acceptance Criteria

  • user_id is extracted from JWT claims (via ClaimsExt or web::ReqData<Uuid>), never from the request body
  • stellar_address is validated against the authenticated user's registered Stellar account in the database
  • A test verifies that supplying a different user's ID in the body returns 403 Forbidden
  • unstake/{user_id} path parameter is also validated against JWT identity

Technical Notes

Follow the pattern in reputation_handler::get_my_reputation which already uses web::ReqData<Uuid> correctly.


Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions