EIP-712 typehash is incorrect for several functions in MetaTxLib
Submitted by MiloTruck, also found by juancito
In LensHub.sol, the second parameter of setProfileMetadataURIWithSig() is declared as metadataURI:
function setProfileMetadataURIWithSig(
uint256 profileId,
string calldata metadataURI,
Types.EIP712Signature calldata signature
) external override whenNotPaused onlyProfileOwnerOrDelegatedExecutor(signature.signer, profileId) {
However, its EIP-712 typehash stores the parameter as metadata instead:
bytes32 constant SET_PROFILE_METADATA_URI = keccak256('SetProfileMetadataURI(uint256 profileId,string metadata,uint256 nonce,uint256 deadline)');
The PostParams struct (which is used for postWithSig()) has address[] actionModules and bytes[] actionModulesInitDatas as its third and fourth fields:
struct PostParams {
uint256 profileId;
string contentURI;
address[] actionModules;
bytes[] actionModulesInitDatas;
address referenceModule;
bytes referenceModuleInitData;
}
However, the third and fourth fields in its typehash are declared as address collectModule and bytes collectModuleInitData instead:
bytes32 constant POST = keccak256('Post(uint256 profileId,string contentURI,address collectModule,bytes collectModuleInitData,address referenceModule,bytes referenceModuleInitData,uint256 nonce,uint256 deadline)');
This occurs for the commentWithSig() and quoteWithSig() functions as well:
bytes32 constant QUOTE = keccak256('Quote(uint256 profileId,string contentURI,uint256 pointedProfileId,uint256 pointedPubId,uint256[] referrerProfileIds,uint256[] referrerPubIds,bytes referenceModuleData,address collectModule,bytes collectModuleInitData,address referenceModule,bytes referenceModuleInitData,uint256 nonce,uint256 deadline)');
bytes32 constant COMMENT = keccak256('Comment(uint256 profileId,string contentURI,uint256 pointedProfileId,uint256 pointedPubId,uint256[] referrerProfileIds,uint256[] referrerPubIds,bytes referenceModuleData,address collectModule,bytes collectModuleInitData,address referenceModule,bytes referenceModuleInitData,uint256 nonce,uint256 deadline)');
The fourth and fifth fields in the MirrorParams struct (which is used for mirrorWithSig()) are declared as referrerProfileIds and referrerPubIds:
struct MirrorParams {
uint256 profileId;
uint256 pointedProfileId;
uint256 pointedPubId;
uint256[] referrerProfileIds;
uint256[] referrerPubIds;
bytes referenceModuleData;
}
However, its EIP-712 typehash declares these fields as referrerProfileId and referrerPubId instead:
bytes32 constant MIRROR = keccak256('Mirror(uint256 profileId,uint256 pointedProfileId,uint256 pointedPubId,uint256[] referrerProfileId,uint256[] referrerPubId,bytes referenceModuleData,uint256 nonce,uint256 deadline)');
Impact
Due to the use of incorrect typehashes, the signature verification in the functions listed above is not EIP-712 compliant.
Contracts or dapps/backends that use “correct” typehashes that match the parameters of these functions will end up generating different signatures, causing them to revert when called.
Recommended Mitigation
Amend the typehashes shown above to have matching parameters with their respective functions.
Assessed type
Error
donosonaumczuk (Lens) disagreed with severity and commented:
We accept it, but we consider it Low severity instead. “Assets are not at risk, function incorrect as to spec”.
Keeping this under Medium severity as this breaks the EIP712 compliance, so can be seen as an instance of “function of the protocol or its availability could be impacted”
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A medium-severity crypto bug in Lens Protocol V2. Code4rena made it public on 11 December 2023. Found in the 2023-07-lens audit contest (finding M-07), also found by 1 other warden.
About Crypto
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.