Protocol is not EIP712
compliant: incorrect typehash for Validation
and Transaction
structures
#23
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
high quality report
This report is of especially high quality
M-03
primary issue
Highest quality submission among a set of duplicates
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2023-10-brahma/blob/main/contracts/src/libraries/TypeHashHelper.sol#L45-L50
https://github.com/code-423n4/2023-10-brahma/blob/main/contracts/src/libraries/TypeHashHelper.sol#L52-L57
Vulnerability details
Summary
When implementing
EIP712
, among other things, for data structures that will be a part of signing message a typehash must be defined.The structure typehash is defined as:
typeHash = keccak256(encodeType(typeOf(s)))
name ‖ "(" ‖ member₁ ‖ "," ‖ member₂ ‖ "," ‖ … ‖ memberₙ ")"
type ‖ " " ‖ name
.The project uses 2 structures on the signed data
Transaction
andValidation
declared inTypeHashHelper
:However, the precalculated typehash for each of the structure are of different structures:
Transaction
the hash is actually calculated on a now removedExecutionParams
structure:Validation
the hash is calculated on another old, removed structureValidationParams
:POC
The issue went undetected in the initial development phase, and can be verified, because the tests still use the old hashes:
The specific test can be verified by running:
Impact
Protocol is not EIP712 compliant which will result in issues with integrators.
Tools Used
Manual review and an online
keccak256
checker for validating that the those hashes are not actually for the correct structures.Recommendations
Modify the structure typehash (and tests) to point to the correct structures.
Assessed type
Other
The text was updated successfully, but these errors were encountered: