Tadle

Tadle
DeFiFoundry
27,750 USDC
View results
Submission Details
Severity: low
Invalid

Non-Atomic Transactions in DeliveryPlace.sol

Summary

Transfers are performed before state updates which can lead to re-entrancy attacks and other unpredictable behaviors if an exception is thrown. This is because Solidity aims to be a "fail-safe" language, which means when an exception is thrown, all changes to the state from the current function call and all its sub-calls are reverted, apart from the payment of the gas fee. This aim to be fail-safe leads to interesting behaviors in the presence of re-entrancy attacks and related vulnerabilities.

Vulnerability Details

In DeliveryPlace.sol, functions closeBidOffer, closeBidTaker, settleAskMaker, and settleAskTaker update token balances before updating the contract states. This implies that in the event of a re-entrancy attack, the token balances could be manipulated while the contract state remains as is.

For example:

function closeBidTaker(address _stock) external {
ITokenManager tokenManager = tadleFactory.getTokenManager();
// ...
tokenManager.addTokenBalance( TokenBalanceType.RemainingCash, _msgSender(), makerInfo.tokenAddress, userCollateralFee );
// ...
perMarkets.updateStockStatus(_stock, StockStatus.Finished);
// ...
}

Above is an example of the affected code where token balance is added before updating the stock status.

Impact

the token balances could be manipulated while the contract state remains as is.

Tools Used

manual review

Recommendations

To remedy these findings, it's recommended to:

  1. Always follow the Checks-Effects-Interactions Pattern to make your contract invulnerable to re-entrancy attacks and maintain state consistency.

  2. Update any affected state variables before performing any transfer of tokens.

  3. Consider making use of the re-entrancy guard modifier provided by OpenZeppelin's ReentrancyGuard contract if necessary.

Updates

Lead Judging Commences

0xnevi Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Lack of quality
Assigned finding tags:

[invalid] finding-PreMarkets-reentrancy

Invalid, all [vague generalities](https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity#vague-generalities) talking about possible reentrancies 11and afaik, reentrancy is not possible and not proven.

Support

FAQs

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