CEthInterface#mint() reading non-existing returns makes topUp() with native token always revert
The CEthInterface incorrectly declared that mint() returns a uint256, but Compound's CEther.mint() returns nothing. As a result, calling topUp() with the native token always reverts.
Submitted by WatchPug
function mint() external payable returns (uint256);
mint() for native cToken (CEther) will return nothing, while the current CEthInterface interface defines the returns as (uint256).
In the current implementation, the interface for CToken is used for both CEther and CErc20.
As a result, the transaction will revert with the error: function returned an unexpected amount of data when topUp() with the native token (ETH).
CToken ctoken = cTokenRegistry.fetchCToken(underlying);
uint256 initialTokens = ctoken.balanceOf(address(this));
address addr = account.addr();
if (repayDebt) {
amount -= _repayAnyDebt(addr, underlying, amount, ctoken);
if (amount == 0) return true;
}
uint256 err;
if (underlying == address(0)) {
err = ctoken.mint{value: amount}(amount);
}
Ref:
method | CEther | CErc20 |
mint() | revert | error code |
redeem() | error code | error code |
repayBorrow() | revert | error code |
repayBorrowBehalf() | revert | error code |
chase-manning (Backd) 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
Impact
Any topUp() using the native token (ETH) will always revert, preventing users from supplying ETH as collateral.
What the attacker needed
TopUp() called with native token (ETH)
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 interface is like a promise about how another contract will behave. Here the promise said a function would give back a number, but the real function gives back nothing, so the call fails and the transaction is undone.
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.