SubAccount operator can steal funds via the gas refund mechanism
The trusted validator signatures did not cover the gas refund parameters of a Gnosis Safe transaction, so a SubAccount operator could set them to send the Safe's Ether or ERC-20 tokens to themselves. The operator could therefore steal funds held in the SubAccount.
Taylor_Webb Follow with ladboy233
Originally disclosed on Code4rena
Submitted by Taylor_Webb, also found by ladboy233
The SubAccount operator can steal funds from the SubAccount Gnosis Safe via the Gnosis Safe gas refund mechanism, since the trusted validator signatures do not include the following parameters that are included in the Safe.sol execTransaction function:
uint256 safeTxGasuint256 baseGasuint256 gasPriceaddress gasTokenaddress payable refundReceiver
This allows the operator to call execTransaction with these parameters set to send all the Ether or a chosen ERC-20 token held in the SubAccount Gnosis Safe to the operator’s address.
Proof of Concept
One of the operators, who is an owner on the SubAccount Gnosis Safe, calls execTransaction on the Gnosis Safe with valid to, value, data, operation, and signatures parameters which is allowed by the current policy configured on the SubAccount, and therefore the trusted validator will also sign.
However, the operator will also populate execTransaction function parameters related to gas refunds (safeTxGas, baseGas, gasPrice, gasToken and refundReceiver), to values that transfer to themselves Ether or ERC-20 tokens held in the SubAccount Gnosis Safe.
The transaction is executed, and in the handlePayment function call within the Gnosis Safe execution, the Ether or ERC-20 tokens will be transferred to the address the operator specified in the refundReceiver parameter.
Recommended Mitigation Steps
Include the safeTxGas, baseGas, gasPrice, gasToken and refundReceiver parameters of the transaction in the trusted validated signature that is verified.
Assessed type
Invalid Validation
0xad1onchain (Brahma) confirmed via duplicate Issue #484
0xsomeone (judge) decreased severity to Medium and commented:
The Warden has demonstrated a potential avenue via which the
SafeModeratorsecurity checks in relation to the interaction performed can be “bypassed”. Effectively, operators of the sub-account can extract any funds held by the sub-account by taking advantage of the gas refund mechanism.Given that the price-per-gas unit can be arbitrarily specified, a minuscule waste of gas can result in a significant amount of funds being extracted. This particular avenue also bypasses the
SafeModeratorsecurity checks.As such, the Warden has showcased a way to actively affect funds within a sub-account that is not intended behaviour by the Sponsor.
0xad1onchain (Brahma) commented:
Fixed, added missing params to transaction validation struct.
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 trusted validator signature did not include the gas refund parameters (safeTxGas, baseGas, gasPrice, gasToken, refundReceiver) that the Safe uses to pay for gas, so an operator could set them arbitrarily.
Impact
The operator could steal all Ether or a chosen ERC-20 token held in the SubAccount, bypassing the SafeModerator security checks.
What the attacker needed
Be an operator/owner of the SubAccount Safe; the SubAccount holds Ether or ERC-20 tokens
The fix
The missing gas refund parameters were added to the transaction validation struct so they are covered by the trusted signature.
How it was found
- The operator calls execTransaction with valid to, value, data, operation and signatures that the policy allows, so the trusted validator signs.
- The operator also sets the gas refund parameters to values that transfer Ether or ERC-20 tokens to themselves.
- The transaction executes and the Safe's handlePayment function transfers the funds to the operator's chosen refundReceiver address.
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.
A SubAccount is a shared wallet (a Gnosis Safe) where several people can approve transactions. One of those people, the operator, found that the approval check ignored some extra settings about paying back gas costs. By changing those settings, the operator could make the wallet pay them a large amount of its own money or tokens.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.