Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POB - POB - Lost funds in the AmirX::_buyBack function when DefiSwap.defiSafe is set to address(0) #211

Open
sherlock-admin2 opened this issue Nov 13, 2024 · 0 comments

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented Nov 13, 2024

POB

Medium

POB - Lost funds in the AmirX::_buyBack function when DefiSwap.defiSafe is set to address(0)

Summary

BuyBack can result in lost funds if DefiSwap.defiSafe is not set. There is no check in the AmirX::_verifyDefiSwap function to ensure that DefiSwap.defiSafe is not the zero address. In the BuyBack function, if feeToken is POL and there is still POL remaining in the contract after the swap (address(this).balance > 0), the remaining POL will be sent to the zero address.

Root Cause

In AmirX::_verifyDefiSwap function there is no check to ensure that DefiSwap.defiSafe is not the zero address.

Internal pre-conditions

  1. DefiSwap.defiSafe should be set to the zero address.
  2. address(feeToken) == POL.
  3. After the aggregator call (bool polSwap,) = aggregator.call{value: msg.value}(swapData);, there should be remaining POL (address(this).balance > 0)

Impact

The bug in the BuyBack function causes any remaining POL after the swap to be sent to the zero address, resulting in lost funds.

Mitigation

Add a condition in the AmirX::_verifyDefiSwap function to check if a non-zero DefiSwap.defiSafe address is provided.

@sherlock-admin3 sherlock-admin3 changed the title Active Goldenrod Cod - POB - Lost funds in the AmirX::_buyBack function when DefiSwap.defiSafe is set to address(0) POB - POB - Lost funds in the AmirX::_buyBack function when DefiSwap.defiSafe is set to address(0) Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant