Report ID
#34352
Report type
Smart Contract
Has PoC?
Yes
Target
https://etherscan.io/address/0xBA510f10E3095B83a0F33aa9ad2544E22570a87C
Impacts
Temporary freezing of funds for at least 1 hour
Description
The _init function in the MultiFlowPump contract is responsible for initializing the reserves for a given slot. However, the function contains a critical flaw where it returns early if any reserve in the reserves array is 0. This can leave the contract in an inconsistent state, leading to unexpected behavior and potential issues in subsequent operations.
Code snippet:
Detailed Analysis:
Initialization Check:
- The function iterates through the
reserves array. - If any reserve value is
0, the function returns early without completing the initialization. - This premature return prevents the reserves from being stored properly.
Impact:
- If the initialization is aborted, the contract may not store the correct initial state.
- Subsequent calls to functions that rely on the initialized state may fail or produce incorrect results.
- This can lead to unexpected behavior and potential loss of funds or incorrect oracle data.
Related Code:
The update function calls _init if the last timestamp is 0 (indicating the pump has never been used before).
Mitigations
Remove Early Return: Instead of returning early if a reserve is 0, handle the 0 value appropriately.
Add Validation: Ensure that the reserves array passed to _init does not contain any 0 values before calling the _init function.
By removing the early return or adding validation to ensure no reserves are 0, you can mitigate this issue and maintain the integrity and security of the contract.
Proof of concept
- Call the
update function with a reserves array that includes a 0 value. - Verify that the contract does not properly initialize the reserves, leading to incorrect behavior in subsequent calls.
Exploitation Scenario
- A malicious actor could call the
update function with a reserves array containing a 0 value. - This would cause the
_init function to return early, leaving the contract in an uninitialized state. - Subsequent operations relying on the initialized state may fail, leading to unexpected behavior or potential loss of funds.
Impact Justification
Impact: Temporary freezing of funds for at least 1 hour
Reasoning:
- The vulnerability can lead to the contract being in an inconsistent state, causing subsequent operations to fail.
- This can result in temporary freezing of funds as the contract is unable to process transactions correctly until the issue is resolved.
- The issue does not lead to permanent freezing or direct theft of funds, but it can cause significant disruption and potential loss of funds due to incorrect behavior in subsequent calls.