Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: medium
Invalid

Asset Balance Increase During Conversion

Summary

Asset conversion logic fails to ensure that the asset balance does not increase, leading to incorrect accounting and potential financial discrepancies.

Vulnerability Details

/CreditDelegationBranch.sol/convertMarketsCreditDepositsToUsdc

function convertMarketsCreditDepositsToUsdc(
uint128 marketId,
address[] calldata assets,
uint128[] calldata strategyIds,
bytes[] calldata paths
) external onlyRegisteredSystemKeepers {
// Missing balance check to ensure asset balance does not increase
...
}

The convertMarketsCreditDepositsToUsdc function in CreditDelegationBranch.sol lacks a balance check to ensure that the asset balance does not increase after conversion. This allows a strategy to manipulate the asset balance, leading to incorrect accounting and potential financial discrepancies. The absence of this check violates the rule validateAssetConversion, which explicitly requires the asset balance to remain unchanged or decrease.

How it Happens

  1. A system keeper calls convertMarketsCreditDepositsToUsdc with a strategy that allows the asset balance to increase.

  2. The function processes the conversion without enforcing a balance check.

Variables

  • Pre-Conversion:

    • initialBalance = 100

    • assetBalances[assets[0]] = 100

  • Post-Conversion:

    • assetBalances[assets[0]] = 150 (expected to remain <= 100)

Impact

  • The asset balance increase could lead to incorrect accounting, affecting the protocol's financial stability.

  • The system's state tracking becomes unreliable, leading to inconsistencies in refund processing.

Tools Used

vs

Recommendations

Add a balance check in the convertMarketsCreditDepositsToUsdc function to ensure the asset balance does not increase:

function convertMarketsCreditDepositsToUsdc(
uint128 marketId,
address[] calldata assets,
uint128[] calldata strategyIds,
bytes[] calldata paths
) external onlyRegisteredSystemKeepers {
uint256 initialBalance = assetBalances[assets[0]];
...
require(assetBalances[assets[0]] <= initialBalance, "Asset balance must not increase after conversion");
}
Updates

Lead Judging Commences

inallhonesty Lead Judge
6 months ago
inallhonesty Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.