code-423n4 / 2021-10-tally-findings

0 stars 0 forks source link

The initial `swapFee` can be greater than or equal to `SWAP_FEE_DIVISOR` #59

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

pants

Vulnerability details

When Swap's constructor sets the initial swapFee to the value of the argument swapFee, it doesn't check that this value is smaller than SWAP_FEE_DIVISOR.

Impact

If swapFee equals SWAP_FEE_DIVISOR, then the system charges 100% fees so users have no reason to use it. If swapFee is greater than SWAP_FEE_DIVISOR, then the swaps won't work at all. Instead, they will always revert due to an underflow on SWAP_FEE_DIVISOR.sub(swapFee).

Tool Used

Manual code review.

Recommended Mitigation Steps

Require swapFee_ < SWAP_FEE_DIVISOR in Swap's constructor.

Shadowfiend commented 2 years ago

Duplicate of #25.