Repository navigation
Conversation
RFC 4515 defines \XX as a single octet, but _processLdapString turned it into the code point chr(0xXX). Since AssertionValue encodes str as UTF-8, any escaped byte above 0x7f was sent as two bytes, so filters on binary attributes such as objectGUID and objectSid returned no entries. Encode unescaped text as UTF-8 first and then replace each escape with its raw byte. Unescaped non-ASCII values keep working, and escaped UTF-8 sequences now produce the same octets as their literal form. Fixes fortra#2357.
Collaborator
|
this one looks duplicate of #2358 |
Author
|
You're right, #2358 covers this exactly, including the octet-based fix and the same test coverage. I missed it when I opened this. Closing mine as a duplicate so there's one place to review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
LDAPConnection._processLdapString()turns every\XXescape intochr(0xXX). SinceAssertionValuehasencoding = 'utf-8', any escaped octet above0x7fis then sent as two UTF-8 bytes:RFC 4515 defines
\XXas one octet, so filters on binary attributes such asobjectGUIDandobjectSid, and filters that escape UTF-8 characters, do not match. Escapes below0x80(\28,\29,\2a,\00) are unaffected.Fix
Encode the unescaped text as UTF-8 first, then replace each
\XXwith its raw byte. Unescaped non-ASCII values keep working, and escaped UTF-8 sequences now produce the same octets as their literal form:The encoded filter now contains
04 03 a1 00 fffor the first case and04 05 4a 6f 73 c3 a9for the second.Tests
New
tests/misc/test_ldap_filter.pycovers binary escapes, escaped and unescaped UTF-8, reserved characters, substring assertions, and extensible matches. 8 passed locally.Fixes #2357.