Connext Amarok contest - Lambda's results

The interoperability protocol of L2 Ethereum.

General Information

Platform: Code4rena

Start Date: 08/06/2022

Pot Size: $115,000 USDC

Total HM: 26

Participants: 72

Period: 11 days

Judge: leastwood

Total Solo HM: 14

Id: 132

League: ETH

Connext

Findings Distribution

Researcher Performance

Rank: 23/72

Findings: 3

Award: $482.61

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: GimelSec

Also found by: Czar102, Lambda, csanuragjain, minhquanym, shenwilly

Labels

bug
duplicate
2 (Med Risk)

Awards

255.6947 USDC - $255.69

External Links

Lines of code

https://github.com/code-423n4/2022-06-connext/blob/main/contracts/contracts/core/connext/libraries/LibDiamond.sol#L88

Vulnerability details

Impact

In LibDiamond.sol#L88, acceptanceTimes of a _diamondCut is set to 0. Then, in #L101, it is checked that this value is smaller than block.timestamp. While this check works when the diamond is in the proposal period, it will always succeed for a rescinded diamond cut (with acceptance time 0), meaning the acceptance period can be trivially circumvented.

Set acceptanceTimes to type(uint256).max when rescinding.

#0 - LayneHaber

2022-06-24T16:34:13Z

Duplicate of #98

#1 - 0xleastwood

2022-08-15T07:58:36Z

Duplicate of #215.

Possible to set RouterOwner to 0 without proposal period

Lines of code

https://github.com/code-423n4/2022-06-connext/blob/main/contracts/contracts/core/connext/facets/RoutersFacet.sol#L434

Vulnerability details

Impact

In RoutersFacet.sol#L434, it is checked if the proposal period has passed. However, it is possible for the owner to set a new owner without waiting for the delay. When proposedRouterTimestamp and proposedRouterOwners are 0 for a given router (i.e., uninitialized), the owner can call acceptProposedRouterOwner (because onlyProposedRouterOwner accepts calls by the owner in such a scenario) and immediately set the owner to 0.

Check proposedRouterTimestamp is 0.

#0 - jakekidd

2022-06-25T02:19:44Z

  • onlyProposedRouterOwner can call this method, so unless you are the owner or somehow control address(0), it will revert.
  • Routers are managed by their operators. The proposal window is intended to delay transfers of ownership from one EOA to another.
  • The described issue basically just amounts to the owner being able to revoke their ownership instantly. I'm going to leave this as acknowledged because it's technically true, but doesn't create any sort of attack or griefing vector.

#1 - 0xleastwood

2022-08-15T00:20:46Z

Agree with sponsor. Routers are able to renounce ownership instantly, but this doesn't impact protocol availability nor lock funds or leak value. The router is still able to withdraw to their chosen recipient address as per usual. Downgrading to QA.

#2 - 0xleastwood

2022-08-15T00:21:09Z

Merging with #43.

#3 - 0xleastwood

2022-08-16T21:21:00Z

Converting to QA report because #43 is invalid.

In the following places, gas can be saved by caching the length of the array:

  • RelayerFacet.sol#L140
  • RelayerFacet.sol#L164

In the following places, gas can be saved by marking the addition in the loop as unchecked:

  • DiamondLoupeFacet.sol#L31
  • Encoding.sol#L22
  • Encoding.sol#L36
  • SwapUtils.sol: #L254, #L268, #L289, #L300, #L302, #L344, #L405, #L425,

In the following places, both optimizations (caching of length & unchecked) can be applied:

  • StableSwapFacet.sol#L415
  • ConnextPriceOracle.sol#L176
  • Multicall.sol#L16
  • LibDiamond.sol#L104
  • LibDiamond.sol#L129
  • LibDiamond.sol#L147
  • LibDiamond.sol#L162
  • StableSwap.sol#L81
  • SwapUtils.sol: #L205, #L558, #L591, #L844, #L869, #L924, #L1014, #L1019, #L1039, #L1055

SafeMath is used in a few places unnecessarily (not needed for Solidity v0.8):

  • ConnextPriceOracle.sol
  • OZERC20.sol
  • Amplificationutils.sol
  • SwapUtils.sol

Other gas optimizations:

  • PortalFacet.sol#L150 and PortalFacet.sol#L153: Subtractions can be unchecked, because underflow was already checked.
  • StableSwapFacet.sol#L427: The line is a NOP for i = 0 and can therefore be moved inside the if statement that checks i > 0
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