Description:Description\
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 string. This may cause some problems on the DApp side and even lead to data loss. For more information about the indexed events, check here:
The problem exists inside the Penrose contract. The event ProtocolWithdrawal is defined in such a way that the dynamical array of IMarkets is indexed. With doing so, the expected parameters wouldn't be emitted properly and front-end would get meaningless one-way hashes.
Attachments
Proof of Concept (PoC) File
Consider this scenario as an example:
1 - The function withdrawAllMarketFees() is called by the owner
2 - Inside the function withdrawAllMarketFees() we expect to see the the array of "IMarkets":
function withdrawAllMarketFees(IMarket[] calldata markets_, ITwTap twTap) external onlyOwner notPaused {
if (address(twTap) == address(0)) revert ZeroAddress();
uint256 length = markets_.length;
unchecked {
for (uint256 i; i < length;) {
_depositFeesToTwTap(markets_[i], twTap);
++i;
}
}
emit ProtocolWithdrawal(markets_, block.timestamp);
}
3 - 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 symbol of the token would be lost in the DApp.
Github username: @MatinR1 Twitter username: MatinRezaii1 Submission hash (on-chain): 0xa5d3c41c908b75f7ae9a660281a4330a0e74ed0e31bef7ffebb42e3671eb5961 Severity: medium
Description: Description\ 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 string. 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
Penrose
contract. The eventProtocolWithdrawal
is defined in such a way that the dynamical array of IMarkets is indexed. With doing so, the expected parameters wouldn't be emitted properly and front-end would get meaningless one-way hashes.Attachments
Consider this scenario as an example:
1 - The function
withdrawAllMarketFees()
is called by the owner2 - Inside the function
withdrawAllMarketFees()
we expect to see the the array of "IMarkets":3 - 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 symbol of the token would be lost in the DApp.
For test purpose one can run this test file:
Outputs of test:
ProtocolWithdrawal:
ProtocolWithdrawal1:
As you can see, the intended outputs wouldn't be emitted if the
indexed
keyword is used for IMarkets[].Consider modifying the event
ProtocolWithdrawal
inside the contractPenrose
: