code4rena-2023-01-biconomy-m03
[M-03] Cross-Chain Signature Replay Attack
Summary
서명 대상에 chainId가 포함되지 않아 크로스 체인으로 유저 서명에 대하여 replay 공격이 가능하다.
Keyword
replay attack, signature, chain id, cross chain
Vulnerability
유저의 서명을 다른 체인에서 replay 가능하여 유저가 원하지 않은 작업을 다른 체인에서 시킬 수 있다.
ERC4337 스펙에서는 유저 서명을 타 체인에서 재활용할 수 없도록 서명에 chainId와 EntryPoint 주소를 포함해야 한다고 명시한다.
To prevent replay attacks (both cross-chain and multiple EntryPoint implementations), the signature should depend on chainid and the EntryPoint address.
하지만 실제 구현에서는 chainId가 누락되었다.
function getHash(UserOperation calldata userOp)
public pure returns (bytes32) {
//can't use userOp.hash(), since it contains also the paymasterAndData itself.
return keccak256(abi.encode(
userOp.getSender(),
userOp.nonce,
keccak256(userOp.initCode),
keccak256(userOp.callData),
userOp.callGasLimit,
userOp.verificationGasLimit,
userOp.preVerificationGas,
userOp.maxFeePerGas,
userOp.maxPriorityFeePerGas
));
}Impact
Replay 공격으로 유저가 원하지 않은 트랜잭션을 발생시킬 수 있다.
Mitigation
서명 대상 값에 chainId를 추가한다.
tags: bughunting, smart contract, biconomy, account abstraction, erc4337, replay attack, signature, chainid, cross chain, wallet, severity medium