[freeipa PR#2511][opened] ipaldap: avoid invalid modlist when attribute encoding differs
by frasertweedale
URL: https://github.com/freeipa/freeipa/pull/2511
Author: frasertweedale
Title: #2511: ipaldap: avoid invalid modlist when attribute encoding differs
Action: opened
PR body:
"""
ipaldap does not take into account the possibility of the attribute
encoding returned by python-ldap differing from the attribute
encoding produced by FreeIPA. In particular this can occur with DNs
with special characters that require escaping. For example,
python-ldap (or the underlying LDAP library) escapes special
characters using hex encoding:
```
CN=Test Sub-CA 201604041620,OU=ftweedal,O=Red Hat\2C Inc.,L=Brisbane,C=AU
```
Whereas FreeIPA, when encoding the DN, escapes the character
directly:
```
CN=Test Sub-CA 201604041620,OU=ftweedal,O=Red Hat\, Inc.,L=Brisbane,C=AU
```
Therefore it is possible to generate an invalid modlist. For
example, during external CA certificate renewal, if the issuer DN
includes a comma in one of the attribute values (as above), an
invalid modlist will be generated:
```
[ (ldap.MOD_ADD, 'ipacaissuerdn',
[b'CN=Test Sub-CA 201604041620,OU=ftweedal,O=Red Hat\, Inc.,L=Brisbane,C=AU'])
, (ldap.MOD_DELETE, 'ipacaissuerdn',
[b'CN=Test Sub-CA 201604041620,OU=ftweedal,O=Red Hat\2C Inc.,L=Brisbane,C=AU'])
]
```
Although encoded differently, these are the same value. If this
modification is applied to the object, attributeOrValueExists (error
20) occurs.
To avoid the issue, put deletes before adds in the modlist. If a
value is present (with different encodings) as both an addition and
a deletion, it must be because the original object contained the
value with a different encoding. Therefore it is safe to delete it,
then add it back.
Note that the modlist is not optimal. In the simplest case (like
above example), there should be no modification to perform. It is
considerably more complex (and more computation) to implement this
because the raw attribute values must be decoded before comparison.
Fixes: https://pagure.io/freeipa/issue/7750
"""
To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/2511/head:pr2511
git checkout pr2511
5 years
Ticket cleanup
by Rob Crittenden
You may notice that over the next few weeks a LOT of issues on
https://pagure.io/freeipa will close.
Most of them fall into one or buckets:
* seems like a good idea but we'll never get to it due to other priorities
* is a great idea but is incredibly complex and we'll never get to it
* was a fantastic idea and we fixed it in a duplicate issue
* a bug that no longer applies or is against an unsupported version
* a small percentage will be something else
If we close one in error then please don't hesitate to comment in the
issue. The goal is to get the number of issues down to a size we
actually have a capacity to address.
regards
rob
5 years