Ironsidesec - hashProposal uses wrong typeshash when hashing the encoded Proposal struct data #266
Labels
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
Ironsidesec
Medium
hashProposal uses wrong typeshash when hashing the encoded Proposal struct data
Summary
acceptLoanOfferAndFillOrder
,_refinance
,matchProposals
use_assertValidSignature
which hashes proposal data and verifies the signature. But the hashed proposal type hash computation is wrong due to usage ofuint256 questionId
instead ofbytes32 questionId
There are 2 impacts. So, even if one is acceptable/wrong, then the issue impact on another.
Definition of typed structured data
section.Root Cause
Using
uint256 questionId
instead ofbytes32 questionId
inside the type hash ofhashProposal()
Internal pre-conditions
No response
External pre-conditions
No response
Attack Path
Issue flow :
questionId
is in bytes 32. And when hashing a proposal data, the type hash of proposal struct format should also use bytes32 for question id. But here its using uint256. Check on line 819 below.This breaks the EIP712 , where atomic types like uint, bytes1 to bytes32, address should be directly used. And only strings, bytes data are dynamic types, should be keccack hashed and then derive the type hash.
https://github.com/sherlock-audit/2024-09-predict-fun/blob/41e70f9eed3f00dd29aba4038544150f5b35dccb/predict-dot-loan/contracts/interfaces/IPredictDotLoan.sol#L50
https://github.com/sherlock-audit/2024-09-predict-fun/blob/41e70f9eed3f00dd29aba4038544150f5b35dccb/predict-dot-loan/contracts/PredictDotLoan.sol#L817
Impact
2 impacts
readme
where it strictly complains. The atomic types should not be hashed or converted to other types.PoC
No response
Mitigation
https://github.com/sherlock-audit/2024-09-predict-fun/blob/41e70f9eed3f00dd29aba4038544150f5b35dccb/predict-dot-loan/contracts/PredictDotLoan.sol#L817
The text was updated successfully, but these errors were encountered: