Open c4-submissions opened 11 months ago
minhquanym marked the issue as insufficient quality report
Expected behavior
MarioPoneder marked the issue as unsatisfactory: Invalid
It is explicitly stated that the buyer should not be able to claim fees on his buy. This report shows how the contract fails to ensure this. How can this explicit discrepancy be justified?
Contrast this with #25, in which the impact is instead that the buyer might pay excessive fees. But in that case what is defined as excessive fees is not based on an explicit statement in the code, but rather on a hypothetical interpretation.
The protocol's fee mechanism works as intended.
Nevertheless, this submissions shows how a user can benefit by using multiple addresses, i.e. acting as multiple users.
This is not a bug/vulnerability of the protocol itself, but a property of the current fee mechanism.
As the warden pointed out in their report, this requires a design change of the fee mechanism.
MarioPoneder changed the severity to QA (Quality Assurance)
MarioPoneder marked the issue as grade-b
Lines of code
https://github.com/code-423n4/2023-11-canto/blob/335930cd53cf9a137504a57f1215be52c6d67cb3/1155tech-contracts/src/Market.sol#L150-L169
Vulnerability details
Impact
A buyer is supposed to pay the full price plus full fees, unlike when selling where the seller should get a share of the fees on his own sale. This can be circumvented such that tokens can be bought at a discount.
Proof of concept
Market.buy()
updatesrewardsLastClaimedValue[_id][msg.sender]
without transferring the new addition, with the intention that the buyer doesn't get back part of his paid fee. This can be circumvented by using two addresses, to first buy one token with the first address and then the rest with the second address. Then the first token will get the fee shares on behalf of the rest. If so desired this one share can then be transferred by selling it and then buying it with the main address. Thus the buyer can get back up to a third of the fee and gets a discount.This is demonstrated in detail in the below test. Add
to the
MockERC20
contract and paste the following into Market.t.sol.Recommended mitigation steps
It is difficult to achieve what was intended. One solution is to only reward the platform and the creator when buying. Otherwise, explicitly let buyers get back this part of the fee, just like when selling. Then at least it is fair.
Assessed type
Context