onlyOwnerOrAssetManager can swap Yield Source in SwappableYieldSource at any time, immediately rugging all funds from old yield source
The swapYieldSource function allows the owner or asset manager to replace the yield source with any contract that implements depositToken, enabling them to rug all funds from the old yield source. An attacker with these privileges could instantly steal all deposited funds.
Originally disclosed on Code4rena
Submitted by GalloDaSballo, also found by 0xRajeev and gpersoon
The function swapYieldSource SwappableYieldSource.sol` L307
Can be called by the owner (deployer / initializer) or Asset Manager. The function will take all funds from the old Yield Source, and transfer them to the new Yield source. Any contract that implement the function function depositToken() external returns (address) will pass the check
However, if either the owner or the assetManager have malicious intent, this function allows them to instantly rug all funds
- Create a contract that implements the
function depositToken() external returns (address) - Be the Owner or
AssetManager - Call
setYieldSourcewhile pointing at your malicious contract - Profit
I highly recommend checking that the YieldSource is from a trusted registry before allowing this swap.
Alternatively forcing each Owner to be a TimeLock with at least 48 hours may provide enough security to allow this to be used in practice
PierrickGT (PoolTogether) disputed:
This is why we will use a multi sig owned by governance to deploy swappable yield sources and manage them. This way, we will avoid these kind of scenarios.
Agree with warden on the risk here. Will both the AssetManager and the Owner be owned by your governance?
The YieldSource could easily extract user funds or send them back to the SwappableYieldSource contract and then remove them from there.
PierrickGT (PoolTogether) commented:
We have removed the
AssetManagerrole andOwnerwill be owned by governance who will vet any change of yield source before going through a vote.
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 function does not verify that the new yield source is from a trusted registry, allowing any contract implementing depositToken to be used.
Impact
The owner or asset manager could instantly rug all funds from the old yield source, stealing all deposited assets.
What the attacker needed
Be the owner or asset manager; malicious intent
The fix
The project removed the AssetManager role and made the Owner a governance-controlled address that vets yield source changes.
How it was found
- Create a contract that implements the depositToken function
- Be the Owner or AssetManager
- Call setYieldSource pointing to the malicious contract
- Profit
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 yield source is where deposited money is invested to earn interest. The contract lets a privileged user (owner or asset manager) switch to a new yield source without any checks. If that user is malicious, they can point to a fake yield source and take all the money.
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.