A vulnerability was discovered in the calculateAmountsFromFee function within the Helpers library, which results in an arithmetic underflow/overflow when the fee parameter exceeds the total amount. This issue arises because the function does not verify whether the fee is less than or equal to the total amount, leading to an unexpected revert with a panic code (0x11). This could lead to denial of service in applications relying on this function for fee validation and may cause unexpected behaviour in systems assuming a consistent execution flow.
The vulnerability occurs because the calculateAmountsFromFee function does not check if the fee parameter is greater than the totalAmount. When fee exceeds totalAmount, the subtraction or division operation results in an arithmetic overflow/underflow, causing the function to revert with a panic code (0x11).
Place the below in your test file.
This vulnerability causes the function to revert unexpectedly when the fee exceeds the totalAmount. While this issue may not directly allow unauthorized fund access or data manipulation, it can disrupt the normal functioning of smart contracts that rely on calculateAmountsFromFee for fee validation. If the function is critical to operations or integrated into a larger financial system, this error could affect user experience and system reliability.
Manual review
To mitigate this vulnerability, add a validation check(preferably a `require` statement) in the calculateAmountsFromFee function to ensure fee does not exceed totalAmount before performing arithmetic operations. Implement the following update:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.