From c329e53811d640e21ee82cabb3bea747af58197b Mon Sep 17 00:00:00 2001 From: Carpentier Pierre-Francois Date: Wed, 7 Feb 2018 19:52:29 +0100 Subject: [PATCH 01/82] Update README.rst --- README.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.rst b/README.rst index 3685447..266d152 100644 --- a/README.rst +++ b/README.rst @@ -30,6 +30,21 @@ Nice and simple application to manage users and groups in multiple directory ser ---- +******** + Demo +******** + +A demo is accessible there: https://ldapcherry.kakwalab.ovh + +The Credential are: + +* as administrator: admin/admin +* as user: user/user + +Please take note that it's not possible to modify/delete the 'admin' and 'user' users. + +Also take note that the service will be reseted once per day. + **************** Presentation **************** From 1ed654c91bf2caeedbad34944bf837b6c21a2292 Mon Sep 17 00:00:00 2001 From: Carpentier Pierre-Francois Date: Wed, 7 Feb 2018 19:54:23 +0100 Subject: [PATCH 02/82] Update README.rst --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 266d152..330eb88 100644 --- a/README.rst +++ b/README.rst @@ -34,9 +34,9 @@ Nice and simple application to manage users and groups in multiple directory ser Demo ******** -A demo is accessible there: https://ldapcherry.kakwalab.ovh +A demo is accessible here: https://ldapcherry.kakwalab.ovh -The Credential are: +The credentials are: * as administrator: admin/admin * as user: user/user From 6f98076281e9452fdb1adcd1bcbb70a6f968ade9 Mon Sep 17 00:00:00 2001 From: John Thiltges Date: Wed, 2 Jan 2019 14:31:10 -0600 Subject: [PATCH 03/82] Protect against XSS vulnerabilities in URL redirection - Switch from base64 to URL encoding for the passing the URL, using the built-in Mako filtering - Apply HTML filtering to Mako output by default - Disable HTML filtering for nested templates in adduser, modify, and selfmodify --- ldapcherry/__init__.py | 23 ++++++++++++----------- resources/templates/adduser.tmpl | 4 ++-- resources/templates/login.tmpl | 14 +++++++------- resources/templates/modify.tmpl | 4 ++-- resources/templates/selfmodify.tmpl | 2 +- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/ldapcherry/__init__.py b/ldapcherry/__init__.py index 60ce654..a7d5c18 100644 --- a/ldapcherry/__init__.py +++ b/ldapcherry/__init__.py @@ -15,7 +15,7 @@ import logging.handlers from operator import itemgetter from socket import error as socket_error -import base64 +import urllib import cgi from exceptions import * @@ -387,7 +387,8 @@ def _load_templates(self, config): ) # preload templates self.temp_lookup = lookup.TemplateLookup( - directories=self.template_dir, input_encoding='utf-8' + directories=self.template_dir, input_encoding='utf-8', + default_filters=['unicode', 'h'] ) # load each template self.temp = {} @@ -573,7 +574,7 @@ def _check_session(self): def _check_auth(self, must_admin, redir_login=True): """ check if a user is autheticated and, optionnaly an administrator - if user not authentifaced -> redirection to login page (with base64 + if user not authenticated -> redirect to login page (with escaped URL of the originaly requested page (redirection after login) if user authenticated, not admin and must_admin enabled -> 403 error @boolean must_admin: flag "user must be an administrator to access @@ -588,13 +589,13 @@ def _check_auth(self, must_admin, redir_login=True): qs = '' else: qs = '?' + cherrypy.request.query_string - # base64 of the requested URL - b64requrl = base64.b64encode(cherrypy.url() + qs) + # Escaped version of the requested URL + quoted_requrl = urllib.quote_plus(cherrypy.url() + qs) if not username: - # return to login page (with base64 of the url in query string + # return to login page (with quoted url in query string) if redir_login: raise cherrypy.HTTPRedirect( - "/signin?url=%(url)s" % {'url': b64requrl}, + "/signin?url=%(url)s" % {'url': quoted_requrl}, ) else: raise cherrypy.HTTPError( @@ -606,7 +607,7 @@ def _check_auth(self, must_admin, redir_login=True): or not cherrypy.session['connected']: if redir_login: raise cherrypy.HTTPRedirect( - "/signin?url=%(url)s" % {'url': b64requrl}, + "/signin?url=%(url)s" % {'url': quoted_requrl}, ) else: raise cherrypy.HTTPError( @@ -631,7 +632,7 @@ def _check_auth(self, must_admin, redir_login=True): else: if redir_login: raise cherrypy.HTTPRedirect( - "/signin?url=%(url)s" % {'url': b64requrl}, + "/signin?url=%(url)s" % {'url': quoted_requrl}, ) else: raise cherrypy.HTTPError( @@ -919,7 +920,7 @@ def login(self, login, password, url=None): if url is None: redirect = "/" else: - redirect = base64.b64decode(url) + redirect = url raise cherrypy.HTTPRedirect(redirect) else: message = "login failed for user '%(user)s'" % { @@ -932,7 +933,7 @@ def login(self, login, password, url=None): if url is None: qs = '' else: - qs = '?url=' + url + qs = '?url=' + urllib.quote_plus(url) raise cherrypy.HTTPRedirect("/signin" + qs) @cherrypy.expose diff --git a/resources/templates/adduser.tmpl b/resources/templates/adduser.tmpl index 7b690fc..8b27f75 100644 --- a/resources/templates/adduser.tmpl +++ b/resources/templates/adduser.tmpl @@ -9,11 +9,11 @@