Incorrect Constraint in SetPeer Hinders Admin Updates During Peer Changes
Summary
An admin cannot update the dst_eid to a new peer address via the set_peer function due to the incorrect use of the init constraint on the peer account.
Root Cause
In cases of misconfigurations or code bugs, the destination chain may switch to a new peer or SolConnector. When this happens, the set_peer function is intended to be called by the admin to update the dst_eid to the new peer address. However, because init is used, the call will always fail as it attempts to reinitialize an already initialized account, making it impossible to update the peer address.
Internal Preconditions
None
External Preconditions
None
Attack Path
None
Impact
If the dst_eid peer changes, it will be impossible to switch to the new peer.
Sunny Syrup Worm
Medium
Incorrect Constraint in SetPeer Hinders Admin Updates During Peer Changes
Summary
An admin cannot update the
dst_eid
to a new peer address via theset_peer
function due to the incorrect use of theinit
constraint on thepeer
account.Root Cause
In cases of misconfigurations or code bugs, the destination chain may switch to a new peer or SolConnector. When this happens, the
set_peer
function is intended to be called by the admin to update thedst_eid
to the new peer address. However, becauseinit
is used, the call will always fail as it attempts to reinitialize an already initialized account, making it impossible to update the peer address.Internal Preconditions
None
External Preconditions
None
Attack Path
None
Impact
If the
dst_eid
peer changes, it will be impossible to switch to the new peer.Proof of Concept (PoC)
https://github.com/sherlock-audit/2024-09-orderly-network-solana-contract/blob/a40ed80ce4a196bc81bfa6dfb749c19b92c623b0/solana-vault/packages/solana/contracts/programs/solana-vault/src/lib.rs#L100-L102
https://github.com/sherlock-audit/2024-09-orderly-network-solana-contract/blob/a40ed80ce4a196bc81bfa6dfb749c19b92c623b0/solana-vault/packages/solana/contracts/programs/solana-vault/src/lib.rs#L100-L102
Mitigation
Update
SetPeer::peer
to: