Skip to content
Business logic Audit finding Intermediate

Inactive skipped assets can be drained from the index

The minting logic excludes assets with the SKIPPED_ASSET_ROLE from deposit checks, but the burning logic only skips them when a separate blacklist flag is set. An attacker could repeatedly deposit and withdraw to drain any skipped asset held by the index without ever depositing it.

IllIllI Follow

Originally disclosed on Code4rena

Submitted by IllIllI

If an index has any inactive assets with the role SKIPPED_ASSET_ROLE, a user can repeatedly deposit and withdraw assets, always getting the skipped asset without having to deposit any

Proof of Concept

During minting, any asset that has the ‘skipped’ role is excluded from the checks of assets deposited: File: contracts/IndexLogic.sol (lines 60-70)

        for (uint i; i < inactiveAssets.length(); ++i) {
            if (!IAccessControl(registry).hasRole(SKIPPED_ASSET_ROLE, inactiveAssets.at(i))) {
                uint lastBalanceInAsset = IvToken(
                    IvTokenFactory(vTokenFactory).createOrReturnVTokenOf(inactiveAssets.at(i))
                ).lastAssetBalanceOf(address(this));
                lastAssetBalanceInBase += lastBalanceInAsset.mulDiv(
                    FixedPoint112.Q112,
                    oracle.refreshedAssetPerBaseInUQ(inactiveAssets.at(i))
                );
            }
        }

During burning, however, there’s a bug that only skips if there are ‘blacklisted’ assets: File: contracts/IndexLogic.sol (lines 125-140)

        for (uint i; i < length + inactiveAssets.length(); ++i) {
            address asset = i < length ? assets.at(i) : inactiveAssets.at(i - length);
            if (containsBlacklistedAssets && IAccessControl(registry).hasRole(SKIPPED_ASSET_ROLE, asset)) {
                continue;
            }

            IvToken vToken = IvToken(IvTokenFactory(vTokenFactory).vTokenOf(asset));
            uint indexAssetBalance = vToken.balanceOf(address(this));
            uint accountBalance = (value * indexAssetBalance) / totalSupply();
            if (accountBalance == 0) {
                continue;
            }

            // calculate index value in vault to be burned
            vToken.transfer(address(vToken), accountBalance);
            vToken.burn(_recipient);

This means that users will be passed back inactive skipped assets even if they never deposited any.

Recommended Mitigation Steps

I believe the && was meant to be a || in the SKIPPED_ASSET_ROLE in the code block directly above. Changing the code to be that way would be the fix.

olivermehr (Phuture Finance) disputed

jn-lp (Phuture Finance) commented:

That’s totally expected behavior. We want to get rid of the dust of skipped assets in our index.

moose-code (judge) commented:

Awarding the warden here since the documentation of the contest should’ve clearly mentioned that this is intentional behavior for skipped assets to be able to be drained. Well worth the warden bringing this up. This is well within the scope of the contest and it’s possible old assets may not be dust and contain material value.


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

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

Phuture is a protocol for index products: a basket of assets tracked by a smart contract, where users mint index tokens by depositing the underlying assets and burn them to withdraw their share. The code discussed here is in IndexLogic.sol, which implements the minting and burning logic and calls out to a registry that assigns roles to assets and a vToken factory that wraps each asset.

Two roles matter for this finding. An asset can be marked with SKIPPED_ASSET_ROLE, and the index also tracks a set of inactive assets. As the minting code shows, skipped assets are left out of the accounting when a user mints. The question the researcher asked was whether the same exclusion is applied consistently when a user burns.

Setup

The report describes no accounts, tooling or deployed environment. The analysis is a source-level review of the contracts at the commit referenced in the finding, with the relevant code quoted inline. The precondition for the issue is an index that holds at least one inactive asset carrying the SKIPPED_ASSET_ROLE.

Finding it

The researcher compared the two loops that handle inactive assets: one in the mint path and one in the burn path. In the mint path, every inactive asset is checked against the registry, and only assets that do not have the skipped role are included in the deposited-asset accounting. The code at contracts/IndexLogic.sol lines 60-70 is:

Solidity
        for (uint i; i < inactiveAssets.length(); ++i) {
            if (!IAccessControl(registry).hasRole(SKIPPED_ASSET_ROLE, inactiveAssets.at(i))) {
                uint lastBalanceInAsset = IvToken(
                    IvTokenFactory(vTokenFactory).createOrReturnVTokenOf(inactiveAssets.at(i))
                ).lastAssetBalanceOf(address(this));
                lastAssetBalanceInBase += lastBalanceInAsset.mulDiv(
                    FixedPoint112.Q112,
                    oracle.refreshedAssetPerBaseInUQ(inactiveAssets.at(i))
                );
            }
        }

The burn path at lines 125-140 iterates over both the active assets and the inactive assets, but the skip condition is different:

Solidity
        for (uint i; i < length + inactiveAssets.length(); ++i) {
            address asset = i < length ? assets.at(i) : inactiveAssets.at(i - length);
            if (containsBlacklistedAssets && IAccessControl(registry).hasRole(SKIPPED_ASSET_ROLE, asset)) {
                continue;
            }

            IvToken vToken = IvToken(IvTokenFactory(vTokenFactory).vTokenOf(asset));
            uint indexAssetBalance = vToken.balanceOf(address(this));
            uint accountBalance = (value * indexAssetBalance) / totalSupply();
            if (accountBalance == 0) {
                continue;
            }

            // calculate index value in vault to be burned
            vToken.transfer(address(vToken), accountBalance);
            vToken.burn(_recipient);

The skipped role is only honoured when containsBlacklistedAssets is true. In every other case, an inactive skipped asset is treated like any other asset and paid out to the burner. That asymmetry between mint and burn is what the researcher flagged.

Exploitation

Step 1: identify an index with an inactive skipped asset

The attacker needs an index whose inactive asset list contains an asset with SKIPPED_ASSET_ROLE. The report does not describe how such an index is created or how common it is; it simply assumes one exists.

Step 2: mint

Because the mint loop excludes skipped assets from the deposited-asset checks, the user can mint without depositing the skipped asset. The report does not include a concrete transaction or payload for this step; the claim follows from reading the mint loop above.

Step 3: burn

On burning, the loop walks the active assets and then the inactive assets. For the skipped inactive asset, containsBlacklistedAssets is false in the normal case, so the continue is not taken. The code computes accountBalance from the user's share of the vToken balance held by the index, transfers that amount into the vToken and burns it, paying the asset out to _recipient.

Step 4: repeat

By depositing and withdrawing repeatedly, the user keeps receiving the skipped asset without ever having deposited any of it. The report describes this as users being passed back inactive skipped assets they never deposited.

Root cause

The condition guarding the skip in the burn loop is a conjunction:

Solidity
            if (containsBlacklistedAssets && IAccessControl(registry).hasRole(SKIPPED_ASSET_ROLE, asset)) {

so the skipped role only takes effect when blacklisted assets are also present. The mint loop uses the role check on its own, so the two paths disagree about what a skipped asset is. The researcher's reading is that the && was meant to be ||, which would make the burn path skip any asset with the role regardless of containsBlacklistedAssets.

Impact

Under the condition above, a user can repeatedly deposit and withdraw and always receive the skipped asset without depositing it, draining that asset from the index. The report frames this as users being passed back inactive skipped assets they never deposited.

The project disputed the finding. Phuture Finance's position, in a comment by jn-lp, was that this is expected behaviour: they want to get rid of the dust of skipped assets in their index. The judge, moose-code, awarded the finding anyway, on the basis that the contest documentation should have clearly stated that draining skipped assets is intentional, and noted that old assets may not be dust and may contain material value. The severity recorded for the finding is medium.

Fix

The researcher's recommended mitigation is to change the && to || in the SKIPPED_ASSET_ROLE check in the burn loop, so that skipped assets are excluded from payouts on burning just as they are excluded from deposits on minting. The report does not record any code change being made; the project's response was that the behaviour is intentional.

Variants to test

  1. Compare every loop that iterates inactive assets across mint, burn and any other entry point, and check whether the role filter is applied identically in each. A positive result is a path where an asset excluded on the way in is included on the way out.
  2. Look for boolean conditions that combine a global flag with a per-asset role check, as containsBlacklistedAssets && hasRole(...) does here. A positive result is a state where the global flag is false and the per-asset exclusion silently stops applying.
  3. Check whether the same asymmetry exists for other roles or flags applied to assets, such as blacklists, pauses or deprecation markers, in the deposit and withdrawal directions.
  4. On indices with skipped assets, model the value of the skipped asset against the cost of a mint and burn cycle. A positive result is a cycle where the payout exceeds what was deposited.

Hunting notes

This kind of bug hides in paired code paths that are supposed to mirror each other: deposit and withdraw, mint and burn, add and remove. The signal during review is a filter or guard that appears in one path and appears in the other with an extra condition attached. Here the extra condition was a global boolean, which makes the divergence easy to miss at a glance and easy to trigger whenever that boolean is false.

The report itself contains no requests, responses or on-chain transactions, so the case rested on the code and on the economic argument that a user could repeatedly cycle deposits and withdrawals to extract the skipped asset. The judge accepted it because the documentation did not state that draining skipped assets was intended, and because old assets may not be dust and may contain material value. That is the lesson for reporting: when behaviour looks wrong but the project calls it intentional, the gap between the code and the documentation is what decides the outcome.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 11 min read.

What happened, in plain words

Phuture is a product that lets people buy into a "basket" of several crypto assets at once, the way an index fund bundles many shares. The basket is run by a smart contract, a program that lives on a blockchain and runs automatically. You put assets in and get index tokens back (this is called minting); you hand the index tokens back and get your share of the assets out (this is called burning).

The code that handles minting and the code that handles burning treat a certain kind of asset differently. Some assets inside the basket can be marked with a special label, SKIPPED_ASSET_ROLE, which means "ignore this one". When you mint, the code really does ignore it: you do not have to deposit any of it. When you burn, the code only ignores it under an extra condition that is normally false. So in the normal case you get paid out a share of that ignored asset even though you never put any of it in. Do that repeatedly and you keep receiving that asset without ever having deposited any of it.

The Phuture team said this was on purpose: they want to clear out leftover scraps ("dust") of skipped assets. The judge still accepted the finding, because the contest documentation should have said clearly that this draining is intended, and because old assets may not be dust and may contain material value. The finding was rated medium severity.

Background you need

A few ideas come up again and again below, so here they are from scratch.

  • Smart contract: a small program stored on a blockchain. Once deployed it runs the same way for everyone, and nobody can quietly change its behaviour. Think of a vending machine bolted to the pavement: the rules are inside it and everyone uses the same machine.
  • Protocol: a set of smart contracts that together provide a service. Phuture is a protocol for index products.
  • Index product: a basket of several assets treated as one thing. If you own a slice of the basket, you own a little of everything inside it. A fruit hamper is the everyday comparison: you buy a share of the hamper, not one specific apple.
  • Mint and burn: minting means creating new index tokens by paying assets into the basket. Burning means destroying index tokens to take your share of the assets back out. They are meant to be mirror images: what you put in on the way in, you get back on the way out.
  • Token: a digital unit tracked by a smart contract. Here there are two kinds: the underlying assets in the basket, and the index tokens that represent a share of the basket.
  • vToken: a wrapper contract around each underlying asset. The index does not hold the raw asset directly; it holds a vToken that represents it. The report does not explain further what the wrapper does beyond this.
  • Registry and roles: a registry is a contract that keeps a list of who or what is allowed to do what. A role is a named permission or label. SKIPPED_ASSET_ROLE is a label that can be attached to an asset, meaning "skip this asset".
  • Inactive assets: assets that are in the basket's records but are no longer actively traded as part of it. The report treats them as a separate list from the active assets.
  • Blacklisted assets: assets marked as blocked. The burn code has a flag called containsBlacklistedAssets that says whether any are present.
  • Loop: code that repeats the same steps over a list, one item at a time. Both the mint code and the burn code loop over the inactive assets.
  • && and ||: in most programming languages && means "and" (both sides must be true) and || means "or" (at least one side must be true). Swapping one for the other changes the logic completely.
  • Dust: a tiny leftover amount of an asset, too small to be worth much on its own.
  • Severity: how serious a finding is judged to be. Medium sits between low and high.

The setup

The report describes no accounts, no tools and no live deployment. The whole analysis is a read of the source code at a specific commit, with the relevant pieces quoted inline. The only precondition is that an index exists which holds at least one inactive asset carrying the SKIPPED_ASSET_ROLE label.

Finding it

The researcher put the two loops side by side: the one that runs when someone mints, and the one that runs when someone burns. Both deal with inactive assets, so they ought to agree.

In the mint path, every inactive asset is checked against the registry, and only assets that do not carry the skipped role are counted in the deposit accounting. The code at contracts/IndexLogic.sol lines 60-70 is:

Solidity
        for (uint i; i < inactiveAssets.length(); ++i) {
            if (!IAccessControl(registry).hasRole(SKIPPED_ASSET_ROLE, inactiveAssets.at(i))) {
                uint lastBalanceInAsset = IvToken(
                    IvTokenFactory(vTokenFactory).createOrReturnVTokenOf(inactiveAssets.at(i))
                ).lastAssetBalanceOf(address(this));
                lastAssetBalanceInBase += lastBalanceInAsset.mulDiv(
                    FixedPoint112.Q112,
                    oracle.refreshedAssetPerBaseInUQ(inactiveAssets.at(i))
                );
            }
        }

Line by line:

  1. for (uint i; i < inactiveAssets.length(); ++i) { starts a counter at zero and walks it up to the number of inactive assets, so the body runs once per inactive asset.
  2. if (!IAccessControl(registry).hasRole(SKIPPED_ASSET_ROLE, inactiveAssets.at(i))) { asks the registry whether the current asset has the skipped role, and the ! flips the answer. The body only runs when the asset does not have the role. This is the key line: skipped assets are left out here.
  3. uint lastBalanceInAsset = IvToken( begins reading the balance of the wrapper token for this asset, held by the index contract itself (address(this) means "this contract").
  4. IvTokenFactory(vTokenFactory).createOrReturnVTokenOf(inactiveAssets.at(i)) asks the factory for the wrapper token belonging to this asset, creating it if needed.
  5. ).lastAssetBalanceOf(address(this)); finishes that call and stores the resulting balance in lastBalanceInAsset.
  6. lastAssetBalanceInBase += lastBalanceInAsset.mulDiv( adds to a running total, converting the balance into a common base unit using a fixed-point division helper.
  7. FixedPoint112.Q112, is the scaling factor used for that conversion.
  8. oracle.refreshedAssetPerBaseInUQ(inactiveAssets.at(i)) asks an oracle (a contract that supplies price information) for the refreshed price of this asset relative to the base unit.
  9. The closing braces end the addition and the loop.

The burn path at lines 125-140 walks over both the active assets and the inactive assets, but the condition that decides whether to skip an asset is different:

Solidity
        for (uint i; i < length + inactiveAssets.length(); ++i) {
            address asset = i < length ? assets.at(i) : inactiveAssets.at(i - length);
            if (containsBlacklistedAssets && IAccessControl(registry).hasRole(SKIPPED_ASSET_ROLE, asset)) {
                continue;
            }

            IvToken vToken = IvToken(IvTokenFactory(vTokenFactory).vTokenOf(asset));
            uint indexAssetBalance = vToken.balanceOf(address(this));
            uint accountBalance = (value * indexAssetBalance) / totalSupply();
            if (accountBalance == 0) {
                continue;
            }

            // calculate index value in vault to be burned
            vToken.transfer(address(vToken), accountBalance);
            vToken.burn(_recipient);

Line by line:

  1. for (uint i; i < length + inactiveAssets.length(); ++i) { runs the loop once for every active asset plus every inactive asset, so the counter covers both lists in one pass.
  2. address asset = i < length ? assets.at(i) : inactiveAssets.at(i - length); picks the current asset: while the counter is below the number of active assets it reads from the active list, otherwise it reads from the inactive list, subtracting the active count to get the right position.
  3. if (containsBlacklistedAssets && IAccessControl(registry).hasRole(SKIPPED_ASSET_ROLE, asset)) { is the skip check. It only skips when both things are true: the index contains blacklisted assets, and this asset has the skipped role. If there are no blacklisted assets, the second half is never even consulted.
  4. continue; jumps to the next asset without paying anything out.
  5. IvToken vToken = IvToken(IvTokenFactory(vTokenFactory).vTokenOf(asset)); looks up the wrapper token for this asset.
  6. uint indexAssetBalance = vToken.balanceOf(address(this)); reads how much of that wrapper the index contract holds.
  7. uint accountBalance = (value * indexAssetBalance) / totalSupply(); works out the user's share: the amount being burned (value) times the index's balance, divided by the total supply of index tokens. This is the standard way to give someone their proportional slice.
  8. if (accountBalance == 0) { continue; } skips assets where the share rounds down to nothing.
  9. // calculate index value in vault to be burned is a comment describing the next two lines.
  10. vToken.transfer(address(vToken), accountBalance); moves the user's share of the wrapper token into the wrapper contract itself.
  11. vToken.burn(_recipient); destroys that amount and pays the underlying asset out to the recipient.

The skipped role is only honoured when containsBlacklistedAssets is true. In every other case, an inactive skipped asset is treated like any other asset and paid out to whoever is burning. That mismatch between mint and burn is the finding.

Exploitation

Step 1: identify an index with an inactive skipped asset

The attacker needs an index whose list of inactive assets contains one carrying SKIPPED_ASSET_ROLE. The report does not describe how such an index comes to exist or how common it is; it simply assumes one does.

Step 2: mint

Because the mint loop leaves skipped assets out of the deposit checks, the user can mint without depositing the skipped asset at all. The report gives no concrete transaction or payload for this step; the claim follows directly from reading the mint loop above.

Step 3: burn

On burning, the loop walks the active assets and then the inactive ones. For the skipped inactive asset, containsBlacklistedAssets is false in the normal case, so the continue is not reached. The code works out accountBalance from the user's share of the wrapper balance held by the index, transfers that amount into the wrapper and burns it, paying the asset out to _recipient.

Step 4: repeat

By depositing and withdrawing over and over, the user keeps receiving the skipped asset without ever having deposited any of it. The report describes this as draining the skipped asset from the index.

Root cause

The condition guarding the skip in the burn loop is an "and":

Solidity
            if (containsBlacklistedAssets && IAccessControl(registry).hasRole(SKIPPED_ASSET_ROLE, asset)) {

So the skipped role only takes effect when blacklisted assets are also present. The mint loop uses the role check on its own, with no extra condition, so the two paths disagree about what a skipped asset means. The researcher's reading is that the && was meant to be ||, which would make the burn path skip any asset with the role regardless of containsBlacklistedAssets.

Impact

Under the condition above, a user can repeatedly deposit and withdraw and always receive the skipped asset without depositing it, draining that asset from the index. The report frames this as users being handed back inactive skipped assets they never put in.

The project disputed the finding. Phuture Finance's position, in a comment by jn-lp, was that this is expected behaviour: they want to get rid of the dust of skipped assets in their index. The judge, moose-code, awarded the finding anyway, on the basis that the contest documentation should have clearly stated that draining skipped assets is intentional, and noted that old assets may not be dust and may contain material value. The severity recorded for the finding is medium.

Fix

The researcher's recommended mitigation is to change the && to || in the SKIPPED_ASSET_ROLE check in the burn loop, so that skipped assets are excluded from payouts on burning just as they are excluded from deposits on minting. The report does not record any code change being made; the project's response was that the behaviour is intentional.

Variants to test

  1. Compare every loop that iterates inactive assets across mint, burn and any other entry point, and check whether the role filter is applied identically in each. A positive result is a path where an asset excluded on the way in is included on the way out.
  2. Look for boolean conditions that combine a global flag with a per-asset role check, as containsBlacklistedAssets && hasRole(...) does here. A positive result is a state where the global flag is false and the per-asset exclusion silently stops applying.
  3. Check whether the same asymmetry exists for other roles or flags applied to assets, such as blacklists, pauses or deprecation markers, in the deposit and withdrawal directions.
  4. On indices with skipped assets, model the value of the skipped asset against the cost of a mint and burn cycle. A positive result is a cycle where the payout exceeds what was deposited.

Hunting notes

This kind of bug hides in paired code paths that are supposed to mirror each other: deposit and withdraw, mint and burn, add and remove. The signal during review is a filter or guard that appears in one path and appears in the other with an extra condition attached. Here the extra condition was a global boolean, which makes the divergence easy to miss at a glance and easy to trigger whenever that boolean is false.

The report itself contains no requests, responses or on-chain transactions, so the case rested on the code and on the economic argument that a user could repeatedly cycle deposits and withdrawals to extract the skipped asset. The judge accepted it because the documentation did not state that draining skipped assets was intended, and because old assets may not be dust and may contain material value. That is the lesson for reporting: when behaviour looks wrong but the project calls it intentional, the gap between the code and the documentation is what decides the outcome.

Glossary

  • Smart contract: a program stored on a blockchain that runs the same way for everyone and cannot be quietly changed after deployment.
  • Index product: a basket of several assets treated as a single thing, so owning a slice means owning a little of everything inside.
  • Mint: create new index tokens by paying assets into the basket.
  • Burn: destroy index tokens to take your share of the basket's assets back out.
  • vToken: a wrapper contract that represents an underlying asset inside the index.
  • Registry: a contract that keeps track of roles and permissions.
  • Role: a named label or permission that can be attached to an address or an asset.
  • SKIPPED_ASSET_ROLE: the role that marks an asset as one to be skipped.
  • Inactive asset: an asset still recorded in the basket but no longer actively traded as part of it.
  • Blacklisted asset: an asset marked as blocked; containsBlacklistedAssets is the flag saying whether any are present.
  • &&: logical "and"; both sides must be true.
  • ||: logical "or"; at least one side must be true.
  • continue: a keyword that jumps straight to the next round of a loop, skipping the rest of the body.
  • Oracle: a contract that supplies outside information, such as asset prices, to other contracts.
  • Fixed-point: a way of representing fractions in whole numbers by scaling them up by a fixed factor.
  • Severity: how serious a finding is judged to be; medium sits between low and high.
  • Judge: the person who decides whether a contest finding is valid and what it is worth.

More by IllIllI

View all

119 more disclosed reports, best first.

More from Phuture

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.