-
Notifications
You must be signed in to change notification settings - Fork 2
0x52 - supplyNativeToken will strand ETH in contract if called after ACTION_DEFER_LIQUIDITY_CHECK #361
Comments
Confirm the issue! However, we believe the correct modification is to pass |
Valid high. I also think the fix from sponsor is most accurate. |
Passing through My suggestion would be to cache msg.value as an internal storage variable (i.e. _msgValue) at the beginning of execute. Adjust supplyNativeToken to use that storage variable rather than |
The situation mentioned is same with #192. |
No, just think they are related. |
Escalate for 10 USDC
|
You've created a valid escalation for 10 USDC! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
My two cents on iamjakethehuman 's escalation.
I would argue that this set of actions is not "too" specific. Deferring liquidity is done to avoid wasting gas by executing
I explored this possibility in my own report (#368 ), and I don't think we should just ignore the fact that the ETH stuck in the contract can be stolen. If the ETH were safe then this would just be an inconvenience until the owner comes in, but both facts together create a vector in which the user can lose their funds without virtually any cost or risk on the malicious actor's side, all due to this implementation flaw on |
Thanks for both comments. Imo this issue should be high. I agree, that it is quite likely for it to happen. ''' |
fix: ibdotxyz/ib-v2#53 |
Result: |
Escalations have been resolved successfully! Escalation status:
|
Fix looks good. Msg.value is now cached allowing it to be preserved across contexts |
0x52
high
supplyNativeToken will strand ETH in contract if called after ACTION_DEFER_LIQUIDITY_CHECK
Summary
supplyNativeToken deposits msg.value to the WETH contract. This is very problematic if it is called after ACTION_DEFER_LIQUIDITY_CHECK. Since onDeferredLiqudityCheck creates a new context msg.value will be 0 and no ETH will actually be deposited for the user, causing funds to be stranded in the contract.
Vulnerability Detail
TxBuilderExtension.sol#L252-L256
supplyNativeToken uses the context sensitive msg.value to determine how much ETH to send to convert to WETH. After ACTION_DEFER_LIQUIDITY_CHECK is called, it enters a new context in which msg.value is always 0. We can outline the execution path to see where this happens:
execute > executeInteral > deferLiquidityCheck > ironBank.deferLiquidityCheck > onDeferredLiquidityCheck (new context) > executeInternal > supplyNativeToken
When IronBank makes it's callback to TxBuilderExtension it creates a new context. Since the ETH is not sent along to this new context, msg.value will always be 0. Which will result in no ETH being deposited and the sent ether is left in the contract.
Although these funds can be recovered by the admin, it may can easily cause the user to be unfairly liquidated in the meantime since a (potentially significant) portion of their collateral hasn't been deposited. Additionally in conjunction with my other submission on ownable not being initialized correctly, the funds would be completely unrecoverable due to lack of owner.
Impact
User funds are indefinitely (potentially permanently) stuck in the contract. Users may be unfairly liquidated due to their collateral not depositing.
Code Snippet
TxBuilderExtension.sol#L252-L256
Tool used
Manual Review
Recommendation
msg.value should be cached at the beginning of the function to preserve it across contexts
The text was updated successfully, but these errors were encountered: