Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ The following people have contributed to Python-ASN1. Collectively they own the
* Geert Jansen <[email protected]>
* Sebastien Andrivet <[email protected]>
* Filippo Santovito <[email protected]>
* bardrop <[email protected]>

6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

Unreleased
----------

* Reject an OID value whose last sub-identifier is truncated (last byte has bit 8 set)
instead of silently dropping it

3.3.0 (2026-05-15)
------------------

Expand Down
4 changes: 4 additions & 0 deletions src/asn1/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,10 @@ def _decode_object_identifier(self, length): # type: (int) -> str
sub_identifiers.append(value)
value = 0

# 8.19.2: the last byte of each sub-identifier has bit 8 set to zero
if content[-1] & 0x80:
raise Error('ASN1 decoding error: the last sub-identifier of an OID value is truncated.')

if len(sub_identifiers) == 0:
raise Error('ASN1 decoding error: no sub-identifiers found.')

Expand Down
6 changes: 6 additions & 0 deletions tests/test_asn1.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,12 @@ def test_error_non_normalised_object_identifier(self):
dec.start(buf)
pytest.raises(asn1.Error, dec.read)

def test_error_truncated_object_identifier(self):
for buf in (b'\x06\x02\x2a\x86', b'\x06\x05\x2a\x86\x48\x86\xf7', b'\x06\x01\x81'):
dec = asn1.Decoder()
dec.start(buf)
pytest.raises(asn1.Error, dec.read)

def test_error_bitstring_with_too_many_unused_bits(self):
buf = b'\x03\x04\x08\x12\x34\x50'
dec = asn1.Decoder()
Expand Down