Skip to content
Business logic Audit finding Intermediate

SwapHandler.sol: Check that collateral token cannot be swapped is insufficient for tokens with multiple addresses

The SwapHandler contract checks that the collateral token cannot be swapped by comparing token addresses, but this check fails for ERC20 tokens that have multiple addresses. An attacker could bypass the restriction and swap the collateral token using an alternative address.

roguereddwarf Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-03-taurus-judging/issues/31

Found by

roguereddwarf

Summary

According to the contest page any non-rebasing ERC20 token is supposed to be supported.

The SwapHandler.swapForTau function checks that the collateralToken cannot be sent to the SwapAdapter for trading:

https://github.com/sherlock-audit/2023-03-taurus/blob/main/taurus-contracts/contracts/Vault/SwapHandler.sol#L54-L56

Vulnerability Detail

There exist however ERC20 tokens that have more than one address. In case of such a token, the above check is not sufficient. The token could be swapped anyway by using a different address.

Impact

The check that collateral cannot be swapped can be bypassed for tokens with multiple addresses.

Code Snippet

https://github.com/sherlock-audit/2023-03-taurus/blob/main/taurus-contracts/contracts/Vault/SwapHandler.sol#L45-L101

Tool used

Manual Review

Recommendation

Compare the balance of the collateral before and after sending tokens to the SwapAdapter and make sure it hasn't changed. Or implement a whitelist for tokens that can be swapped.

Discussion

Sierraescape

Tokens with multiple addresses are pretty rare, so we're just going to note that the vault doesn't allow such tokens as collateral, and create wrappers for them if necessary.

https://github.com/protokol/taurus-contracts/pull/120

spyrosonic10

Escalate for 10 USDC

Token with different addresses is very very rare. Almost every protocols in Defi operating on assumption of token with single address. This issue does not qualify as High/Medium.

sherlock-admin

Escalate for 10 USDC

Token with different addresses is very very rare. Almost every protocols in Defi operating on assumption of token with single address. This issue does not qualify as High/Medium.

You've created a valid escalation for 10 USDC!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

roguereddwarf

Escalate for 10 USDC

Disagree with previous escalation. While these tokens are rare they do exist and as pointed out in my report any non-rebasing ERC20 is supposed to be supported which clearly includes tokens with multiple addresses. So I think this is a valid medium.

sherlock-admin

Escalate for 10 USDC

Disagree with previous escalation. While these tokens are rare they do exist and as pointed out in my report any non-rebasing ERC20 is supposed to be supported which clearly includes tokens with multiple addresses. So I think this is a valid medium.

You've created a valid escalation for 10 USDC!

To remove the escalation from consideration: Delete your comment.

You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.

hrishibhat

Escalation accepted

Considering this a valid medium. As pointed out in the second escalation, even though these tokens are rare the issue can still be considered valid medium.

Note: Going forward, Sherlock team will add additional clarity on such rare token cases in the README.

sherlock-admin

Escalation accepted

Considering this a valid medium. As pointed out in the second escalation, even though these tokens are rare the issue can still be considered valid medium.

Note: Going forward, Sherlock team will add additional clarity on such rare token cases in the README.

This issue's escalations have been accepted!

Contestants' payouts and scores will be updated according to the changes made on this issue.

MLON33

Tokens with multiple addresses are pretty rare, so we're just going to note that the vault doesn't allow such tokens as collateral, and create wrappers for them if necessary.

https://github.com/protokol/taurus-contracts/pull/120

Fixed here

IAm0x52

No direct fix has been implemented but a note has been added explicitly stating that multi-address tokens are not supported

jacksanford1

Classifying this issue as "Acknowledged" since no direct fix was made.

The original report as published on Sherlock, by roguereddwarf. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the contract relies on a single token address to identify and block a token, which is insufficient for tokens that have multiple addresses.

Impact

The restriction that prevents the collateral token from being swapped can be bypassed for tokens with multiple addresses, potentially allowing unauthorised trading of collateral.

What the attacker needed

Collateral token has multiple addresses

The fix

The project noted that such tokens are not supported as collateral and may create wrappers if necessary; a more robust fix would compare collateral balances before and after sending tokens to the SwapAdapter or use a whitelist of swappable tokens.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Some digital tokens can have more than one address on the blockchain. The contract tried to stop a certain token from being traded by checking its address, but if the token has another address, that check does not work. So someone could still trade the token when they should not be able to.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by roguereddwarf

View all

12 more disclosed reports, best first.

More from Taurus

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.