anyone can call function sponsor
The sponsor function in a smart contract lacked access control, allowing anyone to call it with an arbitrary address and transfer tokens from that address if they had a positive allowance to the contract. An attacker could steal tokens from any user who had approved the contract.
paulius.eth Follow with 0xRajeev, cmichel and 1 other
Originally disclosed on Code4rena
Submitted by paulius.eth, also found by 0xRajeev, cmichel, and shw
This function sponsor should only be called by the factory, however, it does not have any auth checks, so that means anyone can call it with an arbitrary _sponsorAddress address and transfer tokens from them if the allowance is > 0:
/// @notice ability to add liqudity to the pot without being able to win.
/// @dev called by Factory during market creation
/// @param _sponsorAddress the msgSender of createMarket in the Factory
function sponsor(address _sponsorAddress, uint256 _amount)
external
override
{
_sponsor(_sponsorAddress, _amount);
}
Recommend checking that the sender is a factory contract.
Splidge (Reality Cards) confirmed:
This is a good one!
mcplums (Reality Cards) commented:
Yeah this is massive one!! Thanks @pauliax :)
Splidge (Reality Cards) resolved:
fixed here
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The sponsor function lacked any access control, allowing any caller to specify an arbitrary address and transfer tokens from it.
Impact
An attacker could transfer tokens from any user who had a positive allowance to the contract, potentially stealing funds.
What the attacker needed
Victim has approved the contract; attacker can call the function
The fix
The function was fixed by adding a check that the sender is the factory contract.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In smart contracts, some functions are meant to be called only by specific contracts or users. Here, a function that moves tokens was open to anyone. If a user had given the contract permission to spend their tokens, an attacker could call this function and take those tokens.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.