Tadle

Tadle
DeFi
30,000 USDC
View results
Submission Details
Severity: medium
Invalid

Lack of Input Validation for address Parameters in Critical Functions

Summary

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.

Vulnerability Details

in closeBidOffer(address _offer) Function

function closeBidOffer(address _offer) external {
(
OfferInfo memory offerInfo,
MakerInfo memory makerInfo,
,
MarketPlaceStatus status
) = getOfferInfo(_offer);
// No validation for the _offer address
if (_msgSender() != offerInfo.authority) {
revert Errors.Unauthorized();
}
// Function logic continues...
}

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

function closeBidTaker(address _stock) external {
IPerMarkets perMarkets = tadleFactory.getPerMarkets();
ITokenManager tokenManager = tadleFactory.getTokenManager();
StockInfo memory stockInfo = perMarkets.getStockInfo(_stock);
// No validation for the _stock address
if (stockInfo.preOffer == address(0x0)) {
revert InvalidStock();
}
// Function logic continues...
}

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

function settleAskMaker(address _offer, uint256 _settledPoints) external {
(
OfferInfo memory offerInfo,
MakerInfo memory makerInfo,
MarketPlaceInfo memory marketPlaceInfo,
MarketPlaceStatus status
) = getOfferInfo(_offer);
// No validation for the _offer address
if (_settledPoints > offerInfo.usedPoints) {
revert InvalidPoints();
}
// Function logic continues...
}

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

function settleAskTaker(address _stock, uint256 _settledPoints) external {
IPerMarkets perMarkets = tadleFactory.getPerMarkets();
StockInfo memory stockInfo = perMarkets.getStockInfo(_stock);
// No validation for the _stock address
if (stockInfo.stockStatus != StockStatus.Initialized) {
revert InvalidStockStatus();
}
// Function logic continues...
}

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.

Impact

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.

Tools Used

Manual Code Review

Recommendations

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");

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.

Updates

Lead Judging Commences

0xnevi Lead Judge
11 months ago
0xnevi Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

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