Omniscia Evergon Labs Audit
OmnichainIdentifiers Manual Review Findings
OmnichainIdentifiers Manual Review Findings
OIS-01M: Incorrect Bitwise Shift of Identifier
| Type | Severity | Location |
|---|---|---|
| Logical Fault | ![]() | OmnichainIdentifiers.sol:L51 |
Description:
The OmnichainIdentifier is improperly decoded as a shift operation by 32 bits occurs which is incorrect as the right-most bits already contain the full 224 bits of the identifier.
Impact:
The decoding of an OmnichainIdentifier is presently incorrect as it will shift the data point by 32 bits to the left thus malforming data and losing the upper-most 32 bits.
Example:
contracts/utils/OmnichainIdentifiers.sol
33/**34 * @dev Encode OmnichainIdentifier35 * @param chainid Chain ID to encode36 * @param identifier Numeric identifier37 * @return Encoded OmnichainIdentifier38 */39function encode(uint32 chainid, uint224 identifier) internal pure returns (OmnichainIdentifier) {40 return OmnichainIdentifier.wrap((uint256(chainid) << 224) | identifier);41}42
43/**44 * @dev Decode OmnichainIdentifier45 * @param oi OmnichainIdentifier to decode46 * @return chainid Chain ID of the OmnichainIdentifier47 * @return identifier Numeric identifier of the OmnichainIdentifier48 */49function decode(OmnichainIdentifier oi) internal pure returns (uint32 chainid, uint224 identifier) {50 uint256 oiu = uint256(OmnichainIdentifier.unwrap(oi));51 identifier = uint224(oiu << 32);52 chainid = uint32(oiu >> 224);53}Recommendation:
We advise a truncation operation to occur either by directly casting the oiu to the uint224 data type or by shifting to the left and then to the right by 32 bits, either of which is an acceptable alleviation to this exhibit.
Alleviation (c6b23c23d8bcd8cce85049ad959cbd711a37126b):
The code was updated to omit the bitwise shift operation occurring for the identifier, alleviating this exhibit.
