Listing an offer while the origin offer is aborted should be disallowed, but it is not. This can lead to a critical situation that leading to breaking the main invariant of the protocol, stealing fund, and lack of balances.
Alice(maker) creates a turbo ask offer to sell 1000 points for $1 with collateral rate 12000 (equivalent to 120%), and deposits $1.2.
Bob (taker1) places a bid order against Alice's offer and buys those 1000 points for $1. So, he deposits $1. We will have:
Alices aborts her offer by calling abortAskOffer
. It means that Alice will not provide the promised 1000 points to Bob. We will have:
Bob lists his offer by calling listOffer
to list 1000 points. By doing so, Bob is promising that he will sell 1000 points for $1 (these 1000 points are those 1000 points that were promised by Alice).
Since Alice's offer is aborted, Bob calls closeBidTaker
. By doing so, Bob receives Alice's collateral, which is $1.2, because this is the punishment to Alice for not keeping her promise. We will have:
Charlie (taker2) places a bid order against Bob's offer and buys 1000 points for $1, so he deposits $1. We will have:
Bob in total has $2.2 withdrawable amount as RemainingCash
and SalesRevenue
, while he only deposited $1 to place a bid order against Alice's offer. So, Bob could gain $1.2.
Now, Charlie already deposited $1 against Bob's offer, but there is no points to be provided to him. If Charlie calls closeBidTaker
, we will have:
The total withdrawable collateral amount is Alice's SalesRevenue + Alice's MakerRefund + Bob's SalesRevenue + Bob's RemainingCash + Charlie's RemainingCash = $1 + $0.2 + $1 + $1.2 + $1.2 = $4.6
, while total deposited collateral amount into the protocol is Alcie's collateral + Bob's deposit + Charlies'deposit = $1.2 + $1 + $1 = $3.2
This breaks the main invariant of the protocol since the input and output amounts are not balanced.
What happened is:
Alice promises that she will provide 1000 points to Bob. Then Alices aborts. Bob lists an ask offer of 1000 points, i.e. he promises that he will provide 1000 points that were promised by Alice. Since, Alice has already aborted, Bob is promising over nothing. This is the root cause of this issue, the protocol should not allow listing (sub-offering) on an aborted offer. Then Bob closes his bid order against Alice's offer, and he receives Alice's collateral. Then Charlie places a bid order on Bob's offer. So far, Bob received two incomes, one from Alice's collateral, and one from Charlie's order.
Moreover, when an ask offer is aborted, its abortOfferStatus
is set to AbortOfferStatus.Aborted
, but if an offer is listed over this aborted offer, it changes its abortOfferStatus
to AbortOfferStatus.SubOfferListed
.
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/PreMarkets.sol#L631
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/PreMarkets.sol#L342
Please note that this report may be seemed to be similar to the finding with title Aborted ask offer returns the extra collateral to the maker that leads to breaking a main invariant of the protocol
. But, the root cause of the issue and the fix are totally different.
The following test implements the above scenario completely. The output is as follows. Total deposited amount into the protocol is $3.21, where $0.1 is as platform fee.
Breaking the main invariant of the protocol.
Stealing fund.
The protocol should not allow listing (sub-offering) on an aborted offer:
https://github.com/Cyfrin/2024-08-tadle/blob/main/src/core/PreMarkets.sol#L335C1-L343C10
Leaving high severity for now but will leave open for appeals. Technically, users can choose not to transact this type offers if they are aware of such undercollaterized relisted offers, in which case it will have no impact. However, if subsequent takers transact this relisted offers, this can allow profits without having to settle any points.
Leaving high severity for now but will leave open for appeals. Technically, users can choose not to transact this type offers if they are aware of such undercollaterized relisted offers, in which case it will have no impact. However, if subsequent takers transact this relisted offers, this can allow profits without having to settle any points.
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.