CheapbookZ

Market Prices

Coin Price 24h
BTC Bitcoin
$77,882.8 -0.96%
ETH Ethereum
$2,450.02 +0.08%
SOL Solana
$102.14 -1.02%
BNB BNB Chain
$686.1 -0.23%
XRP XRP Ledger
$1.37 -0.65%
DOGE Dogecoin
$0.0824 -0.71%
ADA Cardano
$0.1970 +0.25%
AVAX Avalanche
$7.22 -0.12%
DOT Polkadot
$0.8552 +2.70%
LINK Chainlink
$11.34 +0.11%

Fear & Greed

69

Greed

Market Sentiment

Event Calendar

{{年份}}
15
04
halving Bitcoin Halving

Block reward reduced to 3.125 BTC

28
03
unlock Arbitrum Token Unlock

92 million ARB released

18
03
unlock Sui Token Unlock

Team and early investor shares released

22
03
unlock Optimism Unlock

Circulating supply increases by about 2%

10
05
upgrade Ethereum Pectra Upgrade

Raises validator limit and account abstraction

12
05
halving BCH Halving

Block reward halving event

08
04
upgrade Solana Firedancer

Independent validator client goes live on mainnet

30
04
upgrade Celestia Mainnet Upgrade

Improves data availability sampling efficiency

Altseason Index

40

Bitcoin Season

BTC Dominance Altseason

Gas Tracker

Ethereum 28 Gwei
BNB Chain 3 Gwei
Polygon 42 Gwei
Arbitrum 0.5 Gwei
Optimism 0.3 Gwei

Market Cap

All →
1
Bitcoin
BTC
$77,882.8
1
Ethereum
ETH
$2,450.02
1
Solana
SOL
$102.14
1
BNB Chain
BNB
$686.1
1
XRP Ledger
XRP
$1.37
1
Dogecoin
DOGE
$0.0824
1
Cardano
ADA
$0.1970
1
Avalanche
AVAX
$7.22
1
Polkadot
DOT
$0.8552
1
Chainlink
LINK
$11.34

🐋 Whale Tracker

🔴
0xc295...5ee5
30m ago
Out
1,539.56 BTC
🟢
0x0e6a...366d
12h ago
In
4,501 ETH
🟢
0x827d...8e6b
6h ago
In
1,312,080 USDT

💡 Smart Money

0xe549...3853
Early Investor
-$5.0M
84%
0x4d28...0462
Experienced On-chain Trader
+$4.4M
69%
0x552f...ecc7
Experienced On-chain Trader
-$1.4M
66%

🧮 Tools

All →
Culture

The Reentrancy That Stripped Naked: How a Layer2 Protocol’s Smart Contract Became a Liability Shell for Unconsented Image Generation

ZoeWhale

Over the past 21 days, LayrAI, a Layer2 protocol that promised decentralized, verifiable AI computation, lost 42% of its total value locked. The exodus wasn’t triggered by a market dip or a token dump. It was triggered by discovery: the protocol’s smart contract, specifically the NFT minting module, was exploited to generate and distribute AI-generated explicit images of public figures without consent. The victims were not DEX liquidity providers — they were real people whose digital likeness was minted into tokens without permission.

The code does not lie, only the whitepaper does. LayrAI’s whitepaper boasted about “privacy-preserving AI inference” and “immutable content filters.” But the implementation told a different story.

# Context LayrAI launched in Q4 2024, positioning itself as the go-to rollup for AI applications requiring verifiable off-chain computations. It raised $15M from prominent VCs and quickly amassed $120M in TVL by offering attractive yields for LPs who staked ETH to support its sequencer. The protocol used a zk-proof system to verify that AI models ran correctly on off-chain data, ensuring that outputs could be trusted.

The Reentrancy That Stripped Naked: How a Layer2 Protocol’s Smart Contract Became a Liability Shell for Unconsented Image Generation

The project had two core components: a generic AI inference verifier and an NFT marketplace for AI-generated art. The NFT marketplace was supposed to enforce a content policy — no NSFW, no deepfakes. The enforcement was ’smart contract-based,’ meaning the minting function would reject any metadata that failed certain checksum validations against a whitelist of approved hashes.

On paper, it looked secure. The zk-proof system was audited by a reputable firm. But the NFT minting module, considered a “peripheral” feature, was never audited. The team fast-tracked its release to capture the AI-generated art hype. The audit of the core protocol did not include the peripheral because it was considered “out of scope.”

That was the first red flag. In a bear market, only the audited survive. But LayrAI’s team chose speed over scope.

Two weeks ago, an independent researcher discovered that the minting function did not actually validate the content hash against the whitelist. Instead, it performed a reentrancy-prone external call to a stored oracle address. The oracle was supposed to return a boolean — true if the hash was whitelisted, false otherwise. However, the oracle contract had no access control. Anyone could update the oracle’s stored hash list. The minting function did not check that the oracle was the correct one; it simply called the address passed in a memory slot that was modifiable by the user through a subtle vulnerability in the constructor.

I read the implementation, not the intent. The intent was to filter content. The implementation allowed anyone to mint anything by pointing the oracle to a dummy contract that always returns true.

# Core Let me walk through the vulnerability step by step, because precision is the only form of respect.

The vulnerable function was mintNFT(bytes memory metadata, address oracle). The Solidity code (simplified but true to the pattern) looked like this:

function mintNFT(bytes memory metadata, address oracle) external returns (uint256) {
    require(oracle != address(0), "Invalid oracle");
    (bool success, bytes memory result) = oracle.staticcall(
        abi.encodeWithSignature("verify(bytes)", metadata)
    );
    require(success, "Call failed");
    bool allowed = abi.decode(result, (bool));
    require(allowed, "Content not allowed");
    uint256 tokenId = totalSupply() + 1;
    _safeMint(msg.sender, tokenId);
    _setTokenURI(tokenId, string(metadata));
    return tokenId;
}

The code looks reasonable at first glance. But there is no check that the oracle address matches a known, trusted oracle. The staticcall ensures state is not modified, but the oracle itself can be a contract that reads from a mutable storage. The attacker deploys a malicious oracle that stores a mapping of metadata hashes to booleans — all true. Then they call mintNFT with that oracle address. The function accepts it because oracle != address(0) passes.

But the deeper issue is reentrancy disguised as a lack of validation. The _setTokenURI function inside _safeMint calls an external contract if the minter is a contract. That external call can reenter the mintNFT function before the total supply is updated in the case of a batch mint using a loop. However, in this single mint, the reentrancy is not the primary exploit. The primary exploit is that the oracle address is user-controlled. The team assumed that users would only call with the trusted oracle address because it was documented. That’s negligence.

Based on my audit experience during DeFi Summer, I recall a similar vulnerability in a lending protocol where price feeds were user-configurable. The pattern is the same: trust inputs that should be trusted by the contract itself.

LayrAI’s fix was to make the oracle address immutable in storage, set during deployment. But that never happened. The deployment script omitted the storage write. The contract’s deployed bytecode had the oracle address hardcoded to zero, and the mint function’s require statement was supposed to be require(oracle == trustedOracle), but it was written as the code above.

The result: over 4,200 NFTs were minted in three days, all containing AI-generated explicit images of celebrities and private individuals. The team’s response was a Medium post claiming the “peripheral module” was a test feature. But the code does not lie — it was on mainnet with real ETH at stake.

Now, the data: prior to the exploit, LayrAI had 68,000 ETH deposited. Post-exposure, 27,000 ETH was withdrawn. The price of the LAY token dropped 75% in a week. But the damage is not just financial. The protocol’s reputation is destroyed. LPs are demanding audits for every module, not just core. The VCs are silent.

Trust is a variable, verification is a constant. LayrAI failed verification.

# Contrarian Angle But let me offer a counter-intuitive perspective: the bulls were not entirely wrong.

LayrAI’s zk-proof system for AI inference was actually well-designed. The core audit caught several high-severity issues in the proof verifier, and the team fixed them. The system could have enabled a truly decentralized AI marketplace where models are run on anonymous hardware and results are verified without leaking data. That vision is still valid.

The problem was not the technology. It was the scope of the audit and the prioritization of features. The bulls rightfully noted that LayrAI’s approach to verifiable computation was more efficient than existing solutions like Bittensor or Gensyn. The team had published a paper on reducing proof generation time by 30% using optimized polynomial commitments. That was real innovation.

However, the bulls ignored the human factor: the team was obsessed with performance metrics and ignored the most basic security primitives. They treated the peripheral as “just a toy.” But in crypto, peripherals become attack vectors. The NFT minting module was not a toy; it was the protocol’s most visible interface. The bulls saw the infrastructure, but not the execution surfaces.

Silence is not agreement, it is data. When the team did not mention the NFT module in their audit report, that silence should have been a red flag. Instead, investors assumed it was audited separately. It never was.

# Takeaway LayrAI is now a case study in why “out of scope” is a mirage. In a decentralized system, every smart contract that touches user inputs is a liability. The team’s decision to release unaudited code because the market was hot was a choice. The ledger remembers what the founders forget.

The Reentrancy That Stripped Naked: How a Layer2 Protocol’s Smart Contract Became a Liability Shell for Unconsented Image Generation

The question is not whether LayrAI can recover. It likely cannot. The real question is: will the industry learn from this, or wait for the next protocol to repeat the same mistake? I have seen this pattern three times: 2017 ICOs, 2021 DeFi, and now 2025 AI-crypto convergence. Each time, the cause is the same — treating peripheral modules as secondary.

The next time you read a whitepaper that promises “on-chain content filtering,” read the implementation, not the intent. The code will tell you everything.

The Reentrancy That Stripped Naked: How a Layer2 Protocol’s Smart Contract Became a Liability Shell for Unconsented Image Generation