Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NFT Reported Errors #489

Open
2 tasks
gagdiez opened this issue Nov 20, 2024 · 0 comments
Open
2 tasks

NFT Reported Errors #489

gagdiez opened this issue Nov 20, 2024 · 0 comments

Comments

@gagdiez
Copy link

gagdiez commented Nov 20, 2024

Background

A user has reported the following errors:

1. We noticed that in the Series contract, create_series function creates a storage key for tokens by
appending given series id with account id of the caller. However, there is no separator between them. It leads to the key collision 

This combination can lead to the storage key collision:
series_id = 2
account_id = 2clashing.test.near
storage_key = sha256(22clashing.test.near)
series_id_2 = 22
account_id_2 = clashing.test.near
storage_key_2 = sha256(22clashing.test.near)
storage_key_2 == storage_key


https://github.com/near-examples/nft-tutorial/blob/main/nft-series/src/series.rs#L39 

On each token mint, the storage will be overwritten for both of the series (2 & 22), which will lead to the series containing tokens from other series. Any series creator can exploit this by setting a series id to match the storage location of the token set of another series. It can be done for simple griefing, or if they match the token storage location of, let's say, an "expensive" series; when mint of an expensive series token happens, cheap series will also have that token in their set. Then, depending on the logic of the application, it can be exploited further.


Let me know if you need POC


2. We noticed that if the series contains a large number of royalties, during the nft_transfer_payout
execution, the contract can panic due to underflow on royalty_to_payout. This leads to some of the
tokens to be unpayable. That's because there is no validation of whether the total royalty percentage is larger than %100. So, a series creator can create a series with an arbitrary total percentage of royalties to be paid

https://github.com/near-examples/nft-tutorial/blob/main/nft-series/src/royalty.rs#L161
https://github.com/near-examples/nft-tutorial/blob/main/nft-series/src/series.rs#L15

Acceptance Criteria

  • There is no more collision on series
  • The royalties are validated

Priority

  • 🟠 P1 : High
@gagdiez gagdiez added this to DevRel Nov 20, 2024
@gagdiez gagdiez converted this from a draft issue Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: NEW❗
Development

No branches or pull requests

1 participant