Skip to content
Access control Audit finding Intermediate

Anyone Can Arbitrarily Mint Synthetic Assets In VaderPoolV2.mintSynth()

The mintSynth function allows any user to specify a 'to' address and a 'from' address, so an attacker can front-run a victim's approval and mint synthetic assets to themselves using the victim's funds. The attacker monitors approvals to the contract and calls mintSynth with their own address as 'to', causing the victim's deposit to be transferred and the synthetic asset to be sent to the attacker.

leastwood Follow

Originally disclosed on Code4rena

Submitted by leastwood

Impact

The mintSynth() function is callable by any user and creates a synthetic asset against foreignAsset if it does not already exist. The protocol expects a user to first approve the contract as a spender before calling mintSynth(). However, any arbitrary user could monitor the blockchain for contract approvals that match VaderPoolV2.sol and effectively frontrun their call to mintSynth() by setting the to argument to their own address. As a result, the nativeDeposit amount is transferred from the victim, and a synthetic asset is minted and finally transferred to the malicious user who is represented by the to address.

Proof of Concept

https://github.com/code-423n4/2021-11-vader/blob/main/contracts/dex-v2/pool/VaderPoolV2.sol#L126-L167

Tools Used

Manual code review. Discussions with dev.

Recommended Mitigation Steps

Consider removing the from argument in mintSynth() and update the safeTransferFrom() call to instead transfer from msg.sender.

SamSteinGG (Vader) commented:

The pool contracts, similarly to Uniswap V2, are never meant to be interacted with directly.

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

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 mintSynth function takes a 'from' parameter and uses it in safeTransferFrom without verifying that the caller is authorised to spend on behalf of that address, allowing anyone to specify any 'from' address that has approved the contract.

Impact

An attacker could steal a victim's approved deposit and mint synthetic assets to themselves, but the pool contracts are not meant to be interacted with directly, which may limit real-world impact.

What the attacker needed

Victim has approved the contract; attacker can front-run transactions

How it was found

  1. Victim approves VaderPoolV2 contract to spend their tokens.
  2. Attacker monitors the blockchain for such approvals.
  3. Attacker calls mintSynth with 'to' set to their own address and 'from' set to the victim's address.
  4. The contract transfers the victim's nativeDeposit and mints a synthetic asset 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.

This is a smart contract bug where a function lets anyone choose whose money is used and who receives the new tokens. An attacker watches for someone approving the contract to spend their tokens, then quickly calls the function with their own address as the receiver. The victim's tokens are taken and the attacker gets the newly created tokens.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by leastwood

View all

70 more disclosed reports, best first.

More from Vader Protocol contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.