Skip to content
DoS Audit finding Intermediate

The unregistering of vaults can be DoSed by a malicious user.

The vault unregistration functions in both share token contracts refuse to proceed while any asset balance or pending/claimable amount remains, so an attacker can send a tiny amount of tokens to a vault or leave a dust balance unredeemed to block removal. With the ten-vault limit reached, the owner could not unregister an unused vault to register a replacement.

dimulski Follow with 0rpse, 0x_oi and 48 others

Originally disclosed on Code4rena

Submitted by dimulski, also found by 0rpse, 0x_oi, 0xApple, 0xD4n13l, 0xdoichantran, 0xhunter20, 0xlucky, 0xMafiaBug, 0xnightswatch, 0xSecurious, Aamir, aestheticbhai, ahahaHard1k, al0x23, ameng, ami, anchabadze, Audittens, Avalance, Bala1796, blutorque, Bobai23, c0pp3rscr3w3r, cheng9061, cosin3, cpsec, cryptolyndon, demaxl, Ekene, farismaulana, Flare, fullstop, gabkov, Gakarot, glorbo, h2134, hezze, hgrano, holtzzx, igbinosuneric, j3x, jasonxiale, JoshuaM33, Keepitfortoby, khaye26, KuwaTakushi, lazlosoot, lodelux, MadSisyphus, mahdifa, makarov, Mathriel, meshaqRapha, mrMorningstar, MysteryAuditor, Nyxaris, oldguard, orangesantra, osok, phoenixV110, PotEater, prk0, romans, s4bot3ur, Sabit, saraswati, SarveshLimaye, ScarletFir, ShaedyWays, skipper, Sneks, SOPROBRO, sri, Tarnished, TheWitchDoctor, trachev, Uddercover, Utsav, Valves, whitehair0330, Willy_Petrus, Wojack, x86sgn, xAlismx, and ZafiN

  • src/ShareTokenUpgradeable.sol #L282
  • src/WERC7575ShareToken.sol #L256

Both the ShareTokenUpgradeable.sol and the WERC7575ShareToken.sol contracts have mechanisms to remove vaults in order to unlink them from the share token. Both contracts allow a maximum of 10 vaults to be registered. The implementation of the unregisterVault() function is different in both of the contracts, however in both instances the unregistering of a vault can be DoSed.

In the ShareTokenUpgradeable.sol the unregisterVault() function performs several checks:

    function unregisterVault(address asset) external onlyOwner {
        if (asset == address(0)) revert ZeroAddress();
        ShareTokenStorage storage $ = _getShareTokenStorage();

        (bool exists, address vaultAddress) = $.assetToVault.tryGet(asset);
        if (!exists) revert AssetNotRegistered();

        // COMPREHENSIVE SAFETY CHECK: Ensure vault has no user funds at risk
        // This covers pending deposits, claimable redemptions, ERC7887 cancelations, and any remaining assets

        // 1. Check vault metrics for pending requests, active users, and ERC7887 cancelation assets
        try IVaultMetrics(vaultAddress).getVaultMetrics() returns (IVaultMetrics.VaultMetrics memory metrics) {
            if (metrics.isActive) revert CannotUnregisterActiveVault();
            if (metrics.totalPendingDepositAssets != 0) {
                revert CannotUnregisterVaultPendingDeposits();
            }
            if (metrics.totalClaimableRedeemAssets != 0) {
                revert CannotUnregisterVaultClaimableRedemptions();
            }
            if (metrics.totalCancelDepositAssets != 0) {
                revert CannotUnregisterVaultAssetBalance();
            }
            if (metrics.activeDepositRequestersCount != 0) {
                revert CannotUnregisterVaultActiveDepositRequesters();
            }
            if (metrics.activeRedeemRequestersCount != 0) {
                revert CannotUnregisterVaultActiveRedeemRequesters();
            }
        } catch {
            // If we can't get vault metrics, we can't safely verify no pending requests
            revert CannotUnregisterActiveVault();
        }
        // 2. Final safety: Check raw asset balance in vault contract
        // This catches any remaining assets including investments and edge cases
        // If this happens, there is either a bug in the vault
        // or assets were sent to the vault without directly
        if (IERC20(asset).balanceOf(vaultAddress) != 0) {
            revert CannotUnregisterVaultAssetBalance();
        }

        // Remove vault registration (automatically removes from enumerable collection)
        $.assetToVault.remove(asset);
        delete $.vaultToAsset[vaultAddress];

        emit VaultUpdate(asset, address(0));
    }

As seen from the code snippet above, there are multiple ways a malicious actor can brick the removal of a vault. He can always frontrun the call to the unregisterVault() function and transfer 1 WEI to the ERC7575VaultUpgradeable.sol contract implementation that the owner is trying to unregister.

Additionally, he can always leave 1 WEI of assets that he doesn’t redeem in the totalClaimableRedeemAssets additionally that will keep the activeRedeemRequestersCount parameter bigger than 0. Similarly malicious depositors can keep 1 WEI in their respective claimableDepositAssets mapping and this way they won’t be removed from the activeDepositRequesters enumerable set, and the activeDepositRequestersCount will be bigger than 0.

In the WERC7575ShareToken.sol contract, the unregisterVault() function checks the asset balance of the specified vault. The WERC7575Vault.sol contract has a pausing mechanism that prevents the user from depositing and withdrawing if the contract is paused. However there is no functionality that prevents a user from transferring 1 WEI of the vault asset to the contract. There are no mechanisms that allow a trusted role to remove any dust amounts from the contract. A user can always transfer 1 WEI to the WERC7575Vault.sol contract in order to DoS the call to unregisterVault() function.

Additionally, the contracts are to be deployed on Berachain where malicious actors can always frontrun the call to the unregisterVault() function.

If there are already 10 vaults associated with the share token, and users are not utilizing 1 vault, the admin won’t be able to remove that vault and register another vault in its place. This breaks a core contract functionality.

Recommended mitigation steps

To fix the problem with unregisterVault() in the ShareTokenUpgradeable.sol contract, in the ERC7575VaultUpgradeable.sol contract, consider adding admin modifier to the deposit(), mint(), redeem(), withdraw(), claimCancelDepositRequest() and claimCancelRedeemRequest() functions in order to run those functions for the respective users. Additionally consider adding an admin function that can set the totalClaimableRedeemAssets and the totalPendingDepositAssets parameters to 0, if there are some dust amounts in them. Or change the ShareTokenUpgradeable::unregisterVault() to allow a vault to be unregistered even if there are some dust amounts left.

To fix the problem with unregisterVault() in the WERC7575ShareToken.sol contract, consider adding an admin function that can withdraw dust amounts from the WERC7575Vault.sol contract.


The original report as published on Code4rena, by dimulski. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

Likely the unregistration check treats any non-zero balance or pending amount, including unsolicited dust, as a hard blocker with no admin override to clear it.

Impact

The owner could be unable to unregister an unused vault, so once ten vaults are registered no replacement vault can be added, breaking a core function; the text notes the contracts are to be deployed on Berachain where the call can be frontrun.

What the attacker needed

Ten vaults already registered; attacker can send tokens to the vault; or a user leaves a dust balance unclaimed

The fix

The report recommends adding an admin function to clear dust amounts or withdraw dust from the vault, or allowing unregistration despite dust balances.

How it was found

  1. Reach the ten-vault registration limit on the share token.
  2. Send a tiny amount of the vault asset directly to the vault contract, or leave a tiny redeemable or claimable amount unclaimed.
  3. Call unregisterVault for that vault as the owner and observe the revert.

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 vault is a contract that holds user money for a share token, and the owner can only have ten of them linked at once. To remove one, the code insists the vault holds nothing at all and has no leftover requests. Because anyone can send a tiny amount of tokens to a vault, or leave a tiny amount unclaimed, the check never passes and the vault can never be removed.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by dimulski

View all

7 more disclosed reports, best first.

More from SukukFi

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.