The operator being the one signing the message withdrawTokensToL1 he could potentially change the 'to' and 'amount' and rug the vault
function testOperatorRug() public {
uint256 largeApprove = 100e18;
uint256 depositAmount = 10e18;
vm.startPrank(user);
token.balanceOf(address(user));
token.approve(address(tokenBridge), largeApprove);
tokenBridge.depositTokensToL2(user, userInL2, largeApprove);
vm.stopPrank();
vm.startPrank(operator.addr);
(uint8 v, bytes32 r, bytes32 s) = _signMessage(_getTokenWithdrawalMessage(operator.addr, depositAmount), operator.key);
tokenBridge.withdrawTokensToL1(operator.addr, depositAmount, v, r, s);
(uint8 v2, bytes32 r2, bytes32 s2) = _signMessage(_getTokenWithdrawalMessage(operator.addr, depositAmount), operator.key);
tokenBridge.withdrawTokensToL1(operator.addr, depositAmount, v2, r2, s2);
vm.stopPrank();
assertEq(token.balanceOf(operator.addr), depositAmount * 2);
}
Even if it's known that the protocol is centralised it should not be possible for the project owner to rug the project
Add a mapping with the amount deposited per user to avoid malicious actors withdrawing for users without deposit