The function allowPacket() of NativeSwitchboards doesn't catch invalid packetIds.
Estimated to have a severity of Low because other parts of the code catch the invalid packetIds.
- Assume a
NativeSwitchboardis being used - Call function
execute()with an invalidpacketId - Function
execute()calls_verify()with the invalidpacketId packetIdRoots[packetId_]will be0- Function
_verify()callsallowPacket()with the parameters:root_ == 0andpacketId_is invalid - In function
allowPacket()thenpacketIdToRoot[packetId_]will be0 - So function
allowPacket()returnstrue - Function
_verify()continues executing while thepacketIdshould not have been allowed. - Luckily the next steps will catch the invalid
packetId
Possible solutions:
function allowPacket(bytes32 root_,bytes32 packetId_,...) ... {
...
+ if (packetIdToRoot[packetId_] == bytes32(0) ) return false;
if (packetIdToRoot[packetId_] != root_) return false;
return true;
}Function _verify() continues executing while the packetId should not have been allowed.
function _verify(bytes32 packetId_, ... ) ... {
if (
!ISwitchboard(plugConfig_.inboundSwitchboard__).allowPacket(
packetIdRoots[packetId_],
packetId_,
uint32(remoteChainSlug_),
rootProposedAt[packetId_]
)
) revert VerificationFailed();
...
}NativeSwitchboardBase.sol#L224-L234:
function allowPacket(bytes32 root_,bytes32 packetId_,...) ... {
...
if (packetIdToRoot[packetId_] != root_) return false;
return true;
}