RubiconMarket._buys will not work for V1 offers due to the reversion in cancel method.
The _buys function in RubiconMarket attempts to cancel dust offers, but for V1 offers the cancel method reverts because it tries to send the pay token to the zero address. This blocks the _buys function from completing.
Submitted by zhuXKET, also found by adriro, cducrest and bin2chen.
RubiconMarket._buys tries to cancel dust remaining offers, but it fails for V1 offers. So it blocks RubiconMarket._buys.
Proof of Concept
In RubiconMarket._buys, it tries to cancel an offer with dust pay token amount after fulfilling. So it sets dustId so it can pass the RubiconMarket.can_cancel modifier.
if (
isActive(id) &&
offers[id].pay_amt < _dust[address(offers[id].pay_gem)]
) {
dustId = id; //enable current msg.sender to call cancel(id)
cancel(id);
}
But when we move into the cancel method, there is another validation. RubiconMarket.cancel will call SimpleMarket.cancel, and SimpleMarket.cancel tries to return dust pay token amount to owner.
_offer.owner == address(0) && msg.sender == _offer.recipient
? require(_offer.pay_gem.transfer(_offer.recipient, _offer.pay_amt))
: require(_offer.pay_gem.transfer(_offer.owner, _offer.pay_amt));
In this case, msg.sender is different from _offer.recipient, so SimpleMarket.cancel will treat this as a V2 offer, while it can be a valid V1 offer. So for a V1 offer, it tries to send pay token amount to _offer.owner when it is address(0) for V1 offers. So it will revert and SimpleMarket.cancel will not work, although it passes RubiconMarket.can_cancel modifier. This will block the _buy method.
Recommended Mitigation Steps
In SimpleMarket.cancel, we should refund pay token amount to _offer.recipient when _offer.owner is address(0).
daoio (Rubicon) disagreed with severity and confirmed via duplicate issue #1281
HickupHH3 (judge) commented via duplicate issue #1281:
I’m selecting #1324 for the report instead because OZ’s. ERC20 implementation blocks transfers to the null address, so in most cases, cancellation will revert as opposed to lost funds.
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
Likely the cancel logic assumes the offer owner is a valid address, but for V1 offers the owner is the zero address, causing a transfer to the zero address that reverts.
Impact
The _buys function is blocked for V1 offers, preventing purchases that would leave dust; the judge noted that in most cases cancellation reverts rather than causing lost funds.
What the attacker needed
V1 offer with dust pay amount; call _buys on that offer
The fix
In SimpleMarket.cancel, refund the pay token amount to _offer.recipient when _offer.owner is address(0).
How it was found
- Call _buys on an active V1 offer with dust pay amount remaining.
- The code sets dustId and calls cancel(id).
- cancel calls SimpleMarket.cancel, which tries to transfer pay tokens to _offer.owner (address(0)).
- The transfer reverts, so cancel fails and _buys is blocked.
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.
A smart contract has a function to buy offers and clean up tiny leftover amounts by cancelling them. For older offers, the cancel step tries to send tokens to an empty address, which the token contract refuses, so the whole buy fails.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.