Redeemer.sol#redeem() can be called by anyone before maturity, which may lead to loss of user funds
The redeem function in Redeemer.sol is public and can be called by anyone before maturity. For protocols like Notional that allow early redemption, this forces a discounted sale of the protocol's holdings, causing fund loss to stakeholders.
Submitted by WatchPug, also found by csanuragjain, datapunk, and Lambda
function redeem(
uint8 p,
address u,
uint256 m
) public returns (bool) {
// Get the principal token that is being redeemed by the user
address principal = IMarketPlace(marketPlace).markets(u, m, p);
// Make sure we have the correct principal
if (
p != uint8(MarketPlace.Principals.Swivel) &&
p != uint8(MarketPlace.Principals.Element) &&
p != uint8(MarketPlace.Principals.Yield) &&
p != uint8(MarketPlace.Principals.Notional)
) {
revert Invalid('principal');
}
// The amount redeemed should be the balance of the principal token held by the Illuminate contract
uint256 amount = IERC20(principal).balanceOf(lender);
// Transfer the principal token from the lender contract to here
Safe.transferFrom(IERC20(principal), lender, address(this), amount);
if (p == uint8(MarketPlace.Principals.Swivel)) {
// Redeems zc tokens to the sender's address
ISwivel(swivelAddr).redeemZcToken(u, m, amount);
} else if (p == uint8(MarketPlace.Principals.Element)) {
// Redeems principal tokens from element
IElementToken(principal).withdrawPrincipal(amount, marketPlace);
} else if (p == uint8(MarketPlace.Principals.Yield)) {
// Redeems prinicipal tokens from yield
IYieldToken(principal).redeem(address(this), address(this), amount);
} else if (p == uint8(MarketPlace.Principals.Notional)) {
// Redeems the principal token from notional
amount = INotional(principal).maxRedeem(address(this));
}
emit Redeem(p, u, m, amount);
return true;
}
There are some protocols (eg Notional) that allows redeem before maturity, when doing so, they will actually make a market sell, usually means a discounted sale.
Since redeem() is a public function, anyone can call it before maturity, and force the whole protocol to sell it’s holdings at a discounted price, causing fund loss to the stake holders.
function previewRedeem(uint256 shares) public view override returns (uint256 assets) {
if (hasMatured()) {
assets = convertToAssets(shares);
} else {
// If withdrawing non-matured assets, we sell them on the market (i.e. borrow)
(uint16 currencyId, uint40 maturity) = getDecodedID();
(assets, /* */, /* */, /* */) = NotionalV2.getPrincipalFromfCashBorrow(
currencyId,
shares,
maturity,
0,
block.timestamp
);
}
}
Recommendation
Consider only allow unauthenticated call after maturity.
JTraversa (Illuminate) confirmed
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 redeem function lacks an access control check to ensure it is only called after maturity.
Impact
An attacker could force the protocol to sell its holdings at a discounted price before maturity, causing fund loss to stakeholders.
What the attacker needed
None
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 has a function that lets users redeem their tokens. Because anyone can call it, an attacker can trigger it early, forcing the protocol to sell assets at a lower price than if it waited. This means the protocol and its users lose 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.