Tokens can be stolen through transferTo
The protocol's transferTo function authorises transfers based on tx.origin and skips approvals, so any external contract that the user interacts with can call transferTo and move the user's tokens. An attacker could airdrop a malicious token and trick a holder into swapping it, causing all their VADER, USDV and SYNTHS tokens to be stolen.
Vader Protocol contest
Originally disclosed on Code4rena
I know that it’s stated that:
VADER, USDV, SYNTHS all employ the
transferTo()function, which interrogates fortx.originand skips approvals. The author does not subscribe to the belief that this is dangerous
In my opinion, it can be very dangerous. Imagine the following scenario:
- I create a custom attacker ERC20 token that has a hook in the
_transferfunction that checks tx.origin for USDV/VADER/SYNTHS and callstransferToto steal these funds. - I set up a honeypot by providing liquidity to the
BASE <> ATTACKERpool. - I target high-profile accounts holdinging VADER/USDV/SYNTHS and airdrop them free tokens.
- Block explorers / Vader swap websites could show that this token has value and can be traded for actual
BASEtokens. - User wants to sell the airdropped
ATTACKERtoken to receive valuable tokens through the Vader swap and has all their tokens (that are even completely unrelated to the tokens being swapped) stolen.
In general, a holder of any of the core assets of the protocol risks all their funds being stolen if they ever interact with an unvetted external contract/token. This could even be completely unrelated to the VADER protocol.
Recommend removing transferTo and use permit + transferFrom instead to move tokens from tx.origin.
strictly-scarce (vader) acknowledged:
This attack path has already been assessed as the most likely, no new information is being presented here.
Do not interact with attack contracts, interacting with an ERC20 is an attack contract.
@strictly-scarce (vader) What would be the downside of adopting the suggested mitigation? Since we cannot communicate effectively with all users to tell them not to interact with certain kinds of contracts (and even if we could, they may not be able to discern which are OK and which aren’t), we don’t want to set up a thicket for fraudsters to operate. If the downside of the mitigation is not too bad, I think it could be worth it in order to deny fraudsters an opportunity to steal.
Our decision matrix for severity:
0: No-risk: Code style, clarity, off-chain monitoring (events etc), exclude gas-optimisations 1: Low Risk: UX, state handling, function incorrect as to spec 2: Funds-Not-At-Risk, but can impact the functioning of the protocol, or leak value with a hypothetical attack path with stated assumptions, but external requirements 3: Funds can be stolen/lost directly, or indirectly if a valid attack path shown that does not have handwavey hypotheticals.
Recommended: 0
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
The transferTo function trusts tx.origin for authorisation and skips the normal approval step, so any contract called by the victim can move the victim's tokens.
Impact
A holder of any core protocol asset could lose all their VADER, USDV and SYNTHS tokens by interacting with an unvetted external contract, even one unrelated to the protocol.
What the attacker needed
Victim holds VADER, USDV or SYNTHS; victim interacts with an attacker token; attacker deploys a malicious ERC20
The fix
The report recommends removing transferTo and using permit plus transferFrom to move tokens from tx.origin instead; the protocol acknowledged the issue but did not state that it was fixed.
How it was found
- Create a malicious ERC20 token whose transfer hook checks tx.origin and calls transferTo to steal VADER, USDV or SYNTHS.
- Provide liquidity to a pool pairing the malicious token with a valuable base token to create a honeypot.
- Airdrop the malicious token to high-profile holders of VADER, USDV or SYNTHS.
- Wait for a victim to try to sell the airdropped token through the Vader swap.
- The malicious token's hook runs and calls transferTo, moving all of the victim's core tokens to the attacker.
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 tokens let a transfer happen if the request comes from the same wallet that started the transaction, without asking the wallet owner for permission first. A malicious token contract can notice that and quietly ask the protocol to move the victim's tokens to the attacker. The victim only has to try to sell a free token they were sent.
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.