This report examines three functions for potential vulnerabilities, specifically focusing on overflow/underflow risks and missing validation checks. The issues found and recommendations provided aim to improve the security and reliability of the contract.
descaleAmount
Severity: Medium
Description: While the current implementation of this function may assume that decimals
is validated at other points in code, this assumption is dangerous given that scaleAmount
is written as a generalized library function, designed for flexible reuse. Without a built-in guard in the function itself, contexts where decimals
is unchecked can lead to an overflow when decimals
is greater than 18. This overflow occurs due to a negative exponent, resulting in an unintended large output that can break contract logic and undermine reliability in systems relying on this library.
Recommendation:
Add a validation to ensure decimals
is no greater than 18, preventing the underflow scenario:
Adding this validation will mitigate the risk of underflow and maintain function integrity.
scaleAmount
Severity: Medium
Description: This function is intended to scale an amount
from a given decimals
precision to 18 decimals. However, if decimals > 18
, the calculation 10 ** (18 - decimals)
underflows, which can cause scaleFactor
to wrap to a large value. This unintended value can then lead to an overflow when multiplying by amount
, producing an inaccurate and extremely large output.
Recommendation:
Add a validation to ensure decimals
does not exceed 18:
This will prevent underflow and overflow scenarios by ensuring decimals
stays within an appropriate range.
transferAdmin
Severity: Medium
Description: The transferAdmin
function does not check if newAdmin
is the zero address (address(0)
). Assigning the zero address as an admin can unintentionally lock administrative actions, making the contract unmanageable.
Recommendation:
Add a check to ensure newAdmin
is not the zero address:
Implementing this check ensures that the admin role is always assigned to a valid address, preventing potential loss of control over the contract.
This audit highlights underflow and overflow vulnerabilities in the scaling functions and a missing validation in the transferAdmin
function. Addressing these issues by implementing the recommended checks will enhance the contract’s security and maintainability.
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.