The vulnerability is a Denial of Service (DoS) in pyasn1 version 0.6.1 caused by memory exhaustion when decoding malformed OID or RELATIVE-OID values. The root cause is an unbounded loop in the valueDecoder methods of the ObjectIdentifierPayloadDecoder and RelativeOIDPayloadDecoder classes within pyasn1/codec/ber/decoder.py.
When decoding an OID or RELATIVE-OID, the components (arcs) are parsed from bytes. An arc can be represented by multiple bytes, where the high bit of a byte indicates that the next byte is also part of the same arc (a continuation octet). An attacker can craft a payload with an extremely long sequence of these continuation octets for a single arc.
The vulnerable valueDecoder functions would enter a while loop to process these continuation octets. Without any limits, this loop would continue to execute, each time performing bit-shifting and addition to an integer variable (subId). This results in an astronomically large integer being created, consuming a significant amount of memory and CPU, leading to a DoS.
The patch mitigates this by introducing a counter (continuationOctetCount) inside the loop and checking it against a new limit (MAX_OID_ARC_CONTINUATION_OCTETS = 20). If the number of continuation octets exceeds this limit, an exception is raised, terminating the decoding process and preventing resource exhaustion.
The identified vulnerable functions, ObjectIdentifierPayloadDecoder.valueDecoder and RelativeOIDPayloadDecoder.valueDecoder, are the specific methods where this unbounded loop existed. Any application using pyasn1 to decode ASN.1 data from untrusted sources (like X.509 certificates) could trigger this vulnerability. A runtime profile during such an event would show significant time spent within these valueDecoder functions.