There are 4 instances of this issue:
https://github.com/code-423n4/2023-09-maia/blob/f5ba4de628836b2a29f9b5fff59499690008c463/src/BranchPort.sol#L362C1-L380C1
Lets look at the execution path of how strategy tokens are managed:
Root chain to EP: manageStrategyToken => callOut => _performCall => send
EP to Branch chain: receivePayload => lzReceive => lzReceiveNonBlocking => _execute => executeNoSettlement (Executor) => executeNoSettlement (Router) => _manageStrategyToken => either toggleStrategyToken or addStrategyToken
As we can see in the chain of calls above, when toggling off a strategy token, we reach the function toggleStrategyToken(), which toggles of the token as below:
Now, when we try to toggle it back on, according to the chain of calls, we reach the function addStrategyToken(), which does the following:
https://github.com/code-423n4/2023-09-maia/blob/f5ba4de628836b2a29f9b5fff59499690008c463/src/BranchPort.sol#L382C1-L401C1
Lets look at the execution path of how Port Strategies are managed:
Root chain to EP: managePortStrategy() => callOut => _performCall => send
EP to Branch chain: receivePayload => lzReceive => lzReceiveNonBlocking => _execute => executeNoSettlement (Executor) => executeNoSettlement (Router) => _managePortStrategy => either addPortStrategy or togglePortStrategy (excluding updatePortStrategy since its not important here).
As we can see in the chain of calls above, when toggling off a port strategy, we reach the function togglePortStrategy(), which toggles of the strategy as below:
Now, when we try to toggle it back on, according to the chain of calls, we reach the function addPortStrategy(), which does the following:
https://github.com/code-423n4/2023-09-maia/blob/f5ba4de628836b2a29f9b5fff59499690008c463/src/BranchPort.sol#L414C1-L424C6
Lets look at the execution path of how a Core Branch Router is set:
Root chain to EP: setCoreBranch() => callOut => _performCall => send
EP to Branch chain: receivePayload => lzReceive => lzReceiveNonBlocking => _execute => executeNoSettlement (Executor) => executeNoSettlement (Router) => setCoreBranchRouter (Port)
As we can see in the chain of calls above, when setting a Core Branch Router, we reach the function setCoreBranchRouter(), which does the following:
The mitigation is below for the above error (check added on Line 425 to prevent resetting to the same router address again):
Lets look at the execution path of how Bridge Agent Factories are managed:
Root chain to EP: toggleBranchBridgeAgentFactory() => callOut => _performCall => send
EP to Branch chain: receivePayload => lzReceive => lzReceiveNonBlocking => _execute => executeNoSettlement (Executor) => executeNoSettlement (Router) => _toggleBranchBridgeAgentFactory => either toggleBridgeAgentFactory or addBridgeAgentFactory
As we can see in the chain of calls above, when toggling off a branch bridge agent factory, we reach the function toggleBridgeAgentFactory(), which toggles of the bridge agent factory as below:
Now, when we try to toggle it back on, according to the chain of calls, we reach the function addBridgeAgentFactory(), which does the following:
