Yearn vault integration is broken
The Compounding library calls a non-existent 'underlying' function on Yearn vaults, causing a revert. This prevents creating a MarketPlace associated with a Yearn vault, breaking the stated integration.
Submitted by bardamu
Impact
Yearn integration is broken, making it impossible to create a MarketPlace associated with a Yearn vault.
Proof of Concept
Compounding.sol attempts to resolve the underlying token implemented by supported protocols:
function underlying(uint8 p, address c) internal view returns (address) {
if (p == uint8(Protocols.Compound)) {
return ICompoundToken(c).underlying();
} else if (p == uint8(Protocols.Rari)) {
return ICompoundToken(c).underlying();
} else if (p == uint8(Protocols.Yearn)) {
return IYearnVault(c).underlying();
} else if (p == uint8(Protocols.Aave)) {
return IAaveToken(c).UNDERLYING_ASSET_ADDRESS();
} else if (p == uint8(Protocols.Euler)) {
return IEulerToken(c).underlyingAsset();
} else {
return IErc4626(c).asset();
}
}
As can be seen in the excerpt above, the contract will attempt to access IYearnVault(c).underlying(); when integrating with a Yearn vault. Problem is this property is not present in Yearn vaults. Therefore this operation will always revert.
In particular, this would not allow to create a MarketPlace associated with a Yearn vault even though the protocol is stated as supported.
function createMarket(
uint8 p,
uint256 m,
address c,
string memory n,
string memory s
) external authorized(admin) unpaused(p) returns (bool) {
if (swivel == address(0)) { revert Exception(21, 0, 0, address(0), address(0)); }
address underAddr = Compounding.underlying(p, c);
Correct underlying token address in Yearn vaults is stored in the token property.
Tools Used
VIM
Recommended Mitigation Steps
Access the underlying token of a Yearn vault through the token property instead of the non-existent underlying which will cause a revert and the inability to create marketplaces associated with the protocol.
JTraversa (Swivel) disagreed with severity and commented:
Given no funds would be at risk as this is an issue that would exist at the time of admin’s market creation, I’d probably say that this issue is likely ~Low or so.
bghughes (judge) decreaased severity to Medium and commented:
Agreed that funds are not necessarily at risk but this is a broken functionality of the protocol. Given:
There are a few primary targets for concern:
- Ensuring the new
Compounding.sollibrary properly calculates the exchangeRate for each external protocol.- Ensuring the new
withdrawanddepositmethods onSwivel.solproperly encapsulate external protocol interactions.I believe this should be a Medium Risk issue.
robrobbins (Swivel) commented:
The example given is incorrect.
Compounding.Underlying()is correct asCompoundingis our library that abstracts the actual call to get the asset in question.The actual error is in the Compounding lib where
.Protocolresolves toProtocols.Yearn.
Addressed: https://github.com/Swivel-Finance/gost/pull/422.
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 code calls IYearnVault(c).underlying(), but Yearn vaults store the underlying token in a 'token' property instead.
Impact
Creating a MarketPlace associated with a Yearn vault is impossible, though no funds are directly at risk.
What the attacker needed
Admin creates a market for a Yearn vault
The fix
The integration was fixed by accessing the underlying token through the correct property, as addressed in a pull request.
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 smart contract tried to ask a Yearn vault for its underlying token using a function name that Yearn vaults do not have. Because the function does not exist, the call fails every time, so the feature that creates a market for Yearn vaults cannot work.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.