Bug 50529 - UDM REST API can't handle umlaut in DN (HTTP 500)
UDM REST API can't handle umlaut in DN (HTTP 500)
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UDM - REST API
UCS 4.4
Other Linux
: P5 normal (vote)
: UCS 4.4-5-errata
Assigned To: Florian Best
Dirk Wiesenthal
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2019-11-21 15:08 CET by Daniel Tröder
Modified: 2020-08-26 16:35 CEST (History)
5 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 5: Major Usability: Impairs usability in key scenarios
Who will be affected by this bug?: 2: Will only affect a few installed domains
How will those affected feel about the bug?: 3: A User would likely not purchase the product
User Pain: 0.171
Enterprise Customer affected?:
School Customer affected?: Yes
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:
best: Patch_Available+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2019-11-21 15:08:03 CET
GET of https://HOST/univention/udm/users/user/uid=userä,cn=users,BASEDN leads to
---------------------------------------------------------------------------
21.11.19 15:07:14       ERROR      (      466) : Uncaught exception GET /udm/users/user/uid=user%C3%A4,cn=users,dc=ucs-test,dc=intranet (0.0.0.0)
    HTTPServerRequest(protocol='http', host='172.17.0.2', method='GET', uri='/udm/users/user/uid=user%C3%A4,cn=users,dc=ucs-test,dc=intranet', version='HTTP/1.1', remote_ip='0.0.0.0', headers={'X-Umc-Https': 'on', 'Via': '1.1 master.ucs-test.intranet', 'Accept-Language': 'de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7', 'Accept-Encoding': 'gzip, deflate, br', 'X-Forwarded-Host': '172.17.0.2', 'X-Forwarded-Ssl': 'on', 'Sec-Fetch-Site': 'cross-site', 'Host': '172.17.0.2', 'Accept': 'application/json', 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36', 'Dnt': '1', 'Connection': 'close', 'X-Forwarded-Proto': 'https', 'Cookie': 'rocketchatscreenshare=chrome; rocketchatscreenshare=chrome; rocketchatscreenshare=chrome', 'Sec-Fetch-Mode': 'cors', 'X-Forwarded-Server': 'master.ucs-test.intranet', 'X-Forwarded-For': '172.17.0.1', u'Authorization': 'Basic QWRtaW5pc3RyYXRvcjp1bml2ZW50aW9u'})
    Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/tornado/web.py", line 1469, in _execute
        result = yield result
      File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 1015, in run
        value = future.result()
      File "/usr/lib/python2.7/dist-packages/tornado/concurrent.py", line 237, in result
        raise_exc_info(self._exc_info)
      File "/usr/lib/python2.7/dist-packages/tornado/gen.py", line 1024, in run
        yielded = self.gen.send(value)
      File "/usr/lib/python2.7/dist-packages/univention/admin/rest/module.py", line 2622, in get
        props.update(self._options(object_type, obj.dn))
      File "/usr/lib/python2.7/dist-packages/univention/admin/rest/module.py", line 2647, in _options
        self.add_link(props, 'udm:object-modules', self.urljoin('../../'), title=_('All modules'))
      File "/usr/lib/python2.7/dist-packages/univention/admin/rest/module.py", line 762, in urljoin
        return urljoin(urljoin(urlunparse((scheme, base.netloc, 'univention/' if self.request.headers.get('X-Forwarded-Host') else '/', '', '', '')), quote(self.request.path_decoded.lstrip('/'))), '/'.join(args)) + query_string
      File "/usr/lib/python2.7/urllib.py", line 1299, in quote
        return ''.join(map(quoter, s))
    KeyError: u'\xe4'
21.11.19 15:07:14       ERROR      (      466) : Uncaught exception in write_error
    Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/tornado/web.py", line 994, in send_error
        self.write_error(status_code, **kwargs)
      File "/usr/lib/python2.7/dist-packages/univention/admin/rest/module.py", line 884, in write_error
        self.add_link(response, 'self', self.urljoin(''), title=_('HTTP-Error %d: %s') % (status_code, title))
      File "/usr/lib/python2.7/dist-packages/univention/admin/rest/module.py", line 762, in urljoin
        return urljoin(urljoin(urlunparse((scheme, base.netloc, 'univention/' if self.request.headers.get('X-Forwarded-Host') else '/', '', '', '')), quote(self.request.path_decoded.lstrip('/'))), '/'.join(args)) + query_string
      File "/usr/lib/python2.7/urllib.py", line 1299, in quote
        return ''.join(map(quoter, s))
    KeyError: u'\xe4'
21.11.19 15:07:14       ERROR      (      466) : 500 GET /udm/users/user/uid=user%C3%A4,cn=users,dc=ucs-test,dc=intranet (0.0.0.0) 16.98ms
ERROR:tornado.access:500 GET /udm/users/user/uid=user%C3%A4,cn=users,dc=ucs-test,dc=intranet (127.0.0.1) 20.11ms
Comment 1 Daniel Tröder univentionstaff 2019-11-21 15:09:10 CET
The URL with umlaut is generated by the UDM REST API in the collection at https://HOST/univention/udm/users/user/
Comment 2 Daniel Tröder univentionstaff 2019-11-21 15:10:19 CET
$ univention-ldapsearch -LLL 'uid=userä' dn uid
dn:: dWlkPXVzZXLDpCxjbj11c2VycyxkYz11Y3MtdGVzdCxkYz1pbnRyYW5ldA==
uid:: dXNlcsOk
Comment 3 Florian Best univentionstaff 2019-11-26 15:52:33 CET
Typo because of `from future import unicode_literals`:

Patch in branch git:fbest/50529-unicode-dns:

diff --git management/univention-directory-manager-rest/src/univention/admin/rest/module.py management/univention-directory-manager-rest/src/univention/admin/rest/module.py
index a7f17f7739..a3f5c9a4c7 100755
--- management/univention-directory-manager-rest/src/univention/admin/rest/module.py
+++ management/univention-directory-manager-rest/src/univention/admin/rest/module.py
@@ -759,7 +759,7 @@ class ResourceBase(object):
                                break
                        if _scheme == 'http':
                                scheme = 'http'
-               return urljoin(urljoin(urlunparse((scheme, base.netloc, 'univention/' if self.request.headers.get('X-Forwarded-Host') else '/', '', '', '')), quote(self.request.path_decoded.lstrip('/'))), '/'.join(args)) + query_string
+               return urljoin(urljoin(urlunparse((scheme, base.netloc, 'univention/' if self.request.headers.get('X-Forwarded-Host') else '/', '', '', '')), quote(self.request.path_decoded.lstrip(b'/'))), '/'.join(args)) + query_string

        def abspath(self, *args):
                return urljoin(self.urljoin('/univention/udm/' if self.request.headers.get('X-Forwarded-Host') else '/udm/'), '/'.join(args))
Comment 4 Dirk Ahrnke univentionstaff 2020-08-03 17:14:33 CEST
This issue appears to be responsible for a recent customer report that it is possible to create users by using the Kelvin-API but attempts to delete them will fail. 

directory-manager-rest.log shows the same exception
Comment 7 Florian Best univentionstaff 2020-08-25 18:42:39 CEST
Some of the patches of the current UCS 5 have been backported to fix this.
The problem was, as mentioned in comment #3, the unicode_literals import, which has been removed now. Additionally the quoting of the DN when moving an object has been fixed as well. A test case has also been added which tests creation, modification, moving and retrieval of objects containing umlauts in the DN.

ucs-test (9.0.4-47)
8147ffed8f9e | Bug #50529: test with umlauts in DN

univention-directory-manager-rest (9.0.16-9)
6af134dc4884 | Bug #50529: fix quoting of DN when moving objects
18507082fe16 | Bug #50529: (Bug #51685): fix python 3 compatibility
c961c9bcaece | Bug #50529: (Bug #51685): remove __future__.unicode_literals import
1cce61ba91a2 | Bug #50529: (Bug #51685): fix Python3 imports
cb4bd9fb8308 | Bug #50529: (Bug #51685): backport Python 3 compatibility fixes from UCS 5
9146ae3d63d1 | Bug #50529: (Bug #51685): Fix Python 3 dict.keys() concat
Comment 8 Dirk Wiesenthal univentionstaff 2020-08-26 12:22:14 CEST
Code: OK
Test: OK
YAML: OK

GET of https://HOST/univention/udm/users/user/uid=userä,cn=users,BASEDN: OK