Sturdy contest - 0xf15ers's results

The first protocol for interest-free borrowing and high yield lending.

General Information

Platform: Code4rena

Start Date: 13/05/2022

Pot Size: $30,000 USDC

Total HM: 8

Participants: 65

Period: 3 days

Judge: hickuphh3

Total Solo HM: 1

Id: 125

League: ETH

Sturdy

Findings Distribution

Researcher Performance

Rank: 27/65

Findings: 3

Award: $86.25

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Awards

14.8433 USDC - $14.84

Labels

bug
duplicate
3 (High Risk)
disagree with severity

External Links

Lines of code

https://github.com/code-423n4/2022-05-sturdy/blob/78f51a7a74ebe8adfd055bdbaedfddc05632566f/smart-contracts/LidoVault.sol#L141-L142

Vulnerability details

Title

ETH transefer is not checked properly

Impact

Function will return successfully even if the transfer of ETH failed

Proof of Concept

in smart-contracts/LidoVault.sol#L141-L142 the function returns before checking that the ETH is sent properly. This may cause the function successfully returning even if the ETH transfer failed and eventually causes fund loss for the user.

Tools Used

Manual Analysis

Check that the ETH transfer is successful before function returns

      // Before
      return receivedETHAmount;
      require(sent, Errors.VT_COLLATERAL_WITHDRAW_INVALID);

      // After
      require(sent, Errors.VT_COLLATERAL_WITHDRAW_INVALID);
      return receivedETHAmount;

#0 - sforman2000

2022-05-18T01:32:38Z

1. Event DepositCollateral uses _amount as parameter which may be wrong while depositing ether

in smart-contracts/GeneralVault.sol#L88 the event DepositCollateral uses _amount as parameter which may be wrong. For eg. in case of depositing ETH (implementation in smart-contracts/LidoVault.sol#L79-L104) the actual amount is taken from msg.value rather than user provided _amount. This will lead to reporting a false amount in the Events if the user calls the function with different _amount than the amount of ETH provided(i.e. msg.value).

use _stAssetAmount in the event rather than _amount to use correct avount of asset recieved in the function. Also use stAsset instead of _asset to be sure the actual asset deposited is being reported.

 emit DepositCollateral(_stAsset, msg.sender, _stAssetAmount);

The event WithdrawCollateral is also called with _amount in smart-contracts/GeneralVault.sol#L127 which is correct for now across all implementations, but its better to change it to _stAssetAmount to make sure it stays correct for future implementations too.

#0 - HickupHH3

2022-06-06T06:42:22Z

low severity

Awards

24.3601 USDC - $24.36

Labels

bug
G (Gas Optimization)

External Links

1. checking a != 0 is cheaper than a > 0 for uint

2. Prefix increment can be used in loops instead of postfix increment as it is cheaper

  // Before
            for (uint256 i = 0; i < _count; i++) {
                    ......
        }
  // After
        for (uint256 i = 0; i < _count; ++i) {
        }

3. Data.length is calculated for each iteration in loop, this can be cached to save gas

  // Before
        for (uint256 i = 0; i < assetYields.length; i++) {
            ...
        }
  // After
        uint len = assetYields.length;
        for (uint256 i = 0; i < len; ++i) {
        }
AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax Β© 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter