Reentrancy attack possible on RootBridgeAgent.retrySettlement()
with missing access control for RootBridgeAgentFactory.createBridgeAgent()
#492
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
H-18
primary issue
Highest quality submission among a set of duplicates
satisfactory
satisfies C4 submission criteria; eligible for awards
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/2023-05-maia/blob/main/src/ulysses-omnichain/RootBridgeAgent.sol#L244
https://github.com/code-423n4/2023-05-maia/blob/main/src/ulysses-omnichain/factories/RootBridgeAgentFactory.sol#L75
Vulnerability details
RootBridgeAgent.retrySettlement()
is lacking alock
modifier to prevent reentrancy. AndRootBridgeAgentFactory.createBridgeAgent()
is missing access control. Both issues combined allows anyone to re-enterretrySettlement()
and trigger the same settlement repeatedly.Impact
An attacker can steal funds from the protocol by executing the same settlement multiple times before it is marked as executed.
Detailed Explanation
Issue #1
In
RootBridgeAgentFactory
, the privileged functioncreateBridgeAgent()
is lacking access control, which allows anyone to deploy a newRootBridgeAgent
. Leveraging that, the attacker can inject malicious RootRouter and BranchRouter that can be used to trigger a reentrancy attack inretrySettlement()
. Injection of the malicious BranchRouter is done with a separate call toCoreRootRouter.addBranchToBridgeAgent()
in CoreRootRouter.sol#L81-L116, refer to POC for actual steps.https://github.com/code-423n4/2023-05-maia/blob/main/src/ulysses-omnichain/factories/RootBridgeAgentFactory.sol#L75C1-L89C6
Issue #2
In
RootBridgeAgent
, theretrySettlement()
function is not protected from reentrancy with thelock
modifier. We can then re-enter this function via the injected malicious BranchRouter (Issue #1). The malicious BranchRouter can be triggered viaBranchBridgeAgentExecutor
when the attacker perform the settlement call. That will executeIRouter(_router).anyExecuteSettlement()
when additional calldata is passed in as shown in BranchBridgeAgentExecutor.sol#L110.https://github.com/code-423n4/2023-05-maia/blob/main/src/ulysses-omnichain/RootBridgeAgent.sol#L244-L252
Proof of Concept
RootTest.t.sol
.RootTest
contract withinRootTest.t.sol
.Recommended Mitigation Steps
Add
lock
modifier toRootBridgeAgent.retrySettlement()
and add access control toRootBridgeAgentFactory.createBridgeAgent()
.Assessed type
Other
The text was updated successfully, but these errors were encountered: