If a user bids multiple times, their previous bid value will be overwritten and funds will be lost.
fn bid
function :
In bid
function the bid value of a user is stored into a mapping bid_values
:
In Cairo, when we perform two write
operations on the same key in a Map
, the second operation will overwrite the value set by the first. If a particular user bids twice then their bid value will get overwritten with the most recent one.
POC:
Alice bids 100USDC
=> self.bid_values.entry(Alice).write(100);
=> bid_values: Map<Alice,100> (pseudo code entry of the mapping)
Marry bids 150USDC
=> self.bid_values.entry(Marry).write(150);
=> bid_values: Map<Marry,150> (pseudo code entry of the mapping)
Alice bids 200USDC (again)
=> self.bid_values.entry(Alice).write(200);
=> bid_values: Map<Alice,200> (pseudo code entry of the mapping)
Now, the current mapping of Alice will store bid amount as 200USDC overwriting the previous amount of 100USDC. Hence Alice will loose 100USDC because there is no way to track/withdraw the previous bid.
If user bids more than once, they will loose their previous bid amount funds.
Manual review
Use arrays to store multiple values of bid amount for a particular user
Use nested mapping
In the `bid` function the bid values are stored using `self.bid_values.entry(sender).write(amount)` directly, but this overwrites any previous bids made by the same bidder. Therefore if a participant makes 2 or more bids, the participant can then withdraw only the last value of the last bid. That is incorrect, the protocol should save all bids and a participant should withdraw the value of the all unsuccessful bids.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.