Bid Beasts

First Flight #49
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: low
Valid

Missing Event Emission for Successful Withdrawals in `BidBeastsNFTMarket::withdrawAllFailedCredits`

Root + Impact

  • Root Cause: The withdrawAllFailedCredits function successfully withdraws funds from the failedTransferCredits mapping but does not emit an event to log the transaction. This omission occurs because no event emission is implemented after the require(success, "Withdraw failed") check, leaving no on-chain record of the withdrawal details.

  • Impact: The lack of event emission reduces transparency, making it difficult for off-chain systems (e.g., frontends, monitoring tools) to track withdrawals. This can hinder auditing, complicate dispute resolution, and erode user trust, as financial operations lack a verifiable public log, especially in a marketplace handling significant funds.

Description:

The withdrawAllFailedCredits function does not emit an event upon a successful withdrawal. Without an event, off-chain systems (e.g., frontends or monitoring tools) cannot easily track when funds are withdrawn from failedTransferCredits, reducing transparency and complicating debugging or auditing.

function withdrawAllFailedCredits(address _receiver) external {
uint256 amount = failedTransferCredits[_receiver];
require(amount > 0, "No credits to withdraw");
failedTransferCredits[msg.sender] = 0;
(bool success, ) = payable(msg.sender).call{value: amount}("");
require(success, "Withdraw failed");
@> // No event emitted here
}

Risk

  • Likelihood: Medium. The issue affects all successful withdrawals, a common operation in a marketplace. The likelihood increases with active usage or in cases requiring audit trails, though it depends on off-chain systems relying on events.

  • Impact: Medium. The absence of event emission does not cause direct financial loss but significantly impacts transparency and auditability. It may lead to operational inefficiencies, user mistrust, and challenges in resolving disputes or detecting bugs, particularly in high-stakes transactions.

Proof of Concept:

The withdrawAllFailedCredits function allows users to withdraw funds from the failedTransferCredits mapping, but it does not emit an event to log the withdrawal details (e.g., the receiver’s address and the amount withdrawn). This lack of event emission has significant implications:

  • Importance of Events for Withdrawals:

    • Off-Chain Tracking: Events are the primary mechanism for off-chain systems to monitor contract activity. For example, a frontend application needs to listen for events to display a user’s transaction history or confirm that a withdrawal has occurred. Without an event like CreditsWithdrawn(address indexed receiver, uint256 amount), such systems must rely on less reliable methods (e.g., parsing transaction receipts), which are inefficient and error-prone.

    • Auditability and Compliance: In decentralized applications, auditors and regulators often require detailed logs of financial transactions. An event ensures that every withdrawal is recorded in the blockchain’s event log, making it immutable and verifiable. Without it, auditing the contract’s financial operations becomes cumbersome.

    • Error Detection: If a bug (e.g., incorrect mapping updates or reentrancy attacks) causes unexpected withdrawals, an event log would provide a clear trace of the transaction details (who withdrew, how much, and when). Without an event, developers must manually inspect transaction data, which is time-consuming and prone to oversight.

    • User Trust: Users expect transparency in financial operations. Emitting an event for each withdrawal builds trust by ensuring that all actions are publicly logged and verifiable on the blockchain.

In this case, if a user (e.g., Alice) withdraws 10 ether from failedTransferCredits, no event is emitted to record the transaction. This makes it impossible for off-chain systems to automatically detect the withdrawal, notify Alice, or log the event for auditing purposes. This lack of transparency could lead to operational inefficiencies or disputes, especially in a marketplace contract handling significant funds.

Recommended Mitigation:

To improve transparency and traceability, add an event emission to the withdrawAllFailedCredits function to log successful withdrawals. Additionally, address related vulnerabilities to ensure the function is secure and robust.

  • Example:

+ event CreditsWithdrawn(address indexed receiver, uint256 amount);
function withdrawAllFailedCredits(address _receiver) external {
require(_receiver != address(0), "Receiver cannot be zero address");
require(_receiver == msg.sender, "Can only withdraw own credits");
uint256 amount = failedTransferCredits[_receiver];
require(amount > 0, "No credits to withdraw");
failedTransferCredits[_receiver] = 0;
(bool success, ) = payable(_receiver).call{value: amount}("");
require(success, "Withdraw failed");
+ emit CreditsWithdrawn(_receiver, amount);
}

Explanation

  • Event Emission: The CreditsWithdrawn event, with receiver indexed for filtering, logs each withdrawal, enabling off-chain tracking and auditability.

  • Additional Checks: Including zero-address and ownership validations (as previously recommended) ensures the function’s security, preventing unauthorized or invalid withdrawals.

  • Transparency: The event provides a public, immutable record, improving user trust and operational efficiency.

Updates

Lead Judging Commences

cryptoghost Lead Judge about 1 month ago
Submission Judgement Published
Validated
Assigned finding tags:

BidBeasts Marketplace: Incorrect Event Emission

placeBid emits AuctionSettled even though the auction hasn’t ended, causing misleading event logs.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.