Swapper Role Incorrectly Uses msg.value Causing Potential issues
Summary
The incorrect usage of msg.value in the _buyBack function will cause a potential loss for the protocol as the SWAPPER_ROLE user cannot provide POL directly, leading to swap failures or possible mismanagement of POL funds.
Root Cause
In AmirX.sol: 232, msg.value is used to conduct swaps for POL tokens, which should instead use address(this).balance.
Internal pre-conditions
SWAPPER_ROLE calls _buyBack for a fee buyback operation using POL.
The protocol holds a POL balance from previous transactions or collected fees.
External pre-conditions
The aggregator expects a non-zero POL amount to execute the swap successfully.
SWAPPER_ROLE is unable to send msg.value as part of the contract transaction, causing failure.
Attack Path
The SWAPPER_ROLE initiates _buyBack with POL selected as feeToken.
_buyBack calls the aggregator using msg.value, which will be zero from the caller (SWAPPER_ROLE).
The transaction fails or completes without using the POL balance on the contract, causing a failed buyback or remaining POL in the contract.
Impact
The protocol suffers a potential loss of POL due to failed swaps or inconsistent buyback behavior, as SWAPPER_ROLE cannot complete swaps correctly.
PoC
No response
Mitigation
Use address(this).balance instead of msg.value for POL transactions within _buyBack.
0xmujahid002
High
Swapper
Role Incorrectly Usesmsg.value
Causing Potential issuesSummary
The incorrect usage of
msg.value
in the_buyBack
function will cause a potential loss for the protocol as theSWAPPER_ROLE
user cannot providePOL
directly, leading to swap failures or possible mismanagement ofPOL
funds.Root Cause
In AmirX.sol: 232,
msg.value
is used to conduct swaps forPOL
tokens, which should instead useaddress(this).balance
.Internal pre-conditions
SWAPPER_ROLE
calls_buyBack
for a fee buyback operation usingPOL
.POL
balance from previous transactions or collected fees.External pre-conditions
SWAPPER_ROLE
is unable to sendmsg.value
as part of the contract transaction, causing failure.Attack Path
SWAPPER_ROLE
initiates_buyBack
withPOL
selected as feeToken._buyBack
calls the aggregator usingmsg.value
, which will be zero from the caller (SWAPPER_ROLE
).POL
balance on the contract, causing a failed buyback or remainingPOL
in the contract.Impact
The protocol suffers a potential loss of POL due to failed swaps or inconsistent buyback behavior, as
SWAPPER_ROLE
cannot complete swaps correctly.PoC
No response
Mitigation
Use
address(this).balance
instead ofmsg.value
for POL transactions within_buyBack
.