Soroban Smart Contract Flaw: `payout.distribute_winnings()` Auth Bypass via Order-of-Operations Bug
A critical security vulnerability has been identified in a Soroban smart contract, allowing an attacker to bypass authorization checks and potentially trigger unauthorized fund distributions. The flaw resides in the `distribute_winnings()` function within the `payout` contract, where a logic error in the sequence of checks creates a direct path for exploitation.
The function first compares a user-supplied `caller` address against a stored `admin` address. If they match, the function proceeds without immediately verifying the transaction's signature. The crucial `caller.require_auth()` check, which enforces that the transaction was actually signed by the supplied address, is performed *after* this equality test. This means an attacker can pass the *value* of the admin's address as the `caller` parameter, pass the initial `if` check, and then have the function call `require_auth()` on the attacker's own address—which would succeed, as the attacker controls that signature. The contract would then execute the privileged `distribute_winnings` logic under the attacker's authority.
This vulnerability represents a fundamental failure in access control logic, turning a function intended for a single authorized administrator into one that could be invoked by any user who understands the contract's interface. The impact is direct and severe: unauthorized access to a core administrative function responsible for distributing funds. It underscores the critical importance of order-of-operations in security-sensitive code, where signature verification must be the immutable first gate, not a subsequent step that can be sidestepped.