sherlock-audit / 2024-02-telcoin-platform-audit-update-judging

3 stars 1 forks source link

turvec - Protocol will behave unexpectedly if ss.origin is also the fee token #67

Closed sherlock-admin4 closed 8 months ago

sherlock-admin4 commented 8 months ago

turvec

medium

Protocol will behave unexpectedly if ss.origin is also the fee token

Summary

Protocol will behave unexpectedly if ss.origin is also the fee token

Vulnerability Detail

Protocol will behave unexpectedly if ss.origin specified in the stablecoinSwap() is also the fee token, this is because of the operation below

 if (fBalance - iBalance != 0) ss.oAmount = fBalance - Balance;

When the defiSwap gets called in the function, it eventually calls _feeDispersal() which inturn calls _buyBack to swap the feeToken to TELCOIN, this means the contract balance of the fee token gets reduced if it does has a balance amount > 0. There meaning that in the case where the balance of the feetoken is > 0, the fBalance - Balance will underflow and revert. While some other transaction similar swap might pass depending on the contract balance of the fee token and when the time it was executed.

Impact

Protocol will behave unexpectedly if ss.origin is also the fee token.

Code Snippet

https://github.com/sherlock-audit/2024-02-telcoin-platform-audit-update/blob/main/telcoin-contracts/contracts/swap/AmirX.sol#L91

Tool used

Manual Review

Recommendation

Completely prevent ss.origin from being the fee token. You should do this in the _verifyStablecoin() function

sherlock-admin2 commented 8 months ago

1 comment(s) were left on this issue during the judging contest.

WangAudit commented:

path and impact are vague; unexpected behaviour? what does it mean exactly and the watson assumes it may results in a revert; therefore; not enough proof