Malicious actor can prevent migration by calling a non-existing function in `OVM_L2ToL1MessagePasser` and making `ReadWitnessData` return an error
The migration tool collects all calls to the OVM_L2ToL1MessagePasser contract without validating the calldata, and later parsing assumes each call is a valid passMessageToL1 invocation. An attacker can call a non-existent function on that contract, causing the parser to error and halt the migration.
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-03-optimism-judging/issues/67
Found by
0xdeadbeef
Summary
There is a mismatch between collected witness data in l2geth to the parsing of the collected data during migration. The mismatch will return an error and halt the migration until the data will be cleaned.
Vulnerability Detail
Witness data is collected from L2geth using a state dumper that collects any call to OVM_L2ToL1MessagePasser.
The data is collected regardless of the calldata itself. Any call to OVM_L2ToL1MessagePasser will be collected.
The data will persist regardless of the status of the transaction.
func (evm *EVM) Call(caller ContractRef, addr common.Address, input []byte, gas uint64, value *big.Int) (ret []byte, leftOverGas uint64, err error) {
if addr == dump.MessagePasserAddress {
statedumper.WriteMessage(caller.Address(), input)
}
The data will be stored in a file in the following format: "MSG|<source>|<calldata>"
At the start of the migration process, in order to unpack the message from the calldata, the code uses the first 4 bytes to lookup the the selector of passMessageToL1 from the calldata and unpack the calldata according to the ABI.
ReadWitnessData:
https://github.com/sherlock-audit/2023-03-optimism/blob/main/optimism/op-chain-ops/crossdomain/witness.go#L81-L89
method, err := abi.MethodById(msgB[:4])
if err != nil {
return nil, nil, fmt.Errorf("failed to get method: %w", err)
}
out, err := method.Inputs.Unpack(msgB[4:])
if err != nil {
return nil, nil, fmt.Errorf("failed to unpack: %w", err)
}
As can be seen above, the function will return an error that is bubbled up to stop the migration if:
- The calldata first 4 bytes is not a selector of a function from the ABI of
OVM_L2ToL1MessagePasser - The parameters encoded with the selectors are not unpackable (are not the parameters specified by the ABI)
A malicious actor will call any non-existing function in the address of OVM_L2ToL1MessagePasser.
The message will be stored in the witness data and cause an error during migration.
ReadWitnessData is called to parse they json witness data before any filtering is in place.
Impact
An arbitrary user can halt the migration process
Code Snippet
In vulnerability section
Tool used
Manual Review
Recommendation
Instead of bubbling up an error, simply continue to the next message. This shouldn't cause a problem since in the next stages of the migration there are checks to validate any missing messages from the storage.
Discussion
hrishibhat
Sponsor comment: Invalid witness data can cause an error during migration by malicious actor call to the OVM_L2ToL1MessagePasser.
GalloDaSballo
Temporary DOS, not acceptable risk, agree with Med
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The witness data collection does not filter or validate calldata, while the migration parser assumes every entry is a valid passMessageToL1 call and aborts on any parsing error.
Impact
An arbitrary user can halt the migration process, causing a temporary denial of service until the bad data is cleaned.
What the attacker needed
Ability to send a transaction to OVM_L2ToL1MessagePasser
The fix
The migration parser should skip invalid messages instead of aborting, since later stages validate missing messages from storage.
How it was found
- Call a non-existent function on the OVM_L2ToL1MessagePasser contract.
- The call is recorded in the witness data file.
- During migration, ReadWitnessData attempts to parse the calldata and fails.
- The error halts the migration process.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
During a system upgrade, a tool reads a log of messages sent to a special contract. It assumes every message is properly formatted, but an attacker can send a malformed message that makes the tool crash. This stops the upgrade until someone manually removes the bad entry.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.