DefaultAccount#fallback lack payable
The DefaultAccount contract's fallback function lacks the payable modifier, so calls with value to addresses without code fail instead of succeeding as on the mainnet. This could break existing protocols that rely on sending value with a call.
Submitted by bin2chen, also found by minaminao
Fallback lack payable,will lead to differences from the mainnet, and many existing protocols may not work.
Proof of Concept
DefaultAccount Defined as follows:
DefaultAccount
The implementation of the default account abstraction. This is the code that is used by default for all addresses that are not in kernel space and have no contract deployed on them. This address:
Contains the minimal implementation of our account abstraction protocol. Note that it supports the built-in paymaster flows.
When anyone (except bootloader) calls/delegate calls it, it behaves in the same way as a call to an EOA, i.e. it always returns success = 1, returndatasize = 0 for calls from anyone except for the bootloader.
If there is no code for the address, the DefaultAccount #fallback method will be executed, which is compatible with the behavior of the mainnet.
But at present, fallback is not payable.
The code is as follows
contract DefaultAccount is IAccount {
using TransactionHelper for *;
..
fallback() external { //<--------without payable
// fallback of default account shouldn't be called by bootloader under no circumstances
assert(msg.sender != BOOTLOADER_FORMAL_ADDRESS);
// If the contract is called directly, behave like an EOA
}
receive() external payable {
// If the contract is called directly, behave like an EOA
}
Which will lead to differences from the mainnet.
For example, the mainnet execution of the method with value will return true, and the corresponding value will be transfer but DefaultAccount.sol will return false.
It is quite common for call () to with value. If it is not compatible, many existing protocols may not work.
Mainnet code example, executing 0x0 call with value can be successful:
function test() external {
vm.deal(address(this),1000);
console.log("before value:",address(0x0).balance);
(bool result,bytes memory datas) = address(0x0).call{value:10}("abc");
console.log("call result:",result);
console.log("after value:",address(0x0).balance);
}
$ forge test -vvv
[PASS] test() (gas: 42361)
Logs:
before value: 0
call result: true
after value: 10
Simulate DefaultAccount #fallback without payable, it will fail:
contract DefaultAccount {
fallback() external {
}
receive() external payable {
}
}
function test() external {
DefaultAccount defaultAccount = new DefaultAccount();
vm.deal(address(this),1000);
console.log("before value:",address(defaultAccount).balance);
(bool result,bytes memory datas) = address(defaultAccount).call{value:10}("abc");
console.log("call result:",result);
console.log("after value:",address(defaultAccount).balance);
}
$ forge test -vvv
[PASS] test() (gas: 62533)
Logs:
before value: 0
call result: false
after value: 0
Recommended Mitigation Steps
- function test() external {
+ function test() external payable {
vm.deal(address(this),1000);
console.log("before value:",address(0x0).balance);
(bool result,bytes memory datas) = address(0x0).call{value:10}("abc");
console.log("call result:",result);
console.log("after value:",address(0x0).balance);
}
Alex the Entreprenerd (judge) commented:
The Warden has shown how, due to the lack of the
payablemodifer, contracts that sent value as well as a message would revert when triggering thefallback.While this could have been very severe for Smart Contracts, because the contract in question is for Account Abstraction, and that could break only certain transfers, I agree with Medium Severity.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The fallback function in DefaultAccount is not marked payable, so it rejects calls that include value.
Impact
Calls with value to addresses without code may fail, potentially breaking existing protocols that rely on such transfers.
What the attacker needed
None
The fix
The fallback function should be marked payable to match mainnet behaviour.
How it was found
- Deploy a contract with a non-payable fallback and a payable receive function.
- Send a call with value and data to that contract.
- Observe that the call returns false and the value is not transferred.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
On Ethereum, when you send ether to an address that has no code, the transaction succeeds and the ether is transferred. Here, a special contract used for accounts without code has a fallback function that cannot accept ether, so such transfers fail. This means some smart contracts that expect to send ether to any address might break.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.