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

b0g0_ctf - Unauthorized Withdrawal via NFT Transfer #35

Open
mo-hak opened this issue Aug 12, 2024 · 1 comment
Open

b0g0_ctf - Unauthorized Withdrawal via NFT Transfer #35

mo-hak opened this issue Aug 12, 2024 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@mo-hak
Copy link

mo-hak commented Aug 12, 2024

𝗦𝗲𝘃𝗲𝗿𝗶𝘁𝘆:

Medium

Description of the Bug:

mapping(address => uint256) public deposits;
When a user deposits ETH and receives an NFT, the 𝐝𝐞𝐩𝐨𝐬𝐢𝐭𝐬 𝐦𝐚𝐩𝐩𝐢𝐧𝐠 is updated to reflect the deposited amount mapped to the initial depositor. However, if the NFT is transferred to another address via 𝐭𝐫𝐚𝐧𝐬𝐟𝐞𝐫 𝐟𝐮𝐧𝐜𝐭𝐢𝐨𝐧 from erc721 (as it is not overridden), 𝐭𝐡𝐞 𝐝𝐞𝐩𝐨𝐬𝐢𝐭𝐬 𝐦𝐚𝐩𝐩𝐢𝐧𝐠 𝐢𝐬 𝐧𝐨𝐭 𝐮𝐩𝐝𝐚𝐭𝐞𝐝 𝐭𝐨 𝐫𝐞𝐟𝐥𝐞𝐜𝐭 𝐭𝐡𝐢𝐬 𝐭𝐫𝐚𝐧𝐬𝐟𝐞𝐫 𝐭𝐨 𝐭𝐡𝐞 𝐧𝐞𝐰 𝐨𝐰𝐧𝐞𝐫. This allows the new owner of the NFT to withdraw ETH without having deposited any, leading to unauthorized withdrawals.

Impact:

Underflow Errors: Subtracting the deposit amount from an address with zero balance could cause underflow errors, leading to unexpected behavior or contract failure. And the original owner cant also withdraw as it is not the current owner. This would lead to 𝐝𝐞𝐧𝐢𝐚𝐥 𝐨𝐟 𝐬𝐞𝐫𝐯𝐢𝐜𝐞

Solution:

To prevent the vulnerability, the contract should be modified to ensure that only the original depositor can withdraw their ETH. This can be achieved by tracking the original depositor for each token ID and ensuring that only this address can call the withdraw function.

@BogoCvetkov
Copy link
Collaborator

Valid! Already submitted by another auditor -> #22

@BogoCvetkov BogoCvetkov added the duplicate This issue or pull request already exists label Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants