Skip to content
NFTVenue Ledger
Directory

Erc721 Erc1155 Eip712 Permit Security

ERC-1155 Batch Transfer Security: Mandatory Receiver Hooks, Array Mismatches & Gas-Bomb DoS

Unlike ERC-721, EIP-1155 omits non-callback transfers entirely—making mandatory onERC1155Received and onERC1155BatchReceived hooks prime vectors for return-bomb and batch-sweep DoS.

By Dr. Devon Kurosawa, PhDReview not recorded · Updated
ERC-1155 Batch Transfer Security: Mandatory Receiver Hooks, Array Mismatches & Gas-Bomb DoS — NFTVenue Ledger 2026 quantitative & supervisory data card
NFTVenue Ledger (EIP-712 Signatures, Permit2 Allowance Security, Royalties & Proxy Timelocks): Sequential duplicate-ID balance safety, 0xbc197c81 hooks, and Yul Return-Bomb shields.Source: NFTVenue Ledger Institutional Research DeskLicense: CC-BY-4.0

Gaming inventories, fractionalized RWA tranches, and open-edition art collections across our marketplaces directory—such as Basepaint, Avarik Saga, Art Blocks X Bright Moments, and Async Blueprints—overwhelmingly prefer EIP-1155 Multi-Token Contracts because transferring 50 distinct items in one safeBatchTransferFrom(from, to, ids, values, data) call saves up to 80% gas over 50 separate ERC-721 transfers.

Yet as detailed in our EIP-712, Permit2 & proxy security master guide, EIP-1155 contains two architectural surprises that repeatedly break NFT aggregators, lending liquidators, and custom token implementations: (1) EIP-1155 has NO transferFrom without callbacks—every single transfer triggers 0xf23a6e61 or 0xbc197c81 on contract recipients, and (2) custom safeBatchTransferFrom loops frequently introduce fatal Duplicate-ID Balance Overwrite Bugs!

Fatal Bug #1: Caching Balances Across Duplicate ids in safeBatchTransferFrom!#

Watch how custom gas-optimized ERC-1155 implementations get drained for infinite tokens in 1 transaction when developers rewrite OpenZeppelin's safeBatchTransferFrom loop carelessly:

  • Suppose an attacker calls safeBatchTransferFrom(attacker, attacker, [42, 42], [100, 100], "") passing the exact same id = 42 twice inside ids!
  • If a developer reads uint256 fromBal_i = _balances[42][from]; uint256 toBal_i = _balances[42][to]; into memory arrays before the update loop (or caches toBal when from == to!), iteration 1 writes _balances[42] = 100, and iteration 2 adds +100 onto stale toBal_i (or skips subtracting twice)—doubling the attacker's token balance out of thin air on every call!
  • Mandatory Audit Invariant: Inside every for (uint256 i = 0; i < ids.length; ++i) iteration, read and write storage _balances[id][from] -= value and _balances[id][to] += value sequentially per element, never caching across array indices, and strictly assert ids.length == values.length!
ERC-1155 safeBatchTransferFrom CEI execution, memory return-bomb defense, and aggregator try-catch isolation
ERC-1155 safeBatchTransferFrom CEI execution, memory return-bomb defense, and aggregator try-catch isolationVerified Exhibit

Fatal Bug #2: Floor-Sweeper & Liquidation DoS (Gas Bomb + Return Bomb)#

Because EIP-1155 provides zero non-callback transfer function, what happens when a borrower locks an ERC-1155 asset inside a lending protocol (or lists the cheapest item on the floor against a 20-item aggregator sweep on Seaport) via a smart-contract address whose onERC1155Received executes invalid or returns 2,000,000 bytes of junk memory (Return-Data Bomb)?

  1. 63/64 Gas Griefing: High-level Solidity to.onERC1155Received(...) forwards 63/64 of the transaction's entire remaining gas (EIP-150). If a marketplace aggregator wraps 20 floor items inside try seaport.fulfillOrder(...) {} catch {} without capping forwarded gas, 1 malicious seller's contract burns 98.4% of gasleft, causing the outer aggregator transaction to run out of gas and revert all 19 honest sales!
  2. Quadratic Memory Expansion ("Return Bomb"): Even if you cap call{gas: 100_000}(...), high-level Solidity try ... catch (bytes memory reason) automatically executes RETURNDATACOPY on the entire returned payload! An attacker uses 100k gas inside the subcall to return a massive byte buffer that triggers quadratic memory expansion gas in the parent contract, blowing through the caller's remaining gas!

ERC-721 vs ERC-1155 Security & Marketplace Settlement Matrix#

Quantitative Distribution · ERC-1155 Multi-Token Standard
ERC-1155 Multi-Token Standard
01Non-Callback Fallback Trans…NO! Every trans…02Duplicate Token IDs in BatchAllowed (ids = …03Floor-Sweep Aggregator Pois…Seller ETH + Bu…
Security / Settlement PropertyERC-721 Single-Asset StandardERC-1155 Multi-Token StandardMandatory Marketplace / Vault Fix
Non-Callback Fallback Transfer?Yes (transferFrom skips hook)NO! Every transfer calls 0xf23a6e61 / 0xbc197c81Liquidations seize to Liquidator, never push to Borrower!
Duplicate Token IDs in BatchImpossible (1 tokenId per call)Allowed (ids = [7, 7])Never cache _balances in memory prior to loop!
Floor-Sweep Aggregator PoisoningSeller ETH receive gas/return bombSeller ETH + Buyer/Seller 1155 hook bombsLow-level Yul call(capGas, ...) with 0 returndata copy!
Partial-Fill Order SupportIndivisible (amount == 1)Native fungible values (Seaport PARTIAL)Enforce exact fraction divisibility (Seaport math)
Gas cost of transferring 25 NFTs across ERC-721 loop, ERC-1155 safeBatchTransferFrom, and Return-Bomb safe call
Gas cost of transferring 25 NFTs across ERC-721 loop, ERC-1155 safeBatchTransferFrom, and Return-Bomb safe callVerified Exhibit

Quadratic EVM Memory Expansion ("Return Bomb") Cost Formula & Assembly Shield#

Why does copying M = 65,536 bytes (2,048 32-byte words) of malicious returndata destroy a parent contract's gas budget? Because EVM memory cost scales quadratically as floor(words^2 / 512) + 3 * words:

Formula or model from the articleNot independently verified
1) EVM Quadratic Memory Expansion Cost (Exploited by Return-Data Bombs):
  • Memory_Gas(W words) = 3 * W + floor( W^2 / 512 )
  • Example: Child subcall uses MSTORE8 at offset 131,072 (W = 4,096 words = 128 KB) & RETURN(0, 131072):
  • If parent executes high-level Solidity try/catch (auto-copies full 128 KB into parent memory):
  • ParentCopyCost = 3*(4,096) + (4,096^2 / 512) + CopyWordsCost = 12,288 + 32,768 + 12,288 = 57,344+ unexpected gas!
  • At 512 KB (W = 16,384): ParentCopyCost = 573,440 gas -> Instant Out-Of-Gas parent revert!
  • 2) Bomb-Proof Inline Yul ERC-1155 Hook Verification:
  • let success := call(hookGasCap, to, 0, ptr, calldataLen, 0x00, 0x20) // Pre-caps output write to EXACTLY 32 bytes at 0x00!
  • let magicOk := and(success, and(gt(returndatasize, 0x1f), eq(mload(0x00), shl(224, 0xbc197c81))))
  • // Zero RETURNDATACOPY of arbitrary buffers -> Return-Bomb cost = 0 gas!

Auditing Immutable vs Secretly Mutable Bytecode Next#

Even when an ERC-1155 or marketplace Conduit appears to have zero proxy admin on Etherscan, can a malicious deployer wipe its bytecode and redeploy a drainer at the exact same Ethereum address? Examine CREATE2 + SELFDESTRUCT traps next in CREATE2 metamorphic redeployment detection and ERC-721 callback reentrancy inside our EIP-712, Permit2 & Proxy Security hub.

Frequently asked questions

How does the duplicate-ID balance inflation bug happen in custom ERC-1155 contracts?

If a developer reads sender and receiver balances into memory arrays before the transfer loop, submitting safeBatchTransferFrom(me, me, [1, 1], [100, 100]) overwrites the updated balance with stale cached math and mints free tokens.

Why can a borrower freeze an ERC-1155 liquidation if the vault pushes collateral back?

Because ERC-1155 lacks a non-callback transferFrom, pushing excess ERC-1155 tokens back to a borrower contract lets the borrower revert inside onERC1155Received; vaults must hold surpluses in pull-claim escrows.

What is a Return-Data Bomb in NFT marketplace aggregators?

When an aggregator wraps external fills in Solidity try/catch (bytes memory reason), Solidity copies the entire revert buffer into memory; returning 256 KB–512 KB triggers quadratic memory gas costs that crash the entire sweep.

How does EIP-1155 enforce Checks-Effects-Interactions inside the standard itself?

The EIP-1155 specification explicitly mandates updating state balances and emitting TransferSingle/TransferBatch events BEFORE calling onERC1155Received or onERC1155BatchReceived.

Publication record

Published
November 13, 2026
Updated
November 14, 2026
Author
Dr. Devon Kurosawa, PhD
Review
Review not recorded
Automated fact check
Passed in the stored pipeline record
Source URLs
3 recorded

AI assistance recorded: anthropic/claude-opus-4.6. This field does not establish human review or source verification.

Academic & Institutional Attribution

Cite This Research & Embed Live Data Card

Open Attribution License (CC BY 4.0)

Standard academic & institutional research paper citation format.

Dr. Devon Kurosawa, PhD. (2026, November 14). ERC-1155 Batch Transfer Security: Mandatory Receiver Hooks, Array Mismatches & Gas-Bomb DoS. NFTVenue Ledger. https://nftvenueledger.com/protocols/erc1155-batch-transfer-hook-gas-stipend-dos-marketplace

Regulatory Directory Cross-Reference

Referenced Institutions & Regulatory Registries

Primary Tier-1 Supervisory Registries

Explore Erc721 Erc1155 Eip712 Permit Security Hub (20) →

NFTVenue Ledger Data, Benchmarks & Contributor Records

ERC-1155 Batch Transfer Security: Hooks & Gas-Bomb DoS | NFTVenue Ledger