Open c4-bot-3 opened 4 months ago
The report is of sufficient quality
3docSec marked the issue as satisfactory
3docSec marked the issue as selected for report
The finding completely misses a justification for the H severity. A swap not happening as it should is better categorized as M.
3docSec changed the severity to 2 (Med Risk)
Lines of code
https://github.com/code-423n4/2024-06-krystal-defi/blob/f65b381b258290653fa638019a5a134c4ef90ba8/src/V3Automation.sol#L158
Vulnerability details
Impact
Protocol functionality broken
Proof of Concept
AUTO_COMPOUND
action allows for compounding your gains into liquidity. It additionally allows for swaps in the middle. There is a faulty condition though, which is never effective and does not allow to settoken1
as targetToken, namelyelse if (state.token0 == state.token1)
:Because pools cannot have the same token0 and token1, there is no possible position that will fulfill this condition. Looking at other parts of the codebase and params passed to
_swapAndIncrease()
in this code branch, what the protocol wants to achieve is to check ifparams.targetToken == state.token1
and perform swap similarly toparams.targetToken == state.token0
branch.Tools Used
Manual Review
Recommended Mitigation Steps
Assessed type
Other