The Graph L2 bridge contest - csanuragjain's results

A protocol for indexing and querying blockchain data.

General Information

Platform: Code4rena

Start Date: 07/10/2022

Pot Size: $50,000 USDC

Total HM: 4

Participants: 62

Period: 5 days

Judge: 0xean

Total Solo HM: 2

Id: 169

League: ETH

The Graph

Findings Distribution

Researcher Performance

Rank: 3/62

Findings: 1

Award: $4,328.22

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: ladboy233

Also found by: csanuragjain

Labels

bug
duplicate
2 (Med Risk)

Awards

4328.2206 USDC - $4,328.22

External Links

Lines of code

https://github.com/code-423n4/2022-10-thegraph/blob/main/contracts/gateway/BridgeEscrow.sol#L21

Vulnerability details

Impact

The implementation contract can initialize the _controller address multiple times on Managed contract even though it should only be allowed once. Ideally only existing controller should be allowed to decide the new controller but this can be used to bypass the controller power.

Changing controller should only be allowed via setController function

Proof of Concept

  1. Observe the initialize function
function initialize(address _controller) external onlyImpl { Managed._initialize(_controller); }
  1. As we can see the Implementation contract can call this multiple time in order to change the controller via Managed._initialize(_controller);
function _initialize(address _controller) internal { _setController(_controller); } function _setController(address _controller) internal { require(_controller != address(0), "Controller must be set"); controller = IController(_controller); emit SetController(_controller); }
  1. As we can see that this is giving the power to implementation contract to change the controller using _setController function when ideally _setController should only be allowed to be called through current controller via setController function. This could be used to bypass current controller and set a new controller without consent from existing controller
function setController(address _controller) external onlyController { _setController(_controller); }

Use the initializer modifier on the initialize function making it callable once only

#0 - trust1995

2022-10-16T00:44:40Z

Dup of #149 . Precondition likely too much of a stretch for a M finding, although definitely worth fixing.

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