code4rena-2023-01-biconomy-m04
[M-04] Methods used by EntryPoint has onlyOwner modifier
Summary
onlyOwner modifier를 붙여 EntryPoint가 SmartAccount.execute 와 SmartAccount.executeBatch 함수를 호출할 수 없다.
Keyword
access control, modifier, onlyOwner, bug
Vulnerability
- contracts/smart-contract-wallet/SmartAccount.sol#L460-L461
- contracts/smart-contract-wallet/SmartAccount.sol#L465-L466
execute와 executeBatch 함수는 onlyOwner modifier가 붙어 Owner만 호출 가능하다. 또한 코드상에서 다시 한 번 _requireFromEntryPointOrOwner(); 를 확인한다.
function execute(address dest, uint value, bytes calldata func) external onlyOwner{
_requireFromEntryPointOrOwner();
_call(dest, value, func);
}
function executeBatch(address[] calldata dest, bytes[] calldata func) external onlyOwner{
_requireFromEntryPointOrOwner();
require(dest.length == func.length, "wrong array lengths");
for (uint i = 0; i < dest.length;) {
_call(dest[i], 0, func[i]);
unchecked {
++i;
}
}
}
function _requireFromEntryPointOrOwner() internal view {
require(msg.sender == address(entryPoint()) || msg.sender == owner, "account: not Owner or EntryPoint");
}대체 어느 쪽이 맞는가? Owner만 호출해야 하는가? EntryPoint도 호출이 가능해야 하는가? 코드상의 모호함이 있다.
ERC4337 스펙에 따르면, execute 와 executeBatch 함수는 EntryPoint로부터 호출이 가능해야 한다. 스펙에서는 Bundler → EntryPoint → Account 의 execute 의 흐름으로 Account에게 콜을 요청해야 한다고 명시한다.
![]()
출처: https://eips.ethereum.org/EIPS/eip-4337
Call the account with the UserOperation’s calldata. It’s up to the account to choose how to parse the calldata; an expected workflow is for the account to have an execute function that parses the remaining calldata as a series of one or more calls that the account should make.
실제 구현에서는 onlyOwner modifier를 붙였기에 execute 와 executeBatch 함수를 EntryPoint에서 호출할 수 없다. 이는 구현상의 오류이며 컨트랙트가 제대로 기능하지 못하도록 한다.
Impact
EntryPoint를 통한 컨트랙트콜이 동작하지 않는다.
Mitigation
execute 와 executeBatch 함수에서 onlyOwner modifier를 삭제한다.
Memo
이 정도면 시스템이 동작하지 않는 치명적인 버그같은데 왜 심각도가 Medium인지 모르겠다. 취약점이라기보단 버그라서?
tags: bughunting, smart contract, biconomy, account abstraction, erc4337, access control vulnerability, ownable, wallet, severity medium