0xdeadbeef
medium
OptimismPortal has a feature that helps EOAs to easily transfer funds to L2 by just transferring ETH to the contract. EOAs can directly transfer funds to OptimismPortal to receive it in L2. It mentions in the document that if contracts will transfer funds to the contract, it will be lost due to aliasing.
There is no enforcement on implementation to validate that only EOA has called the receive
function.
The receive
function in OptimismPortal
does not enforce EOA calls only.
receive() external payable {
depositTransaction(msg.sender, msg.value, RECEIVE_DEFAULT_GAS_LIMIT, false, bytes(""));
}
Contracts should be prevented from calling this function
Contracts/smart wallets/vaults depositing directly to OptimismPortal
will lose their funds
Manual Review
Consider adding the following modifier to the receive
function
modifier onlyEOA() {
require(
!Address.isContract(msg.sender),
"OptimismPortal: function can only be called from an EOA"
);
_;
}