https://github.com/code-423n4/2024-08-axelar-network/blob/69c4f2c3fcefb1b8eb2129af9c3685a44ae5b6fe/axelar-amplifier/interchain-token-service/src/state.rs#L67-L83
This is the implementation of KeyDeserialize trait for TokenChainPair. Note that from the below we can see how TokenId is always going to be of length 32, otherwise setting it up to revert:
https://github.com/code-423n4/2024-08-axelar-network/blob/69c4f2c3fcefb1b8eb2129af9c3685a44ae5b6fe/axelar-amplifier/interchain-token-service/src/primitives.rs#L43-L52
Which is why in the first snippet attached, the value of the TokenChainPair is then split via value.split_at() with a mid value of 32 and here is the implementation of the queried split_at:
The problem here is the fact that the value.len is allowed to be exactly equal to 32, since the check is not inclusive. This would be problematic because even though the splitting does not panic (since mid = len), this would then cause the deserialization process to be flawed. We would have a 32-length token_id_bytes as expected, but for the chain_bytes, we would instead get a zero-length byte slice.
Allowing chain_bytes to be zero length can lead to issues during deserialization, since this would lead to invalid inputs and essentially a production of an invalid ChainName.
Make the length check inclusive to ensure we have a valid input for ChainName by reverting early if we do not.
Based on your request, Ill rewrite the report in the specified format, adjusting the content to reflect a more appropriate assessment of the situation.
