[Breaking change]: LDAP DirectoryControl parsing performed in managed code #43885
Labels
breaking-change
Indicates a .NET Core breaking change
doc-idea
Indicates issues that are suggestions for new topics [org][type][category]
Pri1
High priority, do before Pri2 and Pri3
⌚ Not Triaged
Not triaged
Description
This change is a result of dotnet/runtime#101512.
Previously, .NET used BerConverter to parse the DirectoryControls it received over the network and to generate the DirectoryControl byte arrays it sent; BerConverter would use the OS-specific BER parsing functionality. This parsing functionality is now implemented in managed code.
Version
.NET 10 Preview 1
Previous behavior
As a result of using BerConverter, the parsing of DirectoryControls was very relaxed.
null
rather than an empty string.While not a breaking change, Windows would always encode ASN.1 tags with a four-byte length while Linux would only use as many bytes for the tag length as it needed. Both representations were valid, but this behavioural difference between platforms is now gone; the Linux behaviour now also appears on Windows.
New behavior
The DirectoryControl parsing is much more stringent, and is now consistent across platforms and versions.
We also validate errors more thoroughly when calling the VlvRequestControl constructor. Passing a string which cannot be encoded as a UTF8 value will now throw an EncoderFallbackException.
Type of breaking change
Reason for change
RFC/spec. compliance. In the various RFCs and sections of MS-ADTS, the controlValue is specified as the BER encoding of an ASN.1 structure with wording similar to the below (from RFC2891, section 1.2):
This precludes trailing data. It also rules out BER encodings of ASN.1 structures with differing ASN.1 tags, and of invalid BER encodings (such as OCTET STRINGs which are longer than their containing SEQUENCE.)
For the VlvRequestControl constructor, throwing the exception early means that users can trust that only the values they explicitly specify are sent to the server - there are no circumstances where they can accidentally send
EF BF BD
to the server because they've passed a string which can't be encoded to valid UTF8 bytes.Recommended action
Servers should comply with the RFCs and specifications. Users should be aware of the need to handle an
EncoderFallbackException
when calling the VlvRequestControl constructor.Feature area
Core .NET libraries, Security
Affected APIs
For the more stringent DirectoryControl parsing:
For the VlvRequestControl constructor:
The text was updated successfully, but these errors were encountered: