The documentation of a compactSize field in the Bitcoin Developer Reference describes four possible encodings based on length. The ranges of integers expressible in each encoding overlap. Therefore it is possible in principle to represent a compactSize with a non-canonical encoding that uses more than the minimum number of bytes.
The actual implementation of ReadCompactSize excludes this possibility. This is also tested. However, it is not documented. Since it affects consensus, it should be documented.
(Ref: https://github.com/zcash/zcash/issues/842 , which is a potential security bug that the Zcash fork of Bitcoin would have had if canonicity were not enforced.)