Skip to content
Access control Audit finding Intermediate

All user assets which are approved to VaderPoolV2 may be stolen

The mintFungible function in VaderPoolV2 allows an attacker to specify any address as the source of tokens, so if that address has approved the pool to spend its tokens, the attacker can mint LP tokens for themselves and steal the underlying assets.

TomFrenchBlockchain Follow

Originally disclosed on Code4rena

Submitted by TomFrenchBlockchain, also found by cmichel

Impact

Total loss of funds which have been approved on VaderPoolV2

Proof of Concept

VaderPoolV2 allows minting of fungible LP tokens with the mintFungible function

https://github.com/code-423n4/2021-11-vader/blob/607d2b9e253d59c782e921bfc2951184d3f65825/contracts/dex-v2/pool/VaderPoolV2.sol#L284-L290

Crucially this function allows a user supplied value for from which specifies where the nativeAsset and foreignAsset should be pulled from. An attacker can then provide any address which has a token approval onto VaderPoolV2 and mint themselves LP tokens - stealing the underlying tokens.

Recommended Mitigation Steps

Remove from argument and use msg.sender instead.

SamSteinGG (Vader) disputed):

pool is not meant to be interacted with

alcueca (judge) commented:

And how are you going to ensure that the pool is not interacted with, @SamSteinGG?

SamSteinGG (Vader) confirmed:

@alcueca Upon second consideration, the functions relating to the minting of synths and wrapped tokens should have had the onlyRouter modifier and thus are indeed vulnerable. Issue accepted.

The original report as published on Code4rena, by TomFrenchBlockchain. 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 mintFungible function accepts a user-supplied 'from' address instead of using msg.sender, allowing anyone to pull tokens from any address that has approved the pool.

Impact

Any user who has approved tokens to VaderPoolV2 could have their entire approved balance stolen.

What the attacker needed

Victim has approved tokens to VaderPoolV2

The fix

The function should be changed to remove the 'from' argument and use msg.sender instead, and the project confirmed the issue was accepted.

How it was found

  1. Find an address that has approved VaderPoolV2 to spend its tokens.
  2. Call mintFungible with that address as the 'from' parameter.
  3. Receive LP tokens and steal the underlying 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.

When you approve a contract to spend your tokens, you trust it to only take them when you ask. Here, the contract let anyone say 'take tokens from this other person's account' and gave the attacker the pool tokens in return. So anyone who had approved the pool could lose their 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 TomFrenchBlockchain

View all

28 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.