Subaccount#execute lacks payable
The Subaccount contract's execute function is not marked payable, so it cannot receive Ether. If a caller tries to send a non-zero value, the transaction will always revert.
Source: https://github.com/sherlock-audit/2023-04-jojo-judging/issues/111
Found by
0xlmanini, Brenzee, T1MOH, ctf_sec, immeas, n1punp, nobody2018, p0wd3r, rvierdiiev, yixxas
Summary
Subaccount#execute lacks payable. If value in Subaccount#execute is not zero, it could always revert.
Vulnerability Detail
Subaccount#execute lacks payable. The caller cannot send the value.
function execute(address to, bytes calldata data, uint256 value) external onlyOwner returns (bytes memory){
require(to != address(0));
-> (bool success, bytes memory returnData) = to.call{value: value}(data);
if (!success) {
assembly {
let ptr := mload(0x40)
let size := returndatasize()
returndatacopy(ptr, 0, size)
revert(ptr, size)
}
}
emit ExecuteTransaction(owner, address(this), to, data, value);
return returnData;
}
The Subaccount contract does not implement receive() payable or fallback() payable, so it is unable to receive value (eth) . Therefore, Subaccount#execute needs to add payable.
Impact
Subaccount#execute cannot work if value != 0.
Code Snippet
Tool used
Manual Review
Recommendation
Add a receive() external payable to the contract or execute() to add a payable modifier.
Discussion
JoscelynFarr
fix link: https://github.com/JOJOexchange/smart-contract-EVM/commit/64dfd055deeae857fa99d4703cdbf7ba1291b8ad
IAm0x52
Fix looks good. execute() is now payable and value is check to make sure no ETH is left in the contract
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 execute function lacks the payable modifier and the contract has no receive or fallback payable function, so it cannot hold or forward Ether.
Impact
Subaccount#execute cannot work if value is not zero.
What the attacker needed
None
The fix
The fix was to make execute() payable and add a check to ensure no ETH is left in the contract.
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.
In Ethereum, a function must be marked 'payable' to accept Ether (the cryptocurrency). The execute function tries to send Ether to another address but cannot receive Ether itself, so any attempt to use it with a non-zero amount fails.
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.