sherlock-audit / 2024-06-symmetrical-update-2-judging

0 stars 0 forks source link

slowfi - Restoration of Suspended Bridge Transactions Without Ensuring Bridge Existence Leads to Loss of Bridged Amounts #17

Closed sherlock-admin2 closed 3 months ago

sherlock-admin2 commented 3 months ago

slowfi

Medium

Restoration of Suspended Bridge Transactions Without Ensuring Bridge Existence Leads to Loss of Bridged Amounts

Summary

The current implementation in BridgeFacetImpl.sol allows the restoration of suspended bridge transactions without verifying the existence of the bridge in the system. This oversight results in potential loss of bridged amounts, as there is no mechanism to restore these amounts to users if the associated bridge has been removed from the system.

Vulnerability Detail

In the restoreBridgeTransaction function within BridgeFacetImpl.sol, a bridge transaction can be restored from a suspended state without validating whether the corresponding bridge still exists in the system. If the bridge has been deregistered or removed, there is no way to return the bridged amount to the user, resulting in a potential loss of funds.

Impact

This vulnerability poses a risk of financial loss for users whose transactions are suspended and cannot be restored due to the absence of the associated bridge.

Code Snippet

No check to ensure the bridge exists in the system on the restoreBridgeTransaction function.

function restoreBridgeTransaction(uint256 transactionId, uint256 validAmount) internal {
    BridgeStorage.Layout storage bridgeLayout = BridgeStorage.layout();
    BridgeTransaction storage bridgeTransaction = bridgeLayout.bridgeTransactions[transactionId];

    require(bridgeTransaction.status == BridgeTransactionStatus.SUSPENDED, "BridgeFacet: Invalid status");
    require(bridgeLayout.invalidBridgedAmountsPool != address(0), "BridgeFacet: Zero address");

    AccountStorage.layout().balances[bridgeLayout.invalidBridgedAmountsPool] += (bridgeTransaction.amount - validAmount);
    bridgeTransaction.status = BridgeTransactionStatus.RECEIVED;
    bridgeTransaction.amount = validAmount;
}

Tool used

Manual Review

Recommendation

Implement a validation mechanism within restoreBridgeTransaction to verify whether the bridge associated with the suspended transaction still exists in the system. If the bridge has been deregistered or removed, introduce a fallback mechanism to handle the return of bridged amounts to the user's account or an appropriate recovery address.

This same principle can be applied for bridged transfers that have the bridge removed during the cooldown period. Consider as well creating a function to restore bridged transaction funds to users for recovery situations.