Closed c4-bot-2 closed 3 months ago
How can a pool become inactive during the transaction? Please provide a test where it can be proven that there can be a condition that pool suddenly becomes inactive without any transaction going before user proceed with paybackBadDebtForToken call
the totalDepositShares from the initial ghost_amount can never be destroyed so it is not possible to have an inactive pool by this check after it has been deployed. Feel free to provide poc testfile though
GalloDaSballo marked the issue as insufficient quality report
based on comment from @vonMangoldt I can agree and dismiss this issue. mark it as invalid.
trust1995 marked the issue as unsatisfactory: Insufficient proof
Lines of code
https://github.com/code-423n4/2024-02-wise-lending/blob/79186b243d8553e66358c05497e5ccfd9488b5e2/contracts/FeeManager/FeeManager.sol#L730-L814
Vulnerability details
Impact
If a pool becomes inactive after the initial check, the function may proceed with the payback operation, but the subsequent operations involving that pool may fail or behave unexpectedly. For example, if the receiving token pool becomes inactive, the function may not be able to correctly calculate or transfer the receiving token amount, potentially leading to loss of funds or other unintended consequences. The severity of this issue can be considered High. The potential loss of funds, inconsistent state, and stuck funds can have significant financial implications and undermine the reliability and trustworthiness of the contract. Additionally, the inability to handle the scenario where a pool becomes inactive during the execution of the function can lead to unexpected behavior and potential vulnerabilities.
Proof of Concept
The
paybackBadDebtForToken
function allows users to pay back the bad debt of a position by providing a payback token and receiving a corresponding amount of another token as a reward. However, there is a potential vulnerability related to the assumption that the pools for both the payback token and the receiving token are active. The function checks if the pools for the_paybackToken
and_receivingToken
are active by verifying if their total deposit shares are non-zero:However, this check is performed only once at the beginning of the function. If either of the pools becomes inactive after this initial check, the function may proceed with the payback operation, leading to inconsistencies or unexpected behavior.
Proof of Concept and Vulnerability Details: Suppose the
_receivingToken
pool is active when the function is called, but it becomes inactive after the initial check. The function will proceed with the payback operation, and when it tries to calculate the receiving amount using thegetReceivingToken
function, it may encounter issues or unexpected behavior due to the pool being inactive. Similarly, if the_paybackToken
pool becomes inactive after the initial check, the subsequent operations involving that pool, such as transferring the payback amount, may fail or lead to inconsistent state.Tools Used
Manual
Recommended Mitigation Steps
Perform the pool activity check not only at the beginning of the function but also immediately before any operations involving those pools. This way, you can ensure that the pools are still active before performing critical operations.
In the modified code, additional checks for the pool activity are performed immediately before the critical operations involving those pools, such as transferring tokens or updating balances. This ensures that the pools are still active at the time of these operations, mitigating the potential vulnerability.
Assessed type
Other