Tadle

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

Potential State Inconsistency Due to Unchecked External Calls

Vulnerability Details

The contract makes external calls to tokenManager.tillIn() without checking the return value. If these calls fail, the function continues executing, which could lead to inconsistent state.

Impact

If the tillIn function fails (e.g., due to insufficient balance or a paused contract), the contract will continue execution as if the transfer succeeded. This could lead to significant discrepancies between the expected and actual token balances, potentially allowing users to receive tokens or benefits they shouldn't.

Proof of Concept:

In the settleAskMaker function:

Link to code

function settleAskMaker(address _offer, uint256 _settledPoints) external {
// ... [earlier code omitted for brevity]
uint256 settledPointTokenAmount = marketPlaceInfo.tokenPerPoint * _settledPoints;
if (settledPointTokenAmount > 0) {
tokenManager.tillIn(
_msgSender(),
marketPlaceInfo.tokenAddress,
settledPointTokenAmount,
true
);
}
// ... [state updates and event emissions]
perMarkets.settledAskOffer(
_offer,
_settledPoints,
settledPointTokenAmount
);
}

If tokenManager.tillIn() fails silently (e.g., due to insufficient balance), the function will continue execution. This results in:

  1. The caller not actually transferring the tokens.

  2. The offer being marked as settled with perMarkets.settledAskOffer().

  3. An event being emitted suggesting a successful settlement.

This creates a state where the contract believes a settlement occurred, but no actual token transfer took place.

Tools Used

Manual Review

Recommendations

  1. Check the return value of tillIn and revert the transaction if it fails.

  2. If tillIn doesn't return a boolean, consider modifying it to do so, or use a try/catch structure to handle potential reverts.

  3. Add events to log any failed transfers for off-chain monitoring.

Example:

bool success = tokenManager.tillIn(
_msgSender(),
marketPlaceInfo.tokenAddress,
settledPointTokenAmount,
true
);
require(success, "Token transfer failed");
Updates

Lead Judging Commences

0xnevi Lead Judge
about 1 year ago
0xnevi Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

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