-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FeeWrapper fails to handle ETH payment refunds #1301
Comments
0xSorryNotSorry marked the issue as high quality report |
0xSorryNotSorry marked the issue as duplicate of #1283 |
HickupHH3 marked the issue as not a duplicate |
Core issue is that the fee wrapper lacks functionality to handle refunds in general, whether in ETH or ERC20. Specifically, for ETH, lacking Generally, I would've considered this to be M severity because it's conditional on the target contract sending back funds. However, the fee wrapper is expected to interact with the Rubicon contracts, which the warden has shown to have the ability send back funds. Hence, the H severity is justified. |
HickupHH3 changed the severity to 3 (High Risk) |
HickupHH3 marked the issue as duplicate of #1283 |
HickupHH3 marked the issue as selected for report |
Lines of code
https://github.com/code-423n4/2023-04-rubicon/blob/main/contracts/utilities/FeeWrapper.sol#L8
Vulnerability details
Impact
The FeeWrapper contract can be used to wrap calls that include ETH payments. This is handled by the
_rubicallPayable
function:https://github.com/code-423n4/2023-04-rubicon/blob/main/contracts/utilities/FeeWrapper.sol#L76-L89
As we can see in the previous snippet, the implementation will forward the ETH payment (minus fees) to the target contract. If the target contract ends up using less ETH than the sent amount, then the usual approach would be to refund the remaining ETH back to the caller, which is a normal and common operation.
If this is the case, then the wrapped call will fail as the FeeWrapper doesn't implement the
receive
orfallback
function to allow ETH payments. Even though there is no loss of funds as the transaction is reverted, the issue will prevent users from wrapping calls to target contracts that may refund ETH as part of their normal behavior.As a potential real example, we can the explore the
buyAllAmountWithETH
function present in theRubiconRouter
contract:https://github.com/RubiconDeFi/rubi-protocol-v2/blob/master/contracts/utilities/RubiconRouter.sol#L379-L418
As we can see in the previous snippet, the function will potentially refund the caller the unspent ETH in lines 412-417. If this call is being wrapped using the FeeWrapper, then
msg.sender
will be the FeeWrapper contract.Proof of Concept
In the following test we create a demonstration contract
FeeWrapperTarget
which includes a function nameddemoETH
that will refund half of the sent amount back to the caller. The wrapped call will fail, as theFeeWrapperTarget
will try to refund the ETH to theFeeWrapper
which doesn't allow ETH payments, causing the whole transaction to be reverted.Note: the snippet shows only the relevant code for the test. Full test file can be found here.
Recommendation
Allow the FeeWrapper contract to receive ETH by implementing the
receive
function. After the call to the target contract, refund any ETH amount present in the FeeWrapper contract back to the original caller.The text was updated successfully, but these errors were encountered: