AdapterBase should always use delegatecall to call the functions in the strategy
The AdapterBase contract calls strategy verification and setup functions directly instead of using delegatecall, so the strategy contract's context is used and the calls fail because the strategy does not implement the adapter interface. This prevents creating a vault with that strategy, and if setup succeeds partially, later harvest calls may fail due to invalid settings.
Submitted by cccz, also found by bin2chen
The strategy contract will generally let the Adapter contract use delegatecall to call its functions.
So IAdapter(address(this)).call is used frequently in strategy contracts, because when the Adapter calls the strategy’s functions using delegatecall, address(this) is the Adapter:
function harvest() public override {
address router = abi.decode(IAdapter(address(this)).strategyConfig(), (address));
address asset = IAdapter(address(this)).asset();
...
But in AdapterBase._verifyAndSetupStrategy, the verifyAdapterSelectorCompatibility/verifyAdapterCompatibility/setUp functions are not called with delegatecall, which causes the context of these functions to be the strategy contract:
function _verifyAndSetupStrategy(bytes4[8] memory requiredSigs) internal {
strategy.verifyAdapterSelectorCompatibility(requiredSigs);
strategy.verifyAdapterCompatibility(strategyConfig);
strategy.setUp(strategyConfig);
}
And since the strategy contract does not implement the interface of the Adapter contract, these functions will fail, making it impossible to create a Vault using that strategy.
function verifyAdapterCompatibility(bytes memory data) public override {
address router = abi.decode(data, (address));
address asset = IAdapter(address(this)).asset();
More dangerously, if functions such as setup are executed successfully because they do not call the Adapter’s functions, they may later error out when calling the harvest function because the settings in setup are invalid.
Proof of Concept
Recommended Mitigation Steps
In AdapterBase.\_verifyAndSetupStrategy, the verifyAdapterSelectorCompatibility/verifyAdapterCompatibility/setUp functions are called using delegatecall.
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
Likely the AdapterBase contract used a regular call instead of delegatecall when invoking strategy verification and setup functions, causing the strategy contract to execute in its own context rather than the adapter's context.
Impact
Creating a vault with the affected strategy fails, and if setup partially succeeds, later harvest calls may fail because the settings are invalid.
What the attacker needed
A strategy contract that relies on delegatecall; vault creation using that strategy
The fix
The AdapterBase contract should use delegatecall to call the verifyAdapterSelectorCompatibility, verifyAdapterCompatibility, and setUp functions.
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 can call another contract in two ways: a normal call runs the other contract's code in its own context, while delegatecall runs the other contract's code as if it were part of the calling contract. Here, the adapter contract is supposed to run the strategy's setup code as itself, but it used a normal call, so the strategy's code tried to use functions it does not have and failed. This meant a vault could not be created with that strategy.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.