A critical vulnerability exists in the NativeMetaTransaction
contract's executeMetaTransaction()
function. This vulnerability permits manipulation of calldata, which can result in unauthorized function calls and bypass security measures due to unsafe handling of user-supplied function signatures and improper calldata concatenation.
This vulnerability allows attackers to make unauthorized or unintended function calls within the smart contract, potentially leading to undesired actions or the exposure of sensitive data. The vulnerability occurs because of unvalidated and improperly encoded inputs in the following code:
Key points of the vulnerability include:
Unvalidated User Input: The functionSignature parameter is used without validation in a low-level .call().
Insecure Data Encoding: abi.encodePacked() is used, which may yield unpredictable results with dynamic types.
Lack of Function Signature Verification: The length and format of functionSignature are not verified.
Unsafe Address Concatenation: Concatenating userAddress without encoding safeguards adds further manipulation risks.
Actors
Attacker: A malicious actor seeking to exploit the arbitrary call vulnerability.
Victim: Contract owners or users impacted by unauthorized function executions.
Protocol: The platform within which the NativeMetaTransaction contract operates, potentially allowing function calls outside the intended scope.
Exploit Scenario
Initial State: The vulnerability exists within the executeMetaTransaction() function due to unvalidated inputs and improper encoding.
Step-by-Step Exploit Description:
Step 1: The attacker initiates an arbitrary call by supplying a malicious functionSignature.
Step 2: The attacker exploits the abi.encodePacked() encoding to craft calldata that bypasses normal access controls.
Step 3: Through the manipulated calldata, the attacker can perform unintended function calls.
Outcome: This can lead to unauthorized actions, such as unauthorized fund transfers or exposing sensitive contract functions.
The vulnerability has serious consequences, including:
Control Flow Manipulation: Unauthorized function executions and bypassed access control.
Asset Security: Potential unauthorized access to contract-held funds, leading to financial loss.
Protocol Security: Exposure of the meta-transaction infrastructure to replay attacks and tampered transactions.
Manual code review
slitherin . --pess
Enforce Signature Validation: Validate the length of functionSignature
to prevent malformed inputs:
Replace abi.encodePacked()
with abi.encode()
:
Add function selector whitelist:
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.