-
Notifications
You must be signed in to change notification settings - Fork 5
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
updateRoyalty
is not distributing first before update the withdrawRoyalty
#66
Comments
Distribution Calculations
|
fatherGoose1 marked the issue as unsatisfactory: |
Hey @ZaK3939 you may don't understand the issue To illustrate properly this imagine the next scenario:
This have being a medium in code4arena that why i add this issues to my favor: |
@jorgect207 pls check this test, this test succesufully update royalty and sent expected eth
|
hey @ZaK3939 the issue is easy to understands, pleas check the other vulns: code-423n4/2024-04-noya-findings#544 Changing fees will recalculate previously accumulated fees if they were not accrued. Using the test that you provide in the comment i made some modifications to explain the issue, bassicly the amount function testUpdateRoyaltyToMax() public {
uint256 credId = 1;
uint256 depositAmount = 1 ether;
uint256 newRoyalty = 1000; // 10% in basis points
uint256 expectedExecuteRoyalty = depositAmount / 10;
// Deposit some ETH to the curatorRewardsDistributor
curatorRewardsDistributor.deposit{ value: depositAmount }(credId, depositAmount);
// Update royalty to max (1000 = 10%) //At this point evryone think that they going to get this 10% as rewards
vm.prank(owner);
curatorRewardsDistributor.updateRoyalty(newRoyalty); <---------
// Signal creds for different users
vm.startPrank(user1);
vm.deal(user1, bondingCurve.getBuyPriceAfterFee(credId, 1, 1));
cred.buyShareCred{ value: bondingCurve.getBuyPriceAfterFee(credId, 1, 1) }(credId, 1, 0);
vm.stopPrank();
vm.startPrank(user2);
vm.deal(user2, bondingCurve.getBuyPriceAfterFee(credId, 2, 2));
cred.buyShareCred{ value: bondingCurve.getBuyPriceAfterFee(credId, 2, 2) }(credId, 2, 0);
vm.stopPrank();
// Now the royalty rewards was update to the 7%; but user was expecting a 10% royalty fee, (Note that this could be changed without any malicious intention and the bug still persist)
newRoyalty = 700; // 7% in basis points <----------
vm.prank(owner);
curatorRewardsDistributor.updateRoyalty(newRoyalty);
// Record initial balances
uint256 initialBalance = anyone.balance;
// Distribute rewards
vm.prank(anyone);
curatorRewardsDistributor.distribute(credId);
// Check final balances
uint256 finalBalance = anyone.balance;
}
```
See the arrows above; what i mean here is that the fee have to be accrued before that update the fee. @ZaK3939 letting my discussion to here, thanks so much for your time and patience. |
@jorgect207 Thank you. I understand your point, but the original report was highlighting a different issue, which I believe is incorrect. This is incorrect point out.
|
Thank so much for answer @ZaK3939, Hey so sorry i guess i made an invalid stamen, the correct statement will be I hope this invalid statement does not penalize me to cancel the findings Since the rest is good. 🙏 |
fatherGoose1 changed the severity to QA (Quality Assurance) |
fatherGoose1 marked the issue as grade-a |
Labeling as QA. It may be part of Phi's flow to call |
Lines of code
https://github.com/code-423n4/2024-08-phi/blob/8c0985f7a10b231f916a51af5d506dd6b0c54120/src/reward/CuratorRewardsDistributor.sol#L57
Vulnerability details
Basically if the owner want to upgrade the royalty, he just call the
updateRoyalty
the problem is that the contact need distribute the rewards before changing theupdateRoyalty
because if is not called the distribute function will distribute a wrong value possibly because the contract does not hold the enough amount of ether in case of the royalty update was increased the value.[Link]
Impact
Incorrect distribution can be occasioned in case of the owner update the Royalties because there is not distribution before, if the upgrade is up the contract get Dos because there is not more ether in the contract:
_msgSender().safeTransferETH(royaltyfee + distributeAmount - actualDistributeAmount);
If the upgrade is down the distribution will be incorrect because is distributing less rewards.
Proof of Concept
Those other similar medium vuln in contest:
setFees doesn't collect previous fees before changing fee values
Lack of update when modifying pool fee
Tools Used
Manual
Recommended Mitigation Steps
Consider get the credIds and distribute this before the update of the
withdrawRoyalty
Assessed type
Other
The text was updated successfully, but these errors were encountered: