Skip to content
Business logic Audit finding Beginner

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.

0xlmanini Follow with Brenzee, T1MOH and 7 others

Originally disclosed on Sherlock

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.

Solidity
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

https://github.com/sherlock-audit/2023-04-jojo/blob/main/smart-contract-EVM/contracts/subaccount/Subaccount.sol#L45-L58

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

The original report as published on Sherlock, by 0xlmanini. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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.

More from JOJO Exchange

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.