Collateral can get stuck in the minting contract under certain conditions or be accounted as profit
The minting contract does not track collateral withdrawn from custodial partners for pending redeem requests, so if a redeem is cancelled or rejected, those funds become stuck and cannot be returned. Additionally, such untracked collateral can be mistakenly accounted as profit, leading to the minting of undercollateralized YUSD.
iamandreiski Follow with vinica_boy
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-04-aegis-op-grant-judging/issues/77
This issue has been acknowledged by the team but won't be fixed at this time.
Found by
iamandreiski, vinica_boy
Summary
The predominant narrative of Aegis is that they aren't holding any funds in their minting contract. This means that all collateral which was transferred to the contract for the purpose of minting YUSD is transferred to their custodial partners for safekeeping OR is accounted for as profit which would result in YUSD being minted in exchange for it, and then said collateral transferred to their custodial partners for safekeeping.
This warrants the need for a 2-step redeem flow which first registers the redeem request, and then withdraws the needed collateral from the custodial partners after which the redeem can be accepted and the collateral transferred to the user. The problem with this approach is that these funds are "untracked", together with the profit.
There are multiple ways in which collateral can get "stuck" in the contract OR be mistaken for profit:
- A redeem request was rejected or cancelled;
- The redeem request acceptance reverts due to any number of reasons such as the user was placed on a blacklist and/or the order has expired;
- A
depositIncomecall mistakenly accounts untracked collateral funds as profit, resulting in the minting of non-collateralized YUSD which contributes to its de-pegging.
Root Cause
The current design of the system doesn't account (virtually) for both the funds which are to-be-redeemed, as well as the income (i.e. profit). The problem of not accounting for the redeem funds is that they can either be mistaken for an income, or remain stuck in the contract with no way to return them to the custodial partners.
When a user requests a redeem, the request is placed and pending as part of _redeemRequests:
_redeemRequests[keccak256(abi.encode(requestId))] = RedeemRequest(RedeemRequestStatus.PENDING, order, block.timestamp);
Once the "untracked" funds become available in the minting contract (i.e. are withdrawn from the custodial partners), the redeem request can be accepted/approved:
uint256 availableAssetFunds = _untrackedAvailableAssetBalance(request.order.collateralAsset);
if (availableAssetFunds < collateralAmount) {
revert NotEnoughFunds();
}
function _untrackedAvailableAssetBalance(address _asset) internal view returns (uint256) {
uint256 balance = IERC20(_asset).balanceOf(address(this));
if (balance < _custodyTransferrableAssetFunds[_asset] + assetFrozenFunds[_asset]) {
return 0;
}
return balance - _custodyTransferrableAssetFunds[_asset] - assetFrozenFunds[_asset];
}
The problem with this approach is that redeem requests are expected to fail / get cancelled after the funds were withdrawn from the custodial partners to the minting contract.
- User could cancel their redeem requests after the funds were already withdrawn to the contract, but before the request is approved;
- An exchange ratio change has prompted the call to be rejected due to slippage;
- The user was placed on a blacklist and the call reverts;
- The order has expired;
Any of (but not limited to) the above-mentioned scenarios could result in the user not being able to claim their collateral, the request being rejected/cancelled and the funds remaining stuck in the minting contract. Since currently, there's no way to send untracked funds to the custodial partners, they will remain stuck within the minting contract.
This is also a problem if the redeem request was a very large amount which affects the balancing strategy of Aegis, and not being able to utilize those funds as part of their delta-neutral position strategy.
A second point of this report is that if the funds stuck in the contract are "mistaken" or otherwise intentionally declared as profit, this would lead to the minting of undercollateralized YUSD.
Considering that the "extra" collateral in the minting contract can be declared as profit by minting adequate and corresponding YUSD amounts through depositIncome, the function assumes that the untracked collateral in-question wasn't utilized for the minting of YUSD tokens:
And that's why it's being treated as a normal mint flow in which the user provides collateral and receives a corresponding amount of YUSD tokens in exchange for the collateral supplied.
Internal Pre-conditions
- A certain collateral amount is deposited to the minting contract from the custodial partners for the purpose of approving redeem requests;
- Said redeem requests can't be approved due to a multitude of reasons and are rejected or cancelled, leading to the already withdrawn "untracked" collateral to be stuck in the contract and unable to be sent back to the custodial counterparts.
External Pre-conditions
N/A
Attack Path
N/A
Impact
The untracked collateral amounts withdrawn to the minting contract which are unused (i.e. haven't been utilized for redeems) will remain stuck in the contract or can be declared as profit which will lead to the minting of undercollateralized YUSD.
PoC
No response
Mitigation
Include an admin controlled mechanism to be able to repurpose unused redeem funds as _custodyTransferrableAssetFunds or make a separate request funds flow which will track the amounts and enable redeem approvals (and if they get rejected, the funds get atomically repurposed).
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 contract lacks accounting for redeem funds and profit, so untracked collateral can be mistaken for income or become stuck.
Impact
Untracked collateral can remain stuck in the contract or be declared as profit, leading to the minting of undercollateralized YUSD.
What the attacker needed
Collateral withdrawn for redeem; redeem request cancelled or rejected
The fix
An admin-controlled mechanism should be added to repurpose unused redeem funds as custody transferrable asset funds, or a separate request funds flow should track amounts and enable atomic repurposing if a redeem is rejected.
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.
When someone wants to redeem their YUSD for collateral, the system first moves the collateral from a custodian into a minting contract. If the redemption is later cancelled or fails, the contract has no way to send that collateral back, so it gets stuck. Also, the contract might treat that extra collateral as profit and mint new YUSD without backing, which is dangerous.
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.