Status DataClose notification

OpenEden Disclosed Report

Audit Report

Quota Removal Incorrectly Decrements totalUsed, Enabling Protocol Insolvency Through Over-Allocation

Target

https://github.com/OpenEdenHQ/openeden.usdoexpress.audit/tree/f3f31d2ac15e3253cba342229f9d05495f95d6fd

Vulnerability details

In contract LiquidityController there is '''solidity function setUserQuota(address user, uint256 quota) external onlyOwner { uint256 oldQuota = userQuotas[user]; uint256 usedQuota = usedQuotas[user];

    // Update total allocated accounting
    if (oldQuota > 0) {
        totalAllocated = totalAllocated - oldQuota;
    }

    if (quota > 0) {
        // Check that new quota isn't less than already used amount
        if (quota < usedQuota) {
            revert QuotaExceedsUsed(quota, usedQuota);
        }

        // Check if new allocation fits within total liquidity
        if (totalAllocated + quota > totalLiquidity) {
            revert QuotaExceedsTotal(quota, totalLiquidity - totalAllocated);
        }

        totalAllocated = totalAllocated + quota;

        // Add to users array if new user
        if (!authorizedUsers[user]) {
            users.push(user);
            authorizedUsers[user] = true;
        }
    } else {
        // Removing quota - also clear used quota
        authorizedUsers[user] = false;
        if (usedQuota > 0) {
            totalUsed = totalUsed - usedQuota;
            usedQuotas[user] = 0;
        }
    }

    userQuotas[user] = quota;

    emit QuotaSet(user, quota);
}

''' // Removing quota - also clear used quota Root Cause: When the owner sets a user's quota to zero (effectively removing them), the function incorrectly:

  1. Decrements totalUsed by the amount of liquidity the user had already consumed
  2. Clears usedQuotas[user] to 0, erasing evidence of actual liquidity consumption.

This breaks the fundamental accounting invariant that totalUsed must always represent actual consumed liquidity from the pool. The consumed liquidity doesn't magically return to the pool when a quota is removed—it's already been spent/redeemed.

Impact:

  1. Accounting Corruption: totalUsed no longer reflects reality, showing less consumption than actually occurred
  2. Over-Allocation: The artificially reduced totalUsed allows new users to reserve more liquidity than physically exists in the pool
  3. Protocol Insolvency: Total reserved liquidity can exceed totalLiquidity, making the system unable to fulfill all redemptions

Recommended Fix: '''solidity function setUserQuota(address user, uint256 quota) external onlyOwner { uint256 oldQuota = userQuotas[user]; uint256 usedQuota = usedQuotas[user];

// Update total allocated accounting
if (oldQuota > 0) {
    totalAllocated = totalAllocated - oldQuota;
}

if (quota > 0) {
    // Check that new quota isn't less than already used amount
    if (quota < usedQuota) {
        revert QuotaExceedsUsed(quota, usedQuota);
    }

    // Check if new allocation fits within total liquidity
    if (totalAllocated + quota > totalLiquidity) {
        revert QuotaExceedsTotal(quota, totalLiquidity - totalAllocated);
    }

    totalAllocated = totalAllocated + quota;

    // Add to users array if new user
    if (!authorizedUsers[user]) {
        users.push(user);
        authorizedUsers[user] = true;
    }
} else {
    // ✅ FIX: Removing quota - require no outstanding consumption
    if (usedQuota > 0) {
        revert CannotRemoveQuotaWithActiveConsumption(user, usedQuota);
    }
    authorizedUsers[user] = false;
    // DO NOT modify totalUsed - it represents actual consumption
    // DO NOT modify usedQuotas[user] - keep consumption record
}

userQuotas[user] = quota;

emit QuotaSet(user, quota);

} '''

Validation steps

  1. Deploy LiquidityController with 1M total liquidity
  2. Set quotas: Alice 300k, Bob 400k, Charlie 300k
  3. Reserve: Alice 300k, Bob 400k (totalUsed = 700k)
  4. Call setUserQuota(alice, 0) - BUG TRIGGERS
  5. Check totalUsed - will show 400k instead of 700k ❌
  6. Set Dave quota 300k (now totalAllocated = 1M)
  7. Dave reserves 300k (totalUsed shows 700k)
  8. Remove Charlie, add Eve with 300k, Eve reserves 300k
  9. System shows totalUsed = 1M but reality is 1.3M consumed
  10. Protocol is insolvent by 300k

Attachments

Attachments are hidden

This information is not publicly available.

Comments are hidden

This information is not publicly available.