# Incorrect implementation of the onDropMessage function in the L1ReverseCustomGateway contract

L1ReverseCustomGateway.onDropMessage transfers tokens instead of minting, so failed deposits can never be refunded, locking user funds.

- Payout: Audit contest
- Severity: high
- Program: Morphl2
- Found by: 0xRajkumar
- Disclosed: 2024-08-28
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-08-morphl2-judging/issues/66
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-08-morphl2%3AH-1
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic

**Target:** L1ReverseCustomGateway.onDropMessage (L1 bridge gateway)
**Root cause:** Tokens are burned on deposit and minted on finalizeWithdrawERC20, but onDropMessage uses safeTransfer from the gateway's own balance instead of minting, so the refund path has no tokens to send.
**Steps:**
1. Deposit ERC20 via L1ReverseCustomGateway: tokens are burned on L1.
2. Deposit message fails on L2 and is dropped.
3. onDropMessage is invoked with the finalizeDepositERC20-encoded message.
4. Function decodes (token, receiver, amount) and calls `IERC20Upgradeable(_token).safeTransfer(_receiver, _amount)`.
5. Gateway holds no balance (tokens were burned), so transfer reverts; user cannot recover funds.
**How found:** Code reading of the refund path: noticed deposit burns tokens and finalize mints, then observed onDropMessage uses safeTransfer rather than mint, making the refund impossible.
**Insight:** On bridge gateways, verify that every refund/drop path uses the same token supply mechanism (mint vs transfer) as the corresponding deposit/finalize path; burned-token designs must mint on refund.

## Proof of concept (copied exactly from the original report)

**onDropMessage uses safeTransfer instead of mint**

```
function onDropMessage(bytes calldata _message) external payable virtual onlyInDropContext nonReentrant {
        // _message should start with 0x8431f5c1  =>  finalizeDepositERC20(address,address,address,address,uint256,bytes)
        require(bytes4(_message[0:4]) == IL2ERC20Gateway.finalizeDepositERC20.selector, "invalid selector");

        // decode (token, receiver, amount)
        (address _token, , address _receiver, , uint256 _amount, ) = abi.decode(
            _message[4:],
            (address, address, address, address, uint256, bytes)
        );

        // do dome check for each custom gateway
        _beforeDropMessage(_token, _receiver, _amount);

        IERC20Upgradeable(_token).safeTransfer(_receiver, _amount);
```

