Platform: Code4rena
Start Date: 01/08/2023
Pot Size: $91,500 USDC
Total HM: 14
Participants: 80
Period: 6 days
Judge: gzeon
Total Solo HM: 6
Id: 269
League: ETH
Rank: 42/80
Findings: 3
Award: $119.42
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: said
Also found by: 3docSec, HChang26, Jeiwan, SpicyMeatball, giovannidisiena, jesusrod15, oakcobalt, pep7siup
91.1886 USDC - $91.19
https://github.com/code-423n4/2023-08-goodentry/tree/main/contracts/RangeManager.sol#L100
The initRange
function in the RangeManager
contract has a vulnerability where leftover underlying assets from the tokenizable range are not properly refunded to the contract owner. This can lead to a situation where the owner's funds are stuck in the contract, and subsequent user interactions could unknowingly deposit this fund into the Lending pool in the user's favor, causing the owner to lose funds.
// Findings are labeled with '<= FOUND' // File: contracts/RangeManager.sol 95: function initRange(address tr, uint amount0, uint amount1) external onlyOwner { 96: ... 99: ASSET_1.safeIncreaseAllowance(tr, amount1); 100: TokenisableRange(tr).init(amount0, amount1); // <= FOUND: tr.init transfer leftover underlying ASSET_0 & ASSET_1 back to RangeManager contract // File: contracts/TokenisableRange.sol 134: function init(uint n0, uint n1) external { 135: ... 158: // Transfer remaining assets back to user 159: TOKEN0.token.safeTransfer(msg.sender, TOKEN0.token.balanceOf(address(this))); // <= FOUND 160: TOKEN1.token.safeTransfer(msg.sender, TOKEN1.token.balanceOf(address(this))); // <= FOUND 161: _mint(msg.sender, 1e18); 162: emit Deposit(msg.sender, 1e18); 163: ...
RangeManager
contract uses the initRange
function to initialize a tokenizable range (TokenisableRange
contract).tr
contract transfers leftover underlying assets back to the RangeManager
in its init
function.initRange
function attempts to transfer the minted TR balance to the owner's address.RangeManager
cleanup
function, can deposit the owner's leftover funds to the Lending pool in the user's favor.Manual review
Update the initRange
function to ensure that leftover underlying assets in the RangeManager
contract are properly refunded to the contract owner.
Other
#0 - c4-pre-sort
2023-08-10T07:27:32Z
141345 marked the issue as duplicate of #390
#1 - c4-pre-sort
2023-08-10T13:27:30Z
141345 marked the issue as duplicate of #254
#2 - c4-judge
2023-08-20T17:37:02Z
gzeon-c4 marked the issue as satisfactory
🌟 Selected for report: dd0x7e8
Also found by: Bughunter101, Fulum, Kaysoft, MatricksDeCoder, SanketKogekar, Sathish9098, T1MOH, Udsen, debo, fatherOfBlocks, grearlake, hpsb, j4ld1na, josephdara, parsely, pep7siup, piyushshukla, ravikiranweb3, shirochan
12.8772 USDC - $12.88
https://github.com/code-423n4/2023-08-goodentry/tree/main/contracts/helper/V3Proxy.sol#L156 https://github.com/code-423n4/2023-08-goodentry/tree/main/contracts/helper/V3Proxy.sol#L174 https://github.com/code-423n4/2023-08-goodentry/tree/main/contracts/helper/V3Proxy.sol#L192
The swapETHForExactTokens
, swapTokensForExactETH
, and swapExactTokensForETH
functions in the V3Proxy
contract have a vulnerability where the return value of low-level calls is ignored. If a transaction fails during the call to refund unused ETH back to the user, the ETH is not refunded, resulting in a potential loss of funds for the user. This situation could arise due to various reasons, such as out-of-gas errors or contract reverts. In such cases, the user's ETH would not be refunded, leading to a financial loss.
swapETHForExactTokens
, swapTokensForExactETH
, or swapExactTokensForETH
).Manual review
Check the return value of the low-level call that refunds unused ETH to the user. If the low-level call fails, the contract should revert the transaction and emit an error message indicating that the refund failed.
ETH-Transfer
#0 - c4-pre-sort
2023-08-09T02:05:51Z
141345 marked the issue as duplicate of #481
#1 - c4-pre-sort
2023-08-09T09:26:10Z
141345 marked the issue as duplicate of #83
#2 - c4-judge
2023-08-20T17:11:36Z
gzeon-c4 marked the issue as satisfactory
🌟 Selected for report: Team_FliBit
Also found by: 0x70C9, 3docSec, 8olidity, DavidGiladi, Krace, LokiThe5th, Rolezn, Sathish9098, UniversalCrypto, banpaleo5, catellatech, digitizeworx, fatherOfBlocks, hpsb, j4ld1na, josephdara, kutugu, niser93, nonseodion, oakcobalt, osmanozdemir1, pep7siup, ravikiranweb3, said, sivanesh_808
15.3494 USDC - $15.35
https://github.com/code-423n4/2023-08-goodentry/blob/main/contracts/PositionManager/OptionsPositionManager.sol#L236-L239 https://github.com/code-423n4/2023-08-goodentry/tree/main/contracts/PositionManager/OptionsPositionManager.sol#L310
In the OptionsPositionManager
contract, there is a vulnerability related to the treatment of excess repayment amount when closing a user's position. The contract does not take into account the final amount repaid from the LP.repay
function (Line 310), potentially leading to an excess amount of debt remaining in the contract. This issue could result in a loss of user funds.
function close(...) external { ... debt = closeDebt(poolId, user, debtAsset, debt, collateralAsset); cleanup(LP, user, token0); // <= Found cleanup(LP, user, token1); // <= Found } function closeDebt(...) internal returns (uint debt) { ... if (user != address(this) ) LP.repay( debtAsset, debt, 2, user); // <= Found }
In the scenario where a user tries to repay with an over-estimated amount of debt, the excess TR amount is stuck in the OptionsPositionManager contract. OptionsPositionManager.close
function, in charge of asset refunding, does not do its task properly (Line 238-239). It only refund Token0 and Token1, not takes care of potential TR debt. This can lead to a situation where the contract holds an excess amount of debt, which is not accounted for.
Manual review
Record the actual repaid amount from the LP.repay
function and adjust the user's debt accordingly. Additionally, the excess amount that is not refunded should be accounted for and properly handled in the OptionsPositionManager.close
function.
Other
#0 - 141345
2023-08-10T08:05:07Z
user's own input
QA might be more appropriate.
#1 - c4-sponsor
2023-08-15T01:27:54Z
Keref marked the issue as sponsor confirmed
#2 - Keref
2023-08-15T01:28:22Z
Dunno if high risk since it's dust but anyway should cleanup
#3 - Keref
2023-08-18T05:49:10Z
See PR#8
#4 - c4-judge
2023-08-19T14:20:54Z
gzeon-c4 changed the severity to QA (Quality Assurance)
#5 - gzeon-c4
2023-08-19T14:21:14Z
Require user error -> low risk.
#6 - c4-judge
2023-08-20T16:40:04Z
gzeon-c4 marked the issue as grade-b