PositionAction4626.sol#_onWithdraw should withdraw from position CDPVault position instead of address(this)
The ERC4626 position action withdrew collateral from the proxy contract itself rather than from the CDPVault position address passed in, unlike the sibling position action contracts. This meant the proxy could not perform withdrawals on behalf of positions other than its own, breaking the intended cross-position functionality.
In PositionAction4626, the _onWithdraw should withdraw the token from position CDPVault position. However, currently it withdraws from address(this). This is inconsistent to the parent contract PositionAction.sol, which specifically states the operation should handle the position address.
Also, in contrast, we can check the PositionAction20 contract, it withdraws from the position address.
PositionAction4626.sol:
function _onWithdraw(address vault, address /*position*/, address dst, uint256 amount) internal override returns (uint256) {
> uint256 collateralWithdrawn = ICDPVault(vault).withdraw(address(this), amount);
// if collateral is not the dst token, we need to withdraw the underlying from the ERC4626 vault
address collateral = address(ICDPVault(vault).token());
if (dst != collateral) {
collateralWithdrawn = IERC4626(collateral).redeem(collateralWithdrawn, address(this), address(this));
}
return collateralWithdrawn;
}
/// @notice Hook to withdraw collateral from CDPVault, handles any CDP specific actions
/// @param vault The CDP Vault
> /// @param position The CDP Vault position
/// @param dst Token the caller expects to receive
/// @param amount The amount of collateral to deposit [wad]
/// @return Amount of collateral (or dst) withdrawn [CDPVault.tokenScale()]
function _onWithdraw(address vault, address position, address dst, uint256 amount) internal virtual returns (uint256);
@Koolex - The proxy supports depositing/withdrawing collateral from positions other than the proxy itself. An example can be found in unit tests, where a user creates a position for another address (aliceProxy).
The issue here is that for PositionAction4626, it only supports actions on the vault of the sender proxy, and not any other address. To make a comparison, both PositionAction20 and PositionActionPendle supports it, only PositionAction4626 lack this functionality.
The original report as published on Code4rena, by pkqs90. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 40 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
Likely the withdraw call hardcoded address(this) instead of using the position parameter supplied to the hook.
Impact
Withdrawals through this contract only work for the sender's own proxy position, so the proxy cannot withdraw collateral from other positions, unlike the other position action contracts.
What the attacker needed
A proxy position other than the caller's own
The fix
The withdraw call should pass the position address rather than address(this); the team confirmed the issue.
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.
Generating the AI write-up for this report.
This usually takes about 40 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
A proxy contract lets a user act on a vault on their behalf. The code that handles withdrawals was told which position to take collateral from, but it ignored that and took it from the proxy's own balance instead. That means actions aimed at someone else's position would not work as designed.
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.