Closed c4-bot-1 closed 10 months ago
hansfriese marked the issue as primary issue
fez-init marked the issue as disagree with severity
fez-init marked the issue as agree with severity
fez-init (sponsor) disputed
This is the expected behavior.
Agree with the sponsor.
hansfriese marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2023-12-initcapital/blob/main/contracts/lending_pool/LendingPool.sol#L111 https://github.com/code-423n4/2023-12-initcapital/blob/main/contracts/lending_pool/LendingPool.sol#L125
Vulnerability details
Impact
Users might not always be able to
burn()
orborrow()
due to being frontrunned by other borrow or burn calls, potentially in a malicious manner so funds don't leave the LendingPool.Proof of Concept
This attack could happen frequently because the health of a position is given by all the collaterals in different lending pools, so it is likely that users borrow more on a certain pool, making this attack possible.
Borrowing and depositing in the same block doesn't trigger any feed, so attackers could move their funds around to block users' burn/borrow.
burn()
borrow()
A simple POC was built in Foundry showing the issue:
Tools Used
Vscode, Foundry
Recommended Mitigation Steps
Instead of reverting, the amount could be cropped to the available. This alone would help significantly as the missing liquidity could be very small but still make the transaction revert. Additionally, a scheduling mechanism could be implemented to allow users to withdraw whenever there is liquidity, later. On top of this, a fixed borrow fee could be added to stop upsers from borrowing and depositing atomically, which would decrease the likelihood of attackers moving funds around maliciously.
Assessed type
Under/Overflow