stake.link

stake.link
DeFiHardhatBridge
27,500 USDC
View results
Submission Details
Severity: high
Invalid

Potential Reentrancy Vulnerability in `handleIncomingRESDL` function

Summary

The handleIncomingRESDL function in the SDLPoolCCIPControllerPrimary contract has a potential vulnerability related to reentrancy attacks. The function's state update, which involves reducing the total supply of a token on the source chain, is placed after an external call to ISDLPoolPrimary(sdlPool).handleIncomingRESDL. This order of operations may expose the contract to reentrancy attacks. Basically, it is not following the CEI pattern.

Vulnerability Details

The vulnerability arises from the fact that the state update is not done atomically with the external call. In case of reentrancy, an attacker could potentially re-enter the function before the state is updated, leading to an inconsistent state and unintended consequences.

Impact

If a reentrancy attack occurs, the reduction in the total supply of the token on the source chain may not take effect as intended. This could result in an inconsistent state and potential issues with the correctness and security of the contract.

Tools Used

Manual review.

Recommendations

To address the vulnerability, it is recommended to reorder the operations in the handleIncomingRESDL function. The state update, particularly the reduction in total supply, should be done before any external calls to ensure atomicity and prevent reentrancy vulnerabilities. Additionally, consider using reentrancy guards or mutex patterns to further enhance the security of the contract.

Updated code should look like this:

// Ensure state updates are performed before external calls to prevent reentrancy vulnerabilities
function handleIncomingRESDL(
uint64 _sourceChainSelector,
address _receiver,
uint256 _tokenId,
ISDLPool.RESDLToken calldata _reSDLToken
) external override onlyBridge {
+ // Perform state updates before the external call
+ reSDLSupplyByChain[_sourceChainSelector] -= _reSDLToken.amount + _reSDLToken.boostAmount;
sdlToken.safeTransfer(sdlPool, _reSDLToken.amount);
ISDLPoolPrimary(sdlPool).handleIncomingRESDL(_receiver, _tokenId, _reSDLToken);
}
Updates

Lead Judging Commences

0kage Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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