Closed code423n4 closed 1 year ago
Similar to #142 - "assets are not at risk: function incorrect as to spec" then we think it should be Low severity
donosonaumczuk marked the issue as disagree with severity
Picodes marked the issue as satisfactory
Keeping duplicate as the general issue is the non compliance of array encoding
Picodes marked the issue as duplicate of #142
Hi @Picodes,
I originally submitted this as a separate issue from #142 as it violates a different rule in EIP-712. In #142, the encoding of arrays are wrong, while in this issue, the encoding of arrays is technically correct; it's the bytes
within it that are encoded wrongly.
Also, if you decide that this issue should still remain a duplicate, shouldn't this one be nullified since the main issue is mine as well? Not sure if it really matters for award calculation or the final report.
Thanks!
@MiloTruck I understand why you originally submitted separate reports. You're totally right to highlight that without #142, this issue would still exist so it wouldn't comply with EIP-712.
My reasoning here is that the root cause is that the dev team didn't follow the EIP to encode these arrays, so correctly mitigating #142 only would very likely lead to this issue being fixed as they'll also fix this in the process. I therefore consider this as a "sub-issue" of #142. On the opposite for example your report #141 is treated separately as fixing #142 wouldn't have led to the team fixing it.
For the award formula: this is taken into account in the computation script!
Lines of code
https://github.com/code-423n4/2023-07-lens/blob/main/contracts/libraries/MetaTxLib.sol#L160-L170
Vulnerability details
Bug Description
The
_hashActionModulesInitDatas()
function is used to encode theactionModulesInitDatas
parameter when verifying signatures in accordance to EIP-712:MetaTxLib.sol#L160-L170
As seen from above, it calls
abi.encode()
on everybytes
element in the array before encoding the entire array. However, according to EIP-712,bytes
should be passed tokeccak256
directly, withoutabi.encode()
:When
abi.encode()
is called on eachbytes
element, the offset and length of thebytes
object will also be included in the data that is passed tokeccak256
. For example:Therefore, the following functions do not comply with EIP-712 as they use
_hashActionModulesInitDatas()
when verifying signatures:validatePostSignature()
validateCommentSignature()
validateQuoteSignature()
A correct example of encoding a
bytes
array can be seen invalidateFollowSignature()
, where each element in thebytes
array is passed tokeccak256
directly.Impact
Contracts or dapps/backends that encode
actionModulesInitDatas
according to the rules specified in EIP-712 will end up with different signatures, causing any of the functions listed above to revert when called.Recommended Mitigation
In
_hashActionModulesInitDatas()
, passactionModulesInitDatas[i]
directly tokeccak256
instead of usingabi.encode()
:MetaTxLib.sol#L160-L170
Assessed type
Other