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

XC20Wrapper: Unsupported fee-on-transfer tokens #160

Open
code423n4 opened this issue Aug 3, 2022 · 3 comments
Open

XC20Wrapper: Unsupported fee-on-transfer tokens #160

code423n4 opened this issue Aug 3, 2022 · 3 comments
Labels
bug Something isn't working QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-07-axelar/blob/9c4c44b94cddbd48b9baae30051a4e13cbe39539/xc20/contracts/XC20Wrapper.sol#L75-L88

Vulnerability details

Impact

In the XC20Wrapper contract, if axelarToken is TokenType.External and is a fee-on-transfer token, the amount of tokens received by the contract in the wrap function will be less than amount, but the amount of wrappedToken minted for the user is amount.
The user can drain the axelarToken in the contract by constantly calling the wrap and unwrap functions

Proof of Concept

https://github.com/code-423n4/2022-07-axelar/blob/9c4c44b94cddbd48b9baae30051a4e13cbe39539/xc20/contracts/XC20Wrapper.sol#L75-L88

Tools Used

None

Recommended Mitigation Steps

Consider getting the received amount by calculating the difference of token balance (using balanceOf) before and after the transferFrom.

@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Aug 3, 2022
code423n4 added a commit that referenced this issue Aug 3, 2022
@Foivos
Copy link
Collaborator

Foivos commented Aug 4, 2022

xc20Wrapper in only meant to be used with non-External tokens. External tokens already exist on moonbeam and they should figure out their own way to go to the rest of Polkadot.

@re1ro
Copy link
Member

re1ro commented Aug 5, 2022

Duplicate of #16

@re1ro re1ro marked this as a duplicate of #16 Aug 23, 2022
@re1ro re1ro added the duplicate This issue or pull request already exists label Aug 23, 2022
@re1ro re1ro closed this as completed Aug 23, 2022
@GalloDaSballo
Copy link
Collaborator

The warden has shown that the contract for wrapping will not check for the change in balance for the token after the transfer, this will cause issues with both rebasing and feeOnTransfer tokens.

The system requires the owner to addWrapping meaning that the issue could happen only if the token is feeOnTransfer and the Owner decided to allow that token to be wrappable.

The total loss will amount to the cost of the fees, specifically the last few to call unwrap will not be able to receive any token (as all tokens will have already been claimed)

Given that the max loss is some balances, but it is contingent on the admin allowing those tokens, and the token itself being feeOnTransfer, I think Low Severity to be more appropriate.

I recommend end users to check if any token will have fees and recommend the sponsor to either refactor or simply never enable such a token

@GalloDaSballo GalloDaSballo added QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Sep 5, 2022
@GalloDaSballo GalloDaSballo removed the duplicate This issue or pull request already exists label Sep 6, 2022
@GalloDaSballo GalloDaSballo reopened this Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
Projects
None yet
Development

No branches or pull requests

4 participants