Skip to content
Smart contracts Audit finding Intermediate

Leak of value when interacting with an ERC721 enforcer contract

The enforcer contract's receive() function does not forward calls to the underlying implementation, so any value sent with empty calldata is trapped and treated as royalties rather than reaching custom logic. An attacker could send value expecting a custom payable action, but the funds are instead diverted to payout addresses.

Trust Follow

Originally disclosed on Code4rena

Submitted by Trust

HolographERC721.sol#L962

HolographERC721.sol is an enforcer of the ERC721 standard. In its fallback function, it calls the actual implementation in order to handle additional logic.

If Holographer is called with no calldata and some msg.value, the call will reach the receive() function, which does not forward the call down to the implementation.

This can be a serious value leak issue, because the underlying implementation may have valid behavior for handling sending of value. For example, it can mint the next available tokenID and credit it to the user. Since this logic is never reached, the entire msg.value is just leaked.

Impact

Leak of value when interacting with an NFT using the receive() or fallback() callback. Note that if NFT implements fallback OR receive() function, execution will never reach either of them from the enforcer’s receive() function.

Recommended Mitigation Steps

Funnel receive() empty calls down to the implementation.

alexanderattar (Holograph) commented:

Receive function will need to be updated to pass value down like the fallback function

Trust (warden) commented:

Upon further thoughts, believe it may qualify as high severity because it is a leak of value without requiring user error.

ACC01ADE (Holograph) commented:

This is intended behavior, mgs.value is never leaked directly to custom implementations. For ERC721 there is a direct and secure method of withdrawing that value via the PA1D contract logic.

Trust (warden) commented:

Yeah, but the withdrawal in PA1D will split the money between payout addresses. If developer implemented an ERC721 with receive() fallback, this call would be intended for that logic but instead the money is now treated as royalties to payout.

ACC01ADE (Holograph) commented:

Developer can implement custom payable functions that guarantee msg.value transfer to their custom implementation. Receive function is reserved for royalty payouts that directly send funds to contract address. Plus it’s expected to be limited to 21k gas units, so there is no real use case where any logic can be accomplished with that much gas.

ACC01ADE (Holograph) commented:

That being said, this is a valid issue and sponsor confirms it. There is no clearly communicated code/documentation that explains this limitation to developers. Will make an attempt at mitigating this potential issue from happening on custom implementation side by providing clearer language and also adding revert functionality in the receive functions to get the attention of developers that might have missed this.

ACC01ADE (Holograph) linked a PR:

Feature/HOLO-605: C4 medium risk fixes


The original report as published on Code4rena, by Trust. 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

The receive() function in the enforcer contract does not forward empty calls with value to the underlying implementation, unlike the fallback function.

Impact

Value sent with empty calldata is leaked and treated as royalties rather than reaching the intended custom logic, though the sponsor notes the receive function is limited to 21k gas and intended for royalty payouts.

What the attacker needed

Custom ERC721 implementation with receive(); user sends value with empty calldata

The fix

The receive() function should be updated to pass value down to the implementation like the fallback function, and clearer documentation plus revert functionality was added to alert developers.

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 smart contract can have a special function that runs when someone sends it money without any instructions. Here, that special function did not pass the money along to the custom code that the developer wrote, so the money got stuck and was treated as a royalty payment instead. This means a user who expected their money to trigger a specific action would lose it to the wrong place.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by Trust

View all

77 more disclosed reports, best first.

More from Holograph contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.