Vault.mintYieldFee function can be called by anyone to mint Vault Shares to any recipient address
The Vault.mintYieldFee function lacks access control and lets the caller choose the recipient address, so anyone can mint the accrued yield fee shares to themselves or any address. This allows theft of the available yield fee as long as the vault is collateralised and the requested shares do not exceed the accrued fee supply.
Udsen Follow with minhtrng, markus_ether and 35 others
Originally disclosed on Code4rena
Submitted by Udsen, also found by minhtrng, markus_ether, GREY-HAWK-REACH, KupiaSec, serial-coder, Aymen0909, peanuts, teawaterwire, ni8mare, alexweb3, josephdara, zzzitron, Jeiwan, Nyx, keccak123, LuchoLeonel1, btk, seeques, 0xPsuedoPandit, 0xMirce, RedTiger, Praise, bin2chen, ktg, Bobface, rvierdiiev, wangxx2026, 0xbepresent, dirk_y, ptsanev, shaka, dacian, mahdirostami, John, 0xStalin, ravikiranweb3, and Co0nan
The Vault.mintYieldFee external function is used to mint Vault shares to the yield fee _recipient. The function is an external function and can be called by anyone since there is no access control. The function will revert only under following two conditions:
- If the Vault is under-collateralized.
- If the
_sharesare greater than the accrued_yieldFeeTotalSupply.
The issue with this function is, it allows the caller to set the _recipient (address of the yield fee recipient). It does not use the _yieldFeeRecipient state variable, which was set in the Vault.constructor as the yield fee recipient.
Which means, anyone can steal the available yield fee from the vault (as long as the above two revert conditions are not satisfied) by minting shares to their own address or to any address of their choice.
Proof of Concept
function mintYieldFee(uint256 _shares, address _recipient) external {
_requireVaultCollateralized();
if (_shares > _yieldFeeTotalSupply) revert YieldFeeGTAvailable(_shares, _yieldFeeTotalSupply);
_yieldFeeTotalSupply -= _shares;
_mint(_recipient, _shares);
emit MintYieldFee(msg.sender, _recipient, _shares);
}
Tools Used
VSCode
Recommended Mitigation Steps
Hence, it is recommended to use the _yieldFeeRecipient state variable value as the yield fee recipient inside the Vault.mintYieldFee external function and to remove the input parameter address _recipient from the Vault.mintYieldFee function; so that the caller will not be able to mint shares to any arbitrary address of their choice and steal the yield fee of the protocol.
The updated function should be as follows:
function mintYieldFee(uint256 _shares) external {
_requireVaultCollateralized();
if (_shares > _yieldFeeTotalSupply) revert YieldFeeGTAvailable(_shares, _yieldFeeTotalSupply);
_yieldFeeTotalSupply -= _shares;
_mint(_yieldFeeRecipient, _shares);
emit MintYieldFee(msg.sender, _recipient, _shares);
}
asselstine (PoolTogether) confirmed
Removed recipient param. PR: https://github.com/GenerationSoftware/pt-v5-vault/pull/7
Status: Mitigation confirmed. Full details in reports from rvierdiiev, dirk_y and 0xStalin.
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 mintYieldFee function has no access control and accepts an arbitrary recipient instead of using the stored _yieldFeeRecipient state variable.
Impact
Anyone could mint the available yield fee shares to an address of their choice, stealing the protocol's yield fee, provided the vault is collateralised and the requested shares do not exceed the accrued fee supply.
What the attacker needed
Vault is collateralised; shares <= accrued yield fee supply
The fix
The recipient parameter was removed so the function always mints to the stored _yieldFeeRecipient; the project mitigated this and the mitigation was confirmed.
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.
A vault holds pooled money and keeps a small fee that should go to a designated recipient. The function that hands out that fee did not check who was calling and let the caller name any recipient, so any user could give the fee to themselves. The fix is to remove the recipient input and always pay the stored fee recipient.
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.