You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Decoding a DER-encoded BIT STRING with a non-zero "unused bits" byte into a types::BitString results in a value padded with 0s to the nearest byte.
This makes it impossible to tell the difference between values with "real" trailing zeros and those without.
In particular, RFC3779 and other RPKI-related standards use a BIT STRING to encode IP prefixes, indicating the length of the prefix through the bit-length of the BIT STRING. This issue makes it impossible to correctly decode IP prefixes with lengths that are not a multiple of 8.
Note that I have only tried this with the DER implementation. I do not know whether the other codecs suffer from a similar issue.
The issue can be reproduced with the following minimal example:
@XAMPPRocky have attempted a fix in #135.
Let me know your thoughts when you have a sec.
I have tested on my project, and this fixes the bug that lead me here.
Decoding a DER-encoded
BIT STRING
with a non-zero "unused bits" byte into atypes::BitString
results in a value padded with0
s to the nearest byte.This makes it impossible to tell the difference between values with "real" trailing zeros and those without.
In particular, RFC3779 and other RPKI-related standards use a
BIT STRING
to encode IP prefixes, indicating the length of the prefix through the bit-length of theBIT STRING
. This issue makes it impossible to correctly decode IP prefixes with lengths that are not a multiple of 8.Note that I have only tried this with the DER implementation. I do not know whether the other codecs suffer from a similar issue.
The issue can be reproduced with the following minimal example:
I will take a look at the relevant code, and propose a fix if I can grok it easily enough.
The text was updated successfully, but these errors were encountered: