Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

momo - Magic numbers in the morpho.sol contract hardcoded to zero #52

Open
sherlock-admin3 opened this issue Oct 21, 2024 · 0 comments
Open

Comments

@sherlock-admin3
Copy link
Contributor

sherlock-admin3 commented Oct 21, 2024

momo

Medium

Magic numbers in the morpho.sol contract hardcoded to zero

Summary

return values of function getSupplyCollateralCalldata, function invokeSupplyCollateral,function getBorrowCalldata function invokeBorrow, function getWithdrawCollateralCalldata, function invokeWithdrawCollateral function invokeRepay,
https://github.com/sherlock-audit/2024-10-morpho-x-index/blob/main/index-protocol/contracts/protocol/integration/lib/Morpho.sol#L54

https://github.com/sherlock-audit/2024-10-morpho-x-index/blob/main/index-protocol/contracts/protocol/integration/lib/Morpho.sol#L98

https://github.com/sherlock-audit/2024-10-morpho-x-index/blob/main/index-protocol/contracts/protocol/integration/lib/Morpho.sol#L118

have their shares/asset hard coded zero. while one of the input of either the borrowed asset/shares shout be zero, it is more flexible to allow a uint256 variable as a place holder and a require statement to ensure zero being passed

Root Cause

No response

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

No response

Impact

-where the user passes in a non zero borrowed asset, the function would run but fail, leading to unexpected behaviour from the codes because the revert is not well handled.
-user may not understand reason for failed transaction
-gas is also spent on a transaction that fails.

PoC

No response

Mitigation

-since borrowed assets input by user has to be zero, require statements at the beginning of the function to validate that one of these values is indeed zero before further logic, along with a clear revert message.

  • proper documentation on the open source code as well as the user interface
@sherlock-admin2 sherlock-admin2 changed the title Sparkly Fleece Mammoth - Magic numbers in the morpho.sol contract hardcoded to zero momo - Magic numbers in the morpho.sol contract hardcoded to zero Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant