It is possible to bypass the need for signer if exactly same transaction is executed as a transaction in the past.
Since all pieces of data used when creating the message digest (that will be signed with operator's private key) are static and reproducible (i.e. nothing dynamic is used such as an account NONCE), it is possible to make a sendToL1 function call with exactly the same data as a previous transaction.
This stems from the fact that in function withdrawTokensToL1, data is encoded in a duplicatable manner. There needs to be a piece in the message digest that can only be used once -such as a nonce.
This way, the attacker can execute a denial of service attack which will immediately withdraw tokens back to the user after the user deposited them.
The user will not be able to use their funds on L2 because the attacker can send them back to the user immediately, completely bypassing the need for the operator to sign the withdrawal transaction.
src/L1BossBridge.sol
https://github.com/Cyfrin/2023-11-Boss-Bridge/blob/dad104a9f481aace15a550cf3113e81ad6bdf061/src/L1BossBridge.sol#L91C25-L91C25
Regular user can not use L2 because their funds are immediately returned to them (provided they had a previous withdraw transaction that will be mimicked by the attacker).
One approach is to implement an internal state variable that has a nonce which can only be used for one withdrawal and is then invalidated.
Add a new state variable to keep track of this value.
Then in withdrawTokensToL1 add a parameter for the uint256 nonce that will have to be different each time. Encode the message with this one-time-use value included.
This will ensure that every future transaction will require a nonce value that is different -since they will be usable only once because the previous nonce values in the mapping are all set to true and not usable again.
For more details on implementing this approach please see below:
https://docs.soliditylang.org/en/latest/solidity-by-example.html#computing-the-message-hash
Manual Audit
Foundry
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.