Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Users will benefit from fee spit when calling burnNFT() agains intended design. #241

Closed
c4-submissions opened this issue Nov 17, 2023 · 4 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working insufficient quality report This report is not of sufficient quality primary issue Highest quality submission among a set of duplicates unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@c4-submissions
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2023-11-canto/blob/b78bfdbf329ba9055ba24bd710c7e1c60251039a/1155tech-contracts/src/Market.sol#L230-L232

Vulnerability details

Impact

Users will benefit from fee spit when calling burnNFT() agains intended design.

Proof of Concept

Let us first take a look at how a user was prevented from benefiting from fee spit in buy() function

        // The reward calculation has to use the old rewards value (pre fee-split) to not include the fees of this buy
        // The rewardsLastClaimedValue then needs to be updated with the new value such that the user cannot claim fees of this buy
        uint256 rewardsSinceLastClaim = _getRewardsSinceLastClaim(_id);
        // Split the fee among holder, creator and platform
        _splitFees(_id, fee, shareData[_id].tokensInCirculation);
        rewardsLastClaimedValue[_id][msg.sender] = shareData[_id].shareHolderRewardsPerTokenScaled;

From the snippet above, note that rewardsSinceLastClaim was first obtained using the previous state before calling splitFees() so that the caller does not benefit from its fee, and rewardsLastClaimedValue[_id][msg.sender] was set to equal the updated value after calling _splitFees() so then no value will be claimable by the user when calling claimHolderFee(), this was done correctly.
However, in Market.buyNFT(), the proper order was not followed, splitFees() was called before setting
rewardsSinceLastClaim, which implies that user will benefit from the fee split.

 _splitFees(_id, fee, shareData[_id].tokensInCirculation);
        // The user does not get the proportional rewards for the burning (unless they have additional tokens that are not in the NFT)
        uint256 rewardsSinceLastClaim = _getRewardsSinceLastClaim(_id);

Tools Used

Manual review.

Recommended Mitigation Steps

// The user does not get the proportional rewards for the burning (unless they have additional tokens that are not in the NFT)
 uint256 rewardsSinceLastClaim = _getRewardsSinceLastClaim(_id);
 _splitFees(_id, fee, shareData[_id].tokensInCirculation);

Assessed type

Context

@c4-submissions c4-submissions added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Nov 17, 2023
c4-submissions added a commit that referenced this issue Nov 17, 2023
@c4-pre-sort
Copy link

minhquanym marked the issue as insufficient quality report

@c4-pre-sort c4-pre-sort added the insufficient quality report This report is not of sufficient quality label Nov 20, 2023
@minhquanym
Copy link
Member

Invalid

@c4-pre-sort c4-pre-sort added the primary issue Highest quality submission among a set of duplicates label Nov 20, 2023
@c4-pre-sort
Copy link

minhquanym marked the issue as primary issue

@c4-judge
Copy link

MarioPoneder marked the issue as unsatisfactory:
Insufficient quality

@c4-judge c4-judge added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working insufficient quality report This report is not of sufficient quality primary issue Highest quality submission among a set of duplicates unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

4 participants