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

InventoryStaking deposit() and withdraw() don't validate passed vaultId #61

Open
code423n4 opened this issue Dec 19, 2021 · 0 comments
Open
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons

Comments

@code423n4
Copy link
Contributor

Handle

Ruhum

Vulnerability details

Impact

In NFTXInventoryStaking a user can withdraw() and deposit() for a vaultId they specify. But, the vaultId is not validated. Instead, the transaction will simply fail at some point because the vault is a zero address. That leads to a bad user experience since the user loses more gas than is really necessary. Instead, the function should validate that there is a vault with that specific ID and revert if that's not the case.

Proof of Concept

https://github.com/code-423n4/2021-12-nftx/blob/main/nftx-protocol-v2/contracts/solidity/NFTXInventoryStaking.sol#L84

https://github.com/code-423n4/2021-12-nftx/blob/main/nftx-protocol-v2/contracts/solidity/NFTXInventoryStaking.sol#L104

Both functions will at some point try to access the passed vault which could be a zero address:
For withdraw() it happens here: https://github.com/code-423n4/2021-12-nftx/blob/main/nftx-protocol-v2/contracts/solidity/NFTXInventoryStaking.sol#L105

For deposit() it happens here: https://github.com/code-423n4/2021-12-nftx/blob/main/nftx-protocol-v2/contracts/solidity/NFTXInventoryStaking.sol#L149

Tools Used

none

Recommended Mitigation Steps

Add the following require statement at the beginning of the function:
require(nftxVaultFactory.vault(vaultId) != address(0), "invalid vaultId");

@code423n4 code423n4 added 1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working labels Dec 19, 2021
code423n4 added a commit that referenced this issue Dec 19, 2021
@0xKiwi 0xKiwi added the sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons label Dec 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Something isn't working sponsor acknowledged Technically the issue is correct, but we're not going to resolve it for XYZ reasons
Projects
None yet
Development

No branches or pull requests

2 participants