-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
2 (Med Risk)Assets not at direct risk, but function/availability of the protocol could be impacted or leak valueAssets not at direct risk, but function/availability of the protocol could be impacted or leak value🤖_22_groupAI based duplicate group recommendationAI based duplicate group recommendation🤖_primaryAI based primary recommendationAI based primary recommendationM-02bugSomething isn't workingSomething isn't workingdowngraded by judgeJudge downgraded the risk level of this issueJudge downgraded the risk level of this issueedited-by-wardenprimary issueHighest quality submission among a set of duplicatesHighest quality submission among a set of duplicatesselected for reportThis submission will be included/highlighted in the audit reportThis submission will be included/highlighted in the audit reportsponsor confirmedSponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Description
Lines of code
Vulnerability details
Impact
When totalSupply = 0, the attacker donates 1wei token, causing the number of shares to remain 0 at deposit time.
Proof of Concept
The toBase function only determines whether total.elastic(_totalAssets) is 0, not whether totalSupply is 0.
function toBase(Rebase memory total, uint256 elastic,bool roundUp
) internal pure returns (uint256 base) {
@ if (total.elastic == 0) {
base = elastic;
} else {
//total.base = totalSupply ; total.elastic = _totalAssets
base = (elastic * total.base) / total.elastic;
if (roundUp && (base * total.elastic) / total.base < elastic) {
base++;
}
}
}When totalSupply=0, if _totalAssets > 0, toBase always returns 0.
An attacker can make a donation of _totalAssets > 0, the toBase function will then compute base through a branch in the else statement, since totalSupply=0
base = 0 * elastic / total.elastic = 0,
As a result, the number of deposit shares is always 0, and the protocol will not work.
function deposit(address receiver) ....{
.....
shares = total.toBase(amount, false);
_mint(receiver, shares);
emit Deposit(msg.sender, receiver, msg.value, shares);
}An attacker can send Collateral token to the StrategyAAVEv3(address(this)) contract,
_totalAssets = collateralBalance - debtBalance
function _getMMPosition() internal virtual override view returns ( uint256 collateralBalance, uint256 debtBalance ) {
DataTypes.ReserveData memory wethReserve = (aaveV3().getReserveData(wETHA()));
DataTypes.ReserveData memory colleteralReserve = (aaveV3().getReserveData(ierc20A()));
debtBalance = IERC20(wethReserve.variableDebtTokenAddress).balanceOf(address(this));
collateralBalance = IERC20(colleteralReserve.aTokenAddress).balanceOf(address(this));
}Tools Used
vscode, manual
Recommended Mitigation Steps
function toBase(Rebase memory total, uint256 elastic,bool roundUp
) internal pure returns (uint256 base) {
- if (total.elastic == 0) {
+ if (total.elastic == 0 || total.base == 0) {
base = elastic;
} else {
//total.base = totalSupply ; total.elastic = _totalAssets
base = (elastic * total.base) / total.elastic;
if (roundUp && (base * total.elastic) / total.base < elastic) {
base++;
}
}
}Assessed type
DoS
Metadata
Metadata
Assignees
Labels
2 (Med Risk)Assets not at direct risk, but function/availability of the protocol could be impacted or leak valueAssets not at direct risk, but function/availability of the protocol could be impacted or leak value🤖_22_groupAI based duplicate group recommendationAI based duplicate group recommendation🤖_primaryAI based primary recommendationAI based primary recommendationM-02bugSomething isn't workingSomething isn't workingdowngraded by judgeJudge downgraded the risk level of this issueJudge downgraded the risk level of this issueedited-by-wardenprimary issueHighest quality submission among a set of duplicatesHighest quality submission among a set of duplicatesselected for reportThis submission will be included/highlighted in the audit reportThis submission will be included/highlighted in the audit reportsponsor confirmedSponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")