Egis-Security / CTF_Challenge

Repository containing CTF challenges from nmirchev8, deth and bOgO.
14 stars 8 forks source link

b0g0_Ctf: `withdraw` Function DOS for conttracts Due to Low-Level Call with Whitespace #39

Open DevPelz opened 2 months ago

DevPelz commented 2 months ago

Summary

The withdraw function in the BuggyNFTVault contract uses a low-level call with a whitespace payload when transferring ETH to the user. This approach triggers the fallback function of a recipient contract, which can lead to issues if the recipient contract does not have a fallback function. Contracts without a fallback function will not be able to receive the withdrawal, causing a denial of service (DoS) for those contracts.

Vulnerability Details

The withdraw function uses a low-level call with a whitespace payload to transfer ETH to the caller:

function withdraw(uint256 tokenId) external {
    require(ownerOf(tokenId) == msg.sender, "Only the owner can withdraw");

    // Burn the NFT to complete the withdrawal process.
    _burn(tokenId);
    deposits[msg.sender] -= depositRequired;

    (bool success, ) = msg.sender.call{value: depositRequired}(" "); // @audit whitespace
    require(success, "Transfer failed");
}

Impact

BogoCvetkov commented 2 months ago

Valid! But another auditor submitted first -> https://github.com/Egis-Security/CTF_Challenge/issues/30