DeFi Security AllianceRequest an audit
Menu

EVM patterns

Solidity Multicall: When Reserves Hide Repeated Native Credit

A payable batch can credit one native payment repeatedly when delegated operations read the same message value. Solidity multicall security needs a payment allocation invariant because an existing reserve can conceal excess credit.

One blue token enters a counting gate while three translucent token images appear beside a reserve of gray tokens.

Key facts

Original execution
64 local EVM cases across 2 routes, 4 batch lengths, 4 payments and 2 reserves
Unsafe delegated fixture
12 of 32 rows created credit above the incoming payment
Reserve masking
6 of those 12 excess credits remained covered by the pool balance
Checked amount budget
14 of 32 calls succeeded, 18 reverted, no excess credit observed
Evidence limit
Own fixtures only. No withdrawal, realized loss or deployed-library vulnerability measured

Account for the payment before judging the balance

Six deliberately incorrect credits still fitted inside the contract's available ETH balance. That was the result that changed the interpretation of our local experiment. A balance check could accept those states even though the latest caller had received more application credit than its payment funded. The extra reserve did not correct the ledger. It made the discrepancy less visible.

Solidity multicall groups contract operations behind one entrypoint. The security question depends on how that entrypoint executes each operation. A self delegatecall runs another function against the same contract state while preserving the calling context. In particular, msg.value remains the value of the containing message. Repeating a delegated function does not divide that value among iterations.

The Solidity delegatecall documentation also preserves msg.sender, the current address and the calling contract's balance. The unchanged message value is not a second transfer. An application that adds it to a credit mapping on each iteration can therefore create several claims from one receipt of native currency.

The inspected Uniswap IMulticall interface explicitly warns against trusting msg.value in methods callable through multicall. That warning identifies an integration assumption. It does not establish that every payable batch is defective, or that a particular deployed router permits an attacker to withdraw unearned funds.

Use two different accounting questions. Did the accepted action receive enough funding for the credit it created? Can the contract currently cover all recorded claims? A reserve can make the second answer positive while the first remains wrong. Native-value accounting needs the first question even when a separate solvency check is also required.

What 64 local EVM cases revealed

Method

DeFiSec executed the full fixture population on . Every row deployed a fresh contract and reset the actor's funds. The test compares an intentionally unsafe delegated batch with an explicit amount-budget route. Each fresh fixture exposes both entrypoints, and a row invokes only one. The comparison evaluates those routes, not the security of the whole contract. The intentionally unsafe entrypoint makes this test contract unsuitable for deployment.

Population
64 cases: 2 routes, 4 batch lengths, 4 incoming values and 2 initial reserves. Each route has 32 cases. No exclusions.
Batch lengths
0, 1, 2 or 3 requested deposit operations. Every unsafe operation delegates to the same payable deposit function.
Payment and reserve
The incoming payment is 0, 1, 7 or 40 wei. The initial uncredited reserve is 0 or 100 wei. The actor starts each row with 1000 wei.
Requested allocations
For the checked route, every requested leg amount equals the full incoming payment. Repeated positive amounts deliberately exceed the budget. Valid divided allocations are not part of this population.
Execution
Solidity 0.8.36, Forge 1.5.1, Cancun, optimizer enabled and compilation through the intermediate representation. The local balance cheatcode supplies the initial reserve without a funding transaction.
Observed fields
Call success, pool balance, actor credit, actor balance and any credit assigned to the pool's own address.

The repository retains seo/research/payable-multicall-security-2026-11-18/MulticallMatrix.t.sol, measurement.py and measurement.json. These paths identify research files rather than public downloads. A second execution reproduced every row. Independent assertions also checked the expected branches and conservation of wei across actor and pool. The retained ledger records the actor's remaining native balance rather than inferring its funding from a successful credit counter.

Results

Complete local population, observed . Counts describe fixture rows, not deployed protocols.
RouteCasesSucceededRevertedExcess creditCredit above pool balanceExcess credit masked by reserve
Unsafe self delegatecall323201266
Checked explicit budget321418000

Excess credit means a successful row assigned more actor credit than the actor paid. A balance shortfall means that credit exceeded the entire pool balance. These classifications differ in 6 unsafe rows: an initial reserve covered the inflated claim. The comparison deliberately keeps those rows visible instead of calling every balance-covered outcome correct.

Selected rows from the same grid. All amounts are wei. Failed calls leave initial funds and zero credit unchanged.
RouteLegsPaymentReserveOutcomePool balanceActor credit
Unsafe270Succeeded714
Unsafe27100Succeeded10714
Unsafe070Succeeded70
Checked27100Reverted1000
Checked17100Succeeded1077
Checked30100Succeeded1000

The unsafe route also accepted 6 empty batches with positive payments. They increased its balance without creating credit. The checked route rejected those unallocated payments as well as the 12 positive repeated allocations that exceeded the budget. Its other 14 rows succeeded. Across both routes, 46 calls succeeded and 18 reverted.

The single-leg positive controls matter as much as the repeated calls. With the same positive payment, both routes created the intended payment-sized claim when only one deposit was requested. The failure therefore appears when composition repeats a payment-sensitive operation, rather than when an ordinary deposit is used alone. A review containing only direct deposits would miss that distinction.

Zero-value calls provide a different control. Repeated reads of zero do not create a positive discrepancy, so a passing zero-value batch says little about native funding. The checked route accepted its zero-value rows, including empty input. That result supports the stated boundary but does not generalize to an arbitrary positive allocation. Record the actual input amounts beside a successful test.

Limits

  • No withdrawal function exists. An incorrect credit is not a measured theft or realized loss.
  • The reserve is uncredited local test funding. It is not a model of every depositor's liabilities, fees or reserves in a live protocol.
  • No public chain, fork, gas benchmark, recursive batch, reentrancy or allowed-failure aggregator was executed.
  • OpenZeppelin, Uniswap and Multicall3 were inspected as references. Their implementations were not run in this experiment.

Spend the batch budget once

The unsafe fixture's deposit function performs credit[msg.sender] += msg.value. Its batch entrypoint delegates to that function for every encoded operation. Because the message context survives each delegation, the same actor receives the same payment-sized credit repeatedly. The pool receives only the outer payment.

The checked fixture instead reads the payment as an initial budget. Each explicit allocation must fit the remaining amount, which is reduced before credit is added. At completion the remaining amount must be zero. There is no delegated deposit in that route. This changes the accounting API rather than attempting to reset msg.value, which is message information rather than an application counter.

The checked fixture consumes explicit allocations and rejects any unallocated remainder. This excerpt omits the surrounding contract and test harness.
uint256 remaining = msg.value;
for (uint256 i; i < amounts.length; ++i) {
    require(amounts[i] <= remaining, "budget");
    remaining -= amounts[i];
    credit[msg.sender] += amounts[i];
}
require(remaining == 0, "unallocated");

A rejection after an earlier credit write still reverted the whole checked application call. Its selected two-leg case first credited the actor, then rejected the second allocation. The final observed credit was zero and the positive incoming payment returned to the actor. Solidity's exception semantics support that rollback within the call and its subcalls. The fixture does not catch its budget errors.

A reserve can cover an incorrectly created claim An incoming payment of seven wei joins a reserve of one hundred wei, producing a pool balance of one hundred seven. Two delegated deposits each read the same seven wei payment and assign fourteen wei of credit. The balance covers that credit while payment attribution is still wrong. Payment received7 wei Uncredited reserve100 wei Pool assets: 107 weiBalance covers the recorded claim Two delegated credit operations7 + 7 = 14 wei of actor creditFunding attribution fails
Asset coverage and funding attribution can disagree in the same completed call.
  1. Identify the new payment independently from assets already present in the pool.
  2. Compare the credit created by the complete batch with its permitted funding allocation. Repeated reads of message value do not create additional receipts.
  3. Check aggregate liabilities separately. An available reserve can conceal the first failure while temporarily covering its financial consequence.

The reserve classification also has a deliberately narrow denominator. Our reserve carried no other recorded liabilities, so the actor's claim could be compared directly with the available balance. A live pool may owe that reserve to other users. Comparing only the latest actor's credit with the pool balance would then be an incomplete solvency test as well as an incomplete funding test. The correct liability population belongs in the product's accounting specification.

For this deposit-only fixture, successful allocated credit should equal the accepted incoming payment. A real router that transfers value onward or charges a fee needs a different conservation equation with named destinations. Do not copy the fixture's equality into a product whose documented behavior includes a refund or donation. Define that behavior first and include every resulting balance change.

Choose the actual batching implementation

The word multicall does not specify an execution model. Compare deployed code and the callable functions before borrowing a mitigation. The Solidity address-call documentation makes the explicit value option available on call, not delegatecall. Switching between them also changes the authorization context.

Source-inspected batching boundaries on . These implementations are references, not executed rows.
PatternRelevant boundaryReview consequence
Self delegatecallMessage value and sender remain in the existing contextInspect every reachable function that credits, refunds or spends based on message value
External CALLA distinct message has an explicit value and a new immediate callerAllocate each payment and authenticate the actor expected at the target
OpenZeppelin 5.4.0 MulticallThe inspected entrypoint is nonpayable and delegates to itselfDo not describe it as the custom payable fixture or assume an override preserves its boundary
Multicall3 aggregate3ValueThe inspected code accumulates requested values and compares their sum with the incoming paymentRead target success handling and retained-value behavior alongside the sum check
STATICCALLState modification is prohibitedA read aggregation is a different operation from a payable deposit batch

The pinned OpenZeppelin module does not declare its multicall entrypoint payable. That restriction prevents a positive payment entering through that entrypoint. It is not evidence that arbitrary custom inheritance or overrides are safe. Inspect the resulting contract ABI and every native-value route after composition.

Multicall3's source uses call{value: val} for requested legs and requires msg.value == valAccumulator. The equality concerns requested values. A request configured to allow failure can fail at its target while the aggregate transaction continues. Requested allocation and value successfully delivered are different quantities.

A caller using an external aggregator also changes what a downstream application sees as its immediate sender. Replacing self delegation with an external self-call has the same identity question: the contract becomes the caller. An application that credits raw msg.sender can credit the wrong account even after a payment-duplication issue disappears. The intended actor must remain authenticated, rather than becoming another untrusted address parameter.

Separate payment budgets from other trust boundaries

Unused ETH needs an explicit owner. The unsafe empty batch accepted funds without assigning credit. The checked fixture rejected that state. Other products may deliberately support a refund, but they must specify the recipient, the amount and the failure policy. A refund path can introduce an external call and must be included in the reentrancy review.

Allowed-failure aggregation needs an additional reconciliation step. In the inspected aggregate3Value code, a failed permitted target call does not receive its requested value. The source still includes that requested value in the accumulator. Do not infer that a successful aggregate call paid every target or refunded every failed allocation. Inspect actual return data and the implementation's retained balances.

Nested batches can restart a poorly designed application counter. A per-invocation budget is insufficient if a recursively reachable operation obtains another full allowance from the same message value. Reentrant entry can create a related accounting problem. These are proposed negative controls, not scenarios executed in our grid. A shared transient-storage budget would need its own caller, nesting and lifecycle tests. The transient storage analysis addresses that storage lifetime separately.

Sender forwarding is another independent boundary. A trusted forwarder may change the application's effective sender without changing the transaction's native-payment semantics. Review that trust and nested context through the ERC2771 forwarder guide. Preserving one kind of context does not prove correct payment attribution or correct resolution of another.

Require evidence at the shipped revision

A detector warning is a review lead. Crytic documents separate delegatecall-loop and msg-value-loop checks. Read the reachable payment operations before deciding what the syntactic pattern means. This research did not run Slither, and a green scan would not replace the complete application invariant.

  1. Pin the entrypoint implementation, compiler and chain context. Identify overridden functions as well as the inherited module.
  2. Record every operation that can create credit or move native value, including paths reachable only from encoded inner calls. Name the account whose funds and claims each operation changes.
  3. Test direct calls and complete batches with repeated payment-sensitive operations. Include an empty batch and zero-value controls, then add a reserve so a solvency check cannot hide incorrect attribution.
  4. Check both success and failure state. A rejected allocation must not leave earlier credit behind when the design promises atomicity.
  5. Exercise nested batches, refund failures and supported caller contexts in separate implementation-specific tests. Our grid does not establish those boundaries.
  6. Repeat the checks after an upgrade changes a reachable function or its payable behavior. Keep the exact source revision beside the output rather than treating a past review as evidence for new code.

Capture state at the transaction boundary that the product promises. An inner allocation may execute successfully before a later check rejects the enclosing operation. Reading only a trace of that intermediate write can misclassify the final ledger. Conversely, a product that deliberately allows individual target failures cannot inherit an atomic rollback promise from the word batch. Compare the final credited actor, native balances and returned failure indicators with the documented policy.

Batch length also belongs in acceptance testing. Our largest length was 3, which establishes no production gas limit or safe maximum. A product accepting a larger input array needs measured operational limits for its actual paths. Avoid changing an accounting fix into an unsupported claim about throughput.

For an external assessment, give the reviewer the funding equation, permitted failure behavior and complete state ledger. The Pharos Production member profile is a provider reference. The security tools hub supplies supporting checks, while the protocol invariants guide helps express the required property. Neither a provider name nor a detector result supplies missing execution evidence.

The decisive comparison in this population was an incorrect credit that a reserve could cover. If later code allocates native value differently, rerun the attribution check with that behavior represented. The criterion is the permitted relationship between received funds and created claims at the shipped revision.

Frequently asked questions

Does an eth_call simulation persist an inflated application credit?

No. The Ethereum JSON-RPC documentation defines eth_call as message execution without creating an on-chain transaction. Simulated state changes are not committed to that chain. That does not make the same application logic correct in a state-changing transaction. Match the simulation context to the intended submission and inspect the resulting state, not only the returned success flag.

Should users approve Multicall3 to spend their ERC20 tokens?

The project documentation explicitly warns against approving Multicall3 to spend tokens. That external shared aggregator is distinct from an application-owned batching contract. Review approvals against the actual spender and its authorization model. An instruction intended for a private application entrypoint must not be transferred to a permissionless aggregator.

Can a selector allowlist check only the outer multicall function?

No. The inspected OpenZeppelin module warns that a relay filtering function selectors does not thereby filter calls nested inside multicall. The policy must account for the actual reachable inner operations. Decoding and testing nested requests is a separate authorization review, not a payment-budget guarantee. The local experiment did not execute a selector-filtering relay.

Comments

0

    Leave a comment

    Share a question or observation about this article.

    10 to 3,000 characters.