Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

ltyu - ERC721 can be deposits as ERC20 #74

Closed
github-actions bot opened this issue Feb 21, 2023 · 0 comments
Closed

ltyu - ERC721 can be deposits as ERC20 #74

github-actions bot opened this issue Feb 21, 2023 · 0 comments
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue

Comments

@github-actions
Copy link

github-actions bot commented Feb 21, 2023

ltyu

high

ERC721 can be deposits as ERC20

Summary

Vulnerability Detail

According to the natspec documentation in DepositManagerV1.sol, fundBountyToken() should be used to "Transfers protocol token or ERC20 from msg.sender to bounty address". However, it is possible to use this function to deposit ERC721 tokens. This is because there is no validation within Bounty.receiveFunds() that prevents ERC721 tokens from being deposited. This results in ERC721 tokens becoming unrefundable, as the deposit has been erroneously registered as a non-NFT.

Impact

Erronous ERC20 deposits with ERC721 tokens will be reverted when attempting to call refundDeposit()

Code Snippet

Heres the unit test for this:

it('should revert when attempting to refund ERC721-as-ERC20 deposit', async () => {
	// ARRANGE
	await openQProxy.mintBounty(Constants.bountyId, Constants.organization, atomicBountyInitOperation);
	const bountyAddress = await openQProxy.bountyIdToAddress(Constants.bountyId);
	await mockNft.approve(bountyAddress, 1);
	const bounty = await AtomicBountyV1.attach(bountyAddress);
	const depositId = generateDepositId(Constants.bountyId, 0);

	// ASSUME
	expect(await mockNft.ownerOf(1)).to.equal(owner.address);

	// ACT
	await depositManager.fundBountyToken(bountyAddress, mockNft.address, 1, 1, Constants.funderUuid);

	// ASSERT
	expect(await bounty.isNFT(depositId)).to.be.false;
	expect(await mockNft.ownerOf(1)).to.equal(bountyAddress);
	await expect(depositManager.refundDeposit(bountyAddress, depositId)).to.be.reverted;
});

This function can be used to transfer both, ERC20 and ERC721:
https://github.com/sherlock-audit/2023-02-openq/blob/main/contracts/Bounty/Implementations/BountyCore.sol#L197-L215
Here's the code being impacted:

Tool used

Manual Review

Recommendation

Add validation to receiveFunds() to prevent tokens besides ERC20 and protocol tokens from being deposited.

Duplicate of #352

@github-actions github-actions bot added Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue labels Feb 21, 2023
@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A valid High severity issue Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant