Skip to content
This repository has been archived by the owner on Dec 17, 2023. It is now read-only.

0x8chars - msg.value can be reused multiple times #240

Closed
sherlock-admin opened this issue Jun 11, 2023 · 0 comments
Closed

0x8chars - msg.value can be reused multiple times #240

sherlock-admin opened this issue Jun 11, 2023 · 0 comments
Labels
Non-Reward This issue will not receive a payout

Comments

@sherlock-admin
Copy link
Contributor

sherlock-admin commented Jun 11, 2023

0x8chars

medium

msg.value can be reused multiple times

Summary

msg.value can be reused to take ETH that is stuck on TxBuilderExtension.sol and UniswapExtension.sol

Vulnerability Detail

Since the execute() function allows you can chain multiple function calls in a single call e.g. TxBuilderExtension.repayNativeToken() or UniswapExtension.supplyNativeToken(), you can reuse msg.value multiple times by calling these functions multiple times but only providing enough eth for a single action. This is the same vulnerability that samczsun found in sushi’s miso contracts.

Assume that there is 1 ETH stuck on the TxBuilderExtension.sol contract. A user can call execute() with the following actions [supplyNativeToken, supplyNativeToken, redeemNativeToken] and a msg.value of 1 eth. The first supplyNativeToken uses the eth that is transferred by the user. The second supplyNativeToken uses the eth that is stuck on the contract. The redeemNativeToken is used to redeem 2 ETH.

Impact

Both the TxBuilderExtension.sol and UniswapExtension.sol contracts implement the seizeNative() function to retrieve ETH that is stuck on these contracts. This function is gated by an onlyOwner() modifier. However, as a result of this vulnerability, a user is also able to bypass this restriction to retrieve the stuck funds.

Code Snippet

https://github.com/sherlock-audit/2023-05-ironbank/blob/main/ib-v2/src/extensions/TxBuilderExtension.sol#L253

https://github.com/sherlock-audit/2023-05-ironbank/blob/main/ib-v2/src/extensions/TxBuilderExtension.sol#L291

https://github.com/sherlock-audit/2023-05-ironbank/blob/main/ib-v2/src/extensions/UniswapExtension.sol#L461

Tool used

Manual Review

Recommendation

Use a local variable to track msg.value. When a function that uses msg.value is executed, subtract from this local variable instead of reusing msg.value.

Duplicate of #198

@github-actions github-actions bot added the Excluded Excluded by the judge without consulting the protocol or the senior label Jun 19, 2023
@0xffff11 0xffff11 added Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label and removed Excluded Excluded by the judge without consulting the protocol or the senior labels Jun 22, 2023
@sherlock-admin sherlock-admin added Non-Reward This issue will not receive a payout and removed Medium A valid Medium severity issue Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label labels Jun 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Non-Reward This issue will not receive a payout
Projects
None yet
Development

No branches or pull requests

2 participants