Open code423n4 opened 1 year ago
0xRobocop marked the issue as primary issue
0xRobocop marked the issue as sufficient quality report
May be QA.
Description fails to give impact rather than just "code not as comments".
that's a typo in the comment we think the severity should be low/informational
viraj124 marked the issue as disagree with severity
ishaansinghal (sponsor) confirmed
JustDravee changed the severity to QA (Quality Assurance)
JustDravee marked the issue as grade-c
Merging with https://github.com/code-423n4/2023-08-shell-findings/issues/247 and accepting as typo in comment
JustDravee marked the issue as grade-a
Lines of code
https://github.com/code-423n4/2023-08-shell/blob/main/src/proteus/EvolvingProteus.sol#L812-L813 https://github.com/code-423n4/2023-08-shell/blob/main/src/proteus/EvolvingProteus.sol#L155-L157 https://github.com/code-423n4/2023-08-shell/blob/main/src/proteus/EvolvingProteus.sol#L149-L151
Vulnerability details
Impact
The
EvolvingProteus._checkBalances
function is used to verify the token reserve balances and the token reserve ratio are with in the valid boundaries of the pool. To validate thereserve ratio
is within the valid range ofMIN_M - MAX_M
the following checks are performed.The
NATSPEC
comments for theMIN_M
andMAX_M
are given as follows:Even though the documentation says the
y / x
ratio can have at most 108 the logic implementation reverts when the `y / x == 108` as shown below:But it is not the case with the
MIN_M
. Because the transaction will not revert wheny / x == 1 / 10**8
. Hence there is a discrepancy between the documentation and the logic implementation.Consider a scenario where the
y balance = 200 * 10**20
andx balance = 200 * 10**12
. Now they / x = 10**8
. The transaction is not expected to be reverted since the documentation mentions that the pool is allowed to have at most 10**8 y for each x. But according to the logic implementation this transaction will revert sinceMAX_M == finalBalanceRatio
. This breaks the expected behaviour of the protocol.Proof of Concept
https://github.com/code-423n4/2023-08-shell/blob/main/src/proteus/EvolvingProteus.sol#L812-L813
https://github.com/code-423n4/2023-08-shell/blob/main/src/proteus/EvolvingProteus.sol#L155-L157
https://github.com/code-423n4/2023-08-shell/blob/main/src/proteus/EvolvingProteus.sol#L149-L151
Tools Used
VSCode and Manual Review
Recommended Mitigation Steps
Hence it is recommended to modify the
MAX_M <= finalBalanceRatio
conditional check of the_checkBalances
function as shown below (omit the equality check in it):Assessed type
Other