Skip to content

crypto/x509: OIDFromInts can overflow the first subidentifier for large 2.x OIDs #79857

Description

@jvdprng

Description

OIDFromInts computes the first DER subidentifier as oid[0]*40 + oid[1] in uint64. For OIDs under arc 2, a very large second component can overflow and wrap to a different DER encoding. That can make an unusual local OID input produce an OID different from the one requested by the caller.

The impact requires local code to construct OIDs with very large integer components.

Specification

ITU-T X.690 Section 8.19 defines DER encoding for OBJECT IDENTIFIER values, including the first subidentifier derived from the first two arcs. The encoding should represent the requested OID components, not a wrapped arithmetic result.

Code references

  • go/src/crypto/x509/oid.go:54 defines OIDFromInts.
  • go/src/crypto/x509/oid.go:56 validates the first two arcs.
  • go/src/crypto/x509/oid.go:60 computes oid[0]*40 + oid[1] without an overflow check.
  • go/src/crypto/x509/oid.go:66 encodes that potentially wrapped value.

Test case

This should be a Go unit test for OIDFromInts([]uint64{2, math.MaxUint64}) or similar large second components. The expected behavior should be a clear error.

It could be paired with an OID parser/serializer property test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions