Incorrect encoding of deposit transactions that creates a new contract
Summary
Incorrect encoding of deposit transactions that creates a new contract
Vulnerability Detail
The encodeDepositTransaction() function in the libraries/Encoding.sol contract does not correctly encode the _tx.isCreation field of a deposit transaction. At L35, the encoded isCreation field is always set to false.
Impact
The encoding of a deposit transaction is incorrect when _tx.isCreation is true. As a result, the deposit transaction's hash calculated from the hashDepositTransaction() function of libraries/Hashing.sol is incorrect either.
shw
low
Incorrect encoding of deposit transactions that creates a new contract
Summary
Incorrect encoding of deposit transactions that creates a new contract
Vulnerability Detail
The
encodeDepositTransaction()
function in thelibraries/Encoding.sol
contract does not correctly encode the_tx.isCreation
field of a deposit transaction. At L35, the encodedisCreation
field is always set tofalse
.Impact
The encoding of a deposit transaction is incorrect when
_tx.isCreation
istrue
. As a result, the deposit transaction's hash calculated from thehashDepositTransaction()
function oflibraries/Hashing.sol
is incorrect either.Code Snippet
https://github.com/ethereum-optimism/optimism/blob/3f4b3c328153a8aa03611158b6984d624b17c1d9/packages/contracts-bedrock/contracts/libraries/Encoding.sol#L35 https://github.com/ethereum-optimism/optimism/blob/3f4b3c328153a8aa03611158b6984d624b17c1d9/packages/contracts-bedrock/contracts/libraries/Hashing.sol#L21-L27
Tool used
Manual Review
Recommendation
Fix
RLPWriter.writeBool(false)
on L35 toRLPWriter.writeBool(_tx.isCreation)
.Duplicate of #89