First Flight #18: T-Swap

First Flight #18
Beginner FriendlyDeFiFoundry
100 EXP
View results
Submission Details
Severity: high
Valid

Protocol drained because of the extra incentive

Summary

The protocol will be drained because of the extra incentive.

Vulnerability Details

In _swap() function, some extra tokens will be transferred to msg.sender as the incentive. The vulnerability is that the hacker can do multiple swap operations in one transaction to get the reward extra tokens. Hackers can repeat this operation to drain the whole protocol.

function _swap(
IERC20 inputToken,
uint256 inputAmount,
IERC20 outputToken,
uint256 outputAmount
) private {
if (
_isUnknown(inputToken) ||
_isUnknown(outputToken) ||
inputToken == outputToken
) {
revert TSwapPool__InvalidToken();
}
swap_count++;
// @audit drain the pool
// @audit dos
if (swap_count >= SWAP_COUNT_MAX) {
swap_count = 0;
outputToken.safeTransfer(msg.sender, 1_000_000_000_000_000_000);
}
}

Impact

The protocol will be drained.

Tools Used

Manual

Recommendations

Revisit the incentive mechanism, maybe create T-SWAP token, and use this token as the extra incentive.

Updates

Appeal created

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

In `TSwapPool::_swap` the extra tokens given to users after every swapCount breaks the protocol invariant of x * y = k

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.