Skip to content
Business logic Audit finding Intermediate

Buypunk function of Cryptopunks in ERC721Pool is used incorrectly

The ERC721Pool contract calls the CryptoPunks buyPunk function without sending any value, but the original contract requires a payable call with msg.value. As a result, the call always reverts and a CryptoPunk can never be used as collateral in the pool.

Chinmay Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-01-ajna-judging/issues/163

Found by

Chinmay

Summary

The buyPunk function here seems to be for transferring NFT from sender to pool, but the original contract has a payable function that uses msg.value checks

Vulnerability Detail

This seems to be a weird implementation for transferring the NFT. Furthermore, the function is payable but the interface by AJNA doesn't mark it as payable.

This function checks for the msg.value in the original Cryptopunks contract. Calling it from the ERC721Pool will always revert because the msg.value is not being sent with the call at L#577. Thus, a cryptopunk NFT will never be able to be used as the collateral in this NFT pool.

Impact

Code Snippet

https://github.com/sherlock-audit/2023-01-ajna/blob/main/contracts/src/ERC721Pool.sol#L577

Tool used

Manual Review

Recommendation

Update the interface with the payable keyword and send msg.value along with the buyPunk call so that it passes checks at the target contract

Discussion

grandizzy

we're not going to support non standard NFT anymore, just wrapped versions

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

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

Likely the interface used by the pool does not mark buyPunk as payable and the call is made without attaching msg.value, so the target contract's value check fails.

Impact

A CryptoPunk NFT can never be used as collateral in this NFT pool because every deposit attempt reverts.

What the attacker needed

Pool supports CryptoPunks as collateral

The fix

The interface should mark buyPunk as payable and the call should forward msg.value so the target contract's checks pass, though the team said they will only support wrapped versions instead.

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.

Some older NFT contracts like CryptoPunks do not follow the usual NFT standard. Their transfer function expects the caller to send some money (a value) along with the call, and it checks that this value is present. The pool contract calls that function without sending any value, so the check fails and the whole call is rejected, meaning the NFT can never be deposited.

What is Business logic?

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

More by Chinmay

View all

5 more disclosed reports, best first.

More from Ajna #2

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.