The settleAskTaker function within the DeliveryPlace smart contract facilitates the settlement of "ask" orders or offers. This function allows multiple parties to interact via a multi-signature methodology. However, due to the sequence and nature of operations performed, race conditions can occur, leading to multiple or inconsistent state changes and settlements. This vulnerability poses significant risks to the contract's reliability, security, and integrity.
External Calls Before State Changes:
External calls to ITokenManager
and IPerMarkets
are made to process token transfers and settlements before updating the internal state of the contract.
Sequential Dependency:
The function relies on a sequence of checks and operations. If multiple transactions are processed simultaneously, there is a risk of updating the same state variables inconsistently.
Multi-Signature Access Control:
Multi-signature access mechanisms depend on the proper authorization of multiple parties (either the stock authority or the owner), which could lead to timing issues in state changes.
An attacker might exploit external calls like tokenManager.tillIn
to re-enter the function and manipulate state variables, withdrawing more funds than intended. If an external contract (such as the TokenManager
) is compromised or malicious, attackers could drain funds by repeating the settlement process before internal state variables are updated.
Multiple parties could attempt to execute settleAskTaker
simultaneously, leading to multiple settlements of the same offer or stock. Inconsistent state updates might also occur due to asynchronous execution, leading to financial discrepancies and operational issues.
Inconsistent State Changes: The same offer or stock might be settled multiple times leading to contradictory states.
Financial Losses: Unauthorized or repetitive extraction of funds due to re-entrancy attacks or multiple settlements.
Loss of Integrity: The reliability and trust in the contract may be compromised, affecting user confidence.
Manual review
Using ReentrancyGuard
from OpenZeppelin can prevent re-entrancy attacks by ensuring that functions cannot be called reentrantly.
Prioritize internal state changes before making any external calls. This reduces the window of opportunity for re-entrancy attacks and state inconsistencies.
Consider using mechanisms to ensure that operations are atomic, such as:
Using transaction batching.
Implementing confirmation steps to ensure the operation completes fully or reverts entirely.
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.