By making the event topic indexed for string type inside the MemberShipFactory contract, it would lead for wrong variable to be emitted
when the indexed keyword is used for reference type variables such as dynamic arrays or strings, it will return the hash of the mentioned variables.
Thus, the event which is supposed to inform all of the applications subscribed to its emitting transaction (e.g. front-end of the DApp, or the backend listeners to that event),would get a meaningless and obscure 32 bytes that correspond to keccak256 of an encoded dynamic array. This may cause some problems on the DApp side and even lead to data loss.
For more information about the indexed events, check here:
(https://docs.soliditylang.org/en/v0.8.17/abi-spec.html?highlight=indexed#events)
The problem exists inside the MemberShipFactory contract. The event MembershipDAONFTCreated is defined in such a way that the string variable of ensName is indexed.
The function createNewDAOMembership() is intended to create a new membership DAO NFT with the provided initialization DAO config and Tier config.
However, with the current design, the expected parameter wouldn't be emitted properly and front-end would get a meaningless one-way hash.
Consider this scenario as an example:
The function createNewDAOMembership() is called
Inside the function createNewDAOMembership() we expect to see the the string of ensName from calldata be emitted
But as the event topic is defined as indexed we'll get an obscure 32-byte hash and listeners will not be notified properly. Thus, the ensName would be lost in the DApp.
Create a BugTest.t.sol contract in the test folder.
Add the following code to the BugTest.t.sol file:
Run the test using the command forge test --mt test_FortisAudits_wrongEmit -vvvv.
MembershipDAONFTCreated_Indexed event:
MembershipDAONFTCreated_NotIndexed event:
To mitigate this issue, remove the indexed keyword from the ensName parameter in the MembershipDAONFTCreated event.
Here is the recommended mitigation:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.