initialize function in L2GraphToken.sol, BridgeEscrow.sol, L2GraphTokenGateway.sol, L1GraphTokenGateway.sol can be invoked multiple times from the implementation contract. #149
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
edited-by-warden
resolved
Finding has been patched by sponsor (sponsor pls link to PR containing fix)
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2022-10-thegraph/blob/309a188f7215fa42c745b136357702400f91b4ff/contracts/l2/gateway/L2GraphTokenGateway.sol#L87
https://github.com/code-423n4/2022-10-thegraph/blob/309a188f7215fa42c745b136357702400f91b4ff/contracts/l2/token/L2GraphToken.sol#L48
https://github.com/code-423n4/2022-10-thegraph/blob/309a188f7215fa42c745b136357702400f91b4ff/contracts/gateway/L1GraphTokenGateway.sol#L99
https://github.com/code-423n4/2022-10-thegraph/blob/309a188f7215fa42c745b136357702400f91b4ff/contracts/gateway/BridgeEscrow.sol#L20
Vulnerability details
Impact
initialize function in L2GraphToken.sol, BridgeEscrow.sol, L2GraphTokenGateway.sol, L1GraphTokenGateway.sol
can be invoked multiple times from the implementation contract.
this means a compromised implementation can reinitialize the contract above and
become the owner to complete the privilege escalation then drain the user's fund.
Usually in Upgradeable contract, a initialize function is protected by the modifier
to make sure the contract can only be initialized once.
Proof of Concept
Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.
The implementation contract is compromised,
The attacker reinitialize the BridgeEscrow contract
the onlyGovernor modifier's result depends on the controller because
The attacker have the governor access to the BridgeEscrow,
The attack can call the approve function to approve malicious contract
Tools Used
Manual Review
Recommended Mitigation Steps
We recommend the project use the modifier
to protect the initialize function from being reinitiated
The text was updated successfully, but these errors were encountered: