The NativeMetaTransaction
contract is vulnerable to replay attacks across different contracts or chains due to the lack of unique identifiers for each contract or chain within the hashMetaTransaction
calculation.
The replay attack vulnerability arises because the contract does not include a unique identifier, such as chainId
or the contract's address, in the meta-transaction hash calculation. Without these identifiers, a meta-transaction executed on one chain or contract can be replayed on other compatible chains or contracts, assuming they use the same MetaTransaction
structure and hashMetaTransaction
function.
This vulnerability breaks the guarantee of transaction uniqueness, as a malicious user could reuse a single meta-transaction across various compatible deployments. For example, if MetaTransaction
data is identical between two chains or contracts, the transaction could be re-executed on a different chain or contract than originally intended.
The vulnerable function in the contract is hashMetaTransaction
, which currently only includes the nonce
, from
address, and functionSignature
. Without additional unique identifiers, this hash is not tied specifically to the contract or chain it was created for, allowing for unintended reuse across deployments.
This vulnerability has a high impact because it can compromise the security of the contract by enabling unauthorized replay of transactions on multiple chains or contract instances. This could lead to double-spending issues or other unintended outcomes, affecting both the integrity of the application and user funds.
Consider the following scenario:
A user signs a meta-transaction on Chain A using the NativeMetaTransaction
contract instance.
Without a unique identifier, this signed transaction can be reused by a malicious actor on Chain B, where an identical contract instance is deployed.
This is possible because the hashMetaTransaction
function generates the same hash on both chains, as it lacks any chain-specific information.
To prevent replay attacks, include chainId
or the contract's address in the hashMetaTransaction
function. This addition will make the hash calculation unique to the chain or contract instance, preventing the transaction from being reused elsewhere.
Add chainId
and/or address(this)
to hashMetaTransaction
as shown below:
This modification will ensure that the hash is unique to both the contract and the chain, effectively mitigating replay attacks.
NativeMetaTransaction.sol
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.