In the DeliveryPlace.sol
contract, certain functions that accept address
parameters do not properly validate these addresses before using them in critical operations. Specifically, the closeBidOffer
, closeBidTaker
, settleAskMaker
, and settleAskTaker
functions use address
parameters without checking if they are zero addresses. Using zero addresses in these functions could lead to unintended behaviors, such as sending tokens to the zero address (burning tokens) or failing to correctly execute the intended logic.
in closeBidOffer(address _offer)
Function
No Address Validation: The function takes _offer
as an input but does not check if it is a valid non-zero address. If _offer
is the zero address (address(0)
), it could cause unintended behavior when used in subsequent function calls or state changes.
** Impact:** If an attacker passes a zero address as _offer
, it could disrupt the function's logic or lead to failures in the marketplace. For example, if the zero address is used in a transfer or update operation, it could burn tokens or prevent proper state transitions.
in closeBidTaker(address _stock)
Function
No Address Validation: The _stock
parameter is not checked to ensure it is a valid, non-zero address before being used to fetch stock information and perform operations.
Impact: If _stock
is the zero address, the function could fetch incorrect or default values, leading to potential logic failures or state corruption. This might cause incorrect token transfers or improper updates to stock statuses.
in settleAskMaker(address _offer, uint256 _settledPoints)
Function
The _offer
parameter is not validated to check if it is a non-zero address before being used in various operations.
Impact: Using a zero address for _offer
could lead to failures in processing the offer, incorrect point settlements, or improper token management, potentially resulting in financial losses or contract malfunction.
in settleAskTaker(address _stock, uint256 _settledPoints)
Function
No Address Validation: The _stock
parameter is used without checking if it is a valid, non-zero address.
** Impact:** If the zero address is used, the function might interact with unintended contract states or default values, potentially leading to incorrect state updates or financial operations.
The lack of proper validation for address
parameters can lead to various unintended consequences, including incorrect state transitions, financial losses due to token transfers to the zero address, or even contract malfunction. These vulnerabilities can be exploited by attackers who pass in zero addresses to disrupt the normal operation of the contract.
Manual Code Review
Add Address Validation:
Add checks in each function to ensure that address
parameters (like _offer
and _stock
) are not zero addresses before proceeding with the logic.
Example Fix:
require(_offer != address(0), "Invalid offer address");
Implement unit tests that include scenarios where zero addresses are passed as parameters to ensure the contract correctly handles or rejects these inputs.
Consider Using OpenZeppelin’s Address Library:
The Address
library from OpenZeppelin provides useful utility functions, such as checking if an address is a contract. This could be used to enhance the security of address handling in the contract.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.