Closed c4-bot-10 closed 8 months ago
0xRobocop marked the issue as duplicate of #757
0xA5DF marked the issue as unsatisfactory: Out of scope
0xA5DF marked the issue as satisfactory
0xA5DF marked the issue as selected for report
Marking as med, since the case where the result of the division is zero is already reported by the bot. We're left only in the case where it's greater than zero (e.g. 1.9 is rounded to 1), in that case the funds wouldn't be lost permanently, we'd just have to wait for the balance to cross the 1 threshold again (i.e. after rounding 1.9 to 1 and distributing the 1, we're left with a balance that will result in 0.9. We'd just have to wait till it reaches 1 again).
Also, the cases where the rounding is significant are more rare and less likely to happen since we have a more limited range of results where this can happen (let's say a 30% loss is significant, that's limited to [1.3, 2), [2.6, 3], [3.9,4)
)
0xA5DF changed the severity to 2 (Med Risk)
I think this essay describes what the bot found. Yes, a slightly different form. But this does not change the essence. If the sponsor corrects the problem found by the bot, then this issue will become invalid.
Hello @0xA5DF This report is a valid Low. I believe that this is a bot report with a POC.
Thank you for your time sir.
I agree that the bot reported the issue, but it only mentioned that the result would be zero without addressing the precision loss of greater values. I agree with the opinion of @0xA5DF .
Does it change anything? If sponsor will fix bit issue, this issue(described by warden) will be fixed automaticaly
I believe @visualbits is correct based on the statement by the Judge.
We're left only in the case where it's greater than zero (e.g. 1.9 is rounded to 1), in that case the funds wouldn't be lost permanently, we'd just have to wait for the balance to cross the 1 threshold again (i.e. after rounding 1.9 to 1 and distributing the 1, we're left with a balance that will result in 0.9. We'd just have to wait till it reaches 1 again).
Based on the recent SC ruling here, issues are escalatable if the bot report does not define the appropriate severity, which is true in this case since the bot just mentions one half of the issue and does not describe the full impact this would have on the approved holders. Additionally, as the last line in the ruling mentions, the sponsor has no agency in determining fixes for bot findings.
Furthermore, this issue would also result in delay of revenue distribution, which has been covered in some of the duplicates.
For this reason, I think this clearly deserves a medium-severity.
I'm going to mark this one OOS. It's basically the same issue, the same root cause. It's true that the bot report didn't describe the issue well enough and the mitigation provided there doesn't really resolve the issue. However, I believe that once this issue has surfaced the sponsor would apply an adequate mitigation. It doesn't take a genius to realize that the mitigation isn't suitable and the average researched/dev can easily find out what's the best practice to deal with loss of precision.
For #638 which mentioned the bot report - I'm going to credit this one as a low, for the rest I'm going to mark as OOS.
@0xA5DF apologies for commenting after PJQA, but shouldn't this report be OOS?
0xA5DF marked the issue as unsatisfactory: Out of scope
Yeah, that's weird, the extension marked all dupes OOS but this one Marked this again as OOS
Lines of code
https://github.com/code-423n4/2024-02-althea-liquid-infrastructure/blob/bd6ee47162368e1999a0a5b8b17b701347cf9a7d/liquid-infrastructure/contracts/LiquidInfrastructureERC20.sol#L275
Vulnerability details
Description
The liquidity infrastructure calculates holder revenue based on the token balance held by each holder and the revenue generated by the controlled NFTs. This revenue is then distributed among holders through the
LiquidInfrastructureERC20
contract.The current method of calculating
erc20EntitlementPerUnit
in_beginDistribution()
introduces inaccuracies because of Solidity's integer math. Specifically, dividing the ERC20 token balance by the total supply in this manner truncates any decimals, leading to a loss of precision.Example:
If the
balance
is9e18
and thesupply
is1e19
, the correct entitlement should be0.9
but the code erroneously calculates it as0
because the division discards the decimal part.Impact
Proof of Concept
POC setup
foundry.toml:
Tools Used
Manual Review Foundry
Recommended Mitigation Steps
Utilize external libraries like ABDK Math for advanced calculations and fixed-point math functionalities.
Assessed type
Math