Potential Loss of Precision in Conversion from
The setUp function of the WithdrawalSystem contract casts a uint256 cooldown value down to uint32, which can silently truncate values larger than the uint32 range. The report claims this could cause unexpected cooldown behaviour, but gives no concrete exploit or demonstrated effect.
- Disclosed after under an hour
29484 - [SC - Insight] Potential Loss of Precision in Conversion from ...
Submitted on Mar 20th 2024 at 23:27:54 UTC by @Flare for Boost | Immunefi Arbitration
Report ID: #29484
Report type: Smart Contract
Report severity: Insight
Target: https://github.com/immunefi-team/vaults/blob/main/src/WithdrawalSystem.sol
Impacts:
- Precision
Description
Brief/Intro
The setUp function in the WithdrawalSystem contract involves converting a uint256 value to a uint32 for setting the cooldown period for withdrawals. This conversion may lead to a loss of precision and unexpected behavior if the original value exceeds the range representable by a uint32
Vulnerability Details
The setUp function in the withdrawlSystem contract accepts parameters, including _txCooldown, which represents the cooldown period for withdrawals. Within the function, the _txCooldown value is cast from uint256 to uint32 before being passed to the _setTxCooldown function. This type conversion can potentially lead to issues due to loss of precision if the original value is larger than what can be represented by a uint32
Impact Details
the impact of the potential loss of precision in the conversion from uint256 to uint32
References
change input var _txCooldown as uint32 in setUp function
Proof of Concept
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely an unchecked narrowing cast from uint256 to uint32 when setting the withdrawal cooldown, which truncates oversized inputs instead of rejecting them.
Impact
The cooldown period could be set to an unintended, truncated value, though the report does not show any concrete loss or attack path.
What the attacker needed
Privileged caller sets an oversized cooldown
The fix
The input variable should be declared as uint32 in the setUp function, or the cast should be range-checked.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A number stored in a small container can only hold so much; if you pour a bigger number in, the extra part is cut off. Here a large cooldown value is squeezed into a smaller type, so the stored cooldown may not be what the operator intended. The report does not show anyone actually losing money or access because of it.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.