Damaged Amber Rat
Invalid
The getChunkRebalanceNotional function in MorphoLeverageStrategyExtension is an external function without access restrictions that uses an unbounded loop over a user-supplied array, potentially leading to a Denial of Service (DoS) attack.
The getChunkRebalanceNotional function in MorphoLeverageStrategyExtension is an external function without access restrictions that uses an unbounded loop over a user-supplied array, potentially leading to a Denial of Service (DoS) attack.
function getChunkRebalanceNotional(
string[] calldata _exchangeNames
)
external
view
returns(uint256[] memory sizes, address sellAsset, address buyAsset)
{
// ... (previous code omitted for brevity)
for (uint256 i = 0; i < _exchangeNames.length; i++) {
// ... (loop body)
}
// ... (remaining code)
}
- The function is marked as external and view.
- The function accepts an array of exchange names as input.
- Any external actor can call this function with an arbitrarily large array of exchange names.
- An attacker calls getChunkRebalanceNotional with an extremely large array of exchange names.
- The function attempts to process all entries, consuming a large amount of gas.
- If the gas consumption exceeds the block gas limit, the function becomes uncallable.
- Denial of Service: The function could become unusable if called with a large enough array, preventing legitimate calls.
- Gas Exhaustion: Calls to this function with large arrays could consume excessive amounts of gas, leading to transaction failures.
- Contract Liveness: If this function is critical for other operations, its unavailability could impact the overall functionality of the contract.
- Economic Loss: Failed transactions due to out-of-gas errors still cost gas, potentially leading to economic losses for users.
No response
Implement a limit on the number of exchange names that can be processed:
function getChunkRebalanceNotional(
string[] calldata _exchangeNames
)
external
view
returns(uint256[] memory sizes, address sellAsset, address buyAsset)
{
require(_exchangeNames.length <= MAX_EXCHANGES, "Too many exchanges");
// ... (rest of the function implementation)
}