Lack of access control allow attacker to mintFungible() and mintSynth() with other user’s wallet balance
The mintFungible and mintSynth functions lack access control, allowing any caller to specify the 'from' address and transfer tokens from any user who has approved the contract. An attacker could steal almost all wallet balances of users who have approved the contract.
Submitted by WatchPug
function mintFungible(
IERC20 foreignAsset,
uint256 nativeDeposit,
uint256 foreignDeposit,
address from,
address to
) external override nonReentrant returns (uint256 liquidity) {
IERC20Extended lp = wrapper.tokens(foreignAsset);
require(
lp != IERC20Extended(_ZERO_ADDRESS),
"VaderPoolV2::mintFungible: Unsupported Token"
);
(uint112 reserveNative, uint112 reserveForeign, ) = getReserves(
foreignAsset
); // gas savings
nativeAsset.safeTransferFrom(from, address(this), nativeDeposit);
foreignAsset.safeTransferFrom(from, address(this), foreignDeposit);
PairInfo storage pair = pairInfo[foreignAsset];
uint256 totalLiquidityUnits = pair.totalSupply;
if (totalLiquidityUnits == 0) liquidity = nativeDeposit;
else
liquidity = VaderMath.calculateLiquidityUnits(
nativeDeposit,
reserveNative,
foreignDeposit,
reserveForeign,
totalLiquidityUnits
);
require(
liquidity > 0,
"VaderPoolV2::mintFungible: Insufficient Liquidity Provided"
);
pair.totalSupply = totalLiquidityUnits + liquidity;
_update(
foreignAsset,
reserveNative + nativeDeposit,
reserveForeign + foreignDeposit,
reserveNative,
reserveForeign
);
lp.mint(to, liquidity);
emit Mint(from, to, nativeDeposit, foreignDeposit);
}
Funds are transferred from the from parameter, and the output tokens are transferred to the to parameter, both passed by the caller without proper access control.
Impact
This issue allows anyone to call mintFungible() and mintSynth() and steal almost all their wallet balances for all the users who have approved the contract before.
Duplicate #67
Not a duplicate.
@alcueca Can you elaborate as to why it is not a duplicate?
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 functions mintFungible and mintSynth allow the caller to specify the 'from' address without verifying that the caller is authorised to act on behalf of that address.
What the attacker needed
Victim has approved the contract
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.
In a smart contract, some functions let users deposit tokens. Here, the function that deposits tokens did not check who was calling it. So anyone could call it and say 'take tokens from this other person's wallet' and the contract would do it, as long as that person had previously allowed the contract to spend their tokens. This means an attacker could steal tokens from many users.
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.