While checking the ur2/ module, I discovered two runtime bugs in the vendored cbor_lite.py implementation. These bugs have likely persisted due to zero test coverage for this module.
-
encodeText (line 155):
The method attempts to call bytearray.append() with a bytes object (the UTF-8 encoded string). bytearray.append() only accepts a single integer (0-255). This raises a TypeError at runtime.
-
decodeMapSize (line 314):
The method checks for a map tag using Tag_Major_mask (0xe0) instead of Tag_Major_map (0xa0).
This means certain malformed CBOR maps could silently pass tag validation or correctly formed maps could fail depending on the major type bits.
Although most SeedSigner PSBT and xpub data is binary (byteStrings), any attempt to use textStrings in the UR protocol would result in a crash. More importantly, the incorrect map validation constant is a risk for the reliable parsing of complex UR structures. This doesn't really cause any issues on the emulator, but it is a latent bug.
While checking the
ur2/module, I discovered two runtime bugs in the vendoredcbor_lite.pyimplementation. These bugs have likely persisted due to zero test coverage for this module.encodeText(line 155):The method attempts to call
bytearray.append()with abytesobject (the UTF-8 encoded string).bytearray.append()only accepts a single integer (0-255). This raises aTypeErrorat runtime.decodeMapSize(line 314):The method checks for a map tag using
Tag_Major_mask(0xe0) instead ofTag_Major_map(0xa0).This means certain malformed CBOR maps could silently pass tag validation or correctly formed maps could fail depending on the major type bits.
Although most SeedSigner PSBT and xpub data is binary (byteStrings), any attempt to use textStrings in the UR protocol would result in a crash. More importantly, the incorrect map validation constant is a risk for the reliable parsing of complex UR structures. This doesn't really cause any issues on the emulator, but it is a latent bug.