|
|
cc3dff |
From 896091407c244ed151f2fad39a82881a6e991d26 Mon Sep 17 00:00:00 2001
|
|
|
cc3dff |
From: Rich Megginson <rmeggins@redhat.com>
|
|
|
cc3dff |
Date: Tue, 29 Oct 2013 13:47:35 -0600
|
|
|
cc3dff |
Subject: [PATCH] Ticket #47605 CVE-2013-4485: DoS due to improper handling of ger attr searches
|
|
|
cc3dff |
|
|
|
cc3dff |
https://fedorahosted.org/389/ticket/47605
|
|
|
cc3dff |
Reviewed by: nhosoi (Thanks!)
|
|
|
cc3dff |
Branch: 389-ds-base-1.3.1
|
|
|
cc3dff |
Fix Description: The traversal of the attr list looking for GER objectclasses
|
|
|
cc3dff |
was modifying the same attribute twice, removing the "@" from it. The second
|
|
|
cc3dff |
time, since there was no "@" in the string, the strchr would return NULL, and
|
|
|
cc3dff |
the code would not check for it.
|
|
|
cc3dff |
The code was simplified and rewritten to use charray_merge_nodup
|
|
|
cc3dff |
to build the gerattrs list with unique objectclass values, which I believe was
|
|
|
cc3dff |
the intention of the original code. I also added some error checking to look
|
|
|
cc3dff |
for invalid attributes like "@name" "name@" and "name@name@name".
|
|
|
cc3dff |
Platforms tested: RHEL6 x86_64
|
|
|
cc3dff |
Flag Day: no
|
|
|
cc3dff |
Doc impact: no
|
|
|
cc3dff |
(cherry picked from commit 7e03702932546e74f0044d11832e7e7e395cbb36)
|
|
|
cc3dff |
(cherry picked from commit 12e54af6982ab5406f4bba6a02dd0724a0415501)
|
|
|
cc3dff |
(cherry picked from commit 8c5e74b291d08c66e0afbf766f77f955725b9bf4)
|
|
|
cc3dff |
---
|
|
|
cc3dff |
ldap/servers/slapd/search.c | 79 +++++++++----------------------------------
|
|
|
cc3dff |
1 files changed, 16 insertions(+), 63 deletions(-)
|
|
|
cc3dff |
|
|
|
cc3dff |
diff --git a/ldap/servers/slapd/search.c b/ldap/servers/slapd/search.c
|
|
|
cc3dff |
index da1772f..59c4afb 100644
|
|
|
cc3dff |
--- a/ldap/servers/slapd/search.c
|
|
|
cc3dff |
+++ b/ldap/servers/slapd/search.c
|
|
|
cc3dff |
@@ -246,8 +246,6 @@ do_search( Slapi_PBlock *pb )
|
|
|
cc3dff |
}
|
|
|
cc3dff |
|
|
|
cc3dff |
if ( attrs != NULL ) {
|
|
|
cc3dff |
- int gerattrsiz = 1;
|
|
|
cc3dff |
- int gerattridx = 0;
|
|
|
cc3dff |
int aciin = 0;
|
|
|
cc3dff |
/*
|
|
|
cc3dff |
* . store gerattrs if any
|
|
|
cc3dff |
@@ -257,66 +255,25 @@ do_search( Slapi_PBlock *pb )
|
|
|
cc3dff |
{
|
|
|
cc3dff |
char *p = NULL;
|
|
|
cc3dff |
/* check if @<objectclass> is included */
|
|
|
cc3dff |
- p = strchr(attrs[i], '@');
|
|
|
cc3dff |
- if ( p && '\0' != *(p+1) ) /* don't store "*@", e.g. */
|
|
|
cc3dff |
+ p = strchr(attrs[i], '@');
|
|
|
cc3dff |
+ if ( p )
|
|
|
cc3dff |
{
|
|
|
cc3dff |
- int j = 0;
|
|
|
cc3dff |
- if (gerattridx + 1 >= gerattrsiz)
|
|
|
cc3dff |
+ char *dummyary[2]; /* need a char ** for charray_merge_nodup */
|
|
|
cc3dff |
+ if ((*(p + 1) == '\0') || (p == attrs[i]) || (strchr(p+1, '@'))) /* e.g. "foo@" or "@objectclassname" or "foo@bar@baz" */
|
|
|
cc3dff |
{
|
|
|
cc3dff |
- char **tmpgerattrs;
|
|
|
cc3dff |
- gerattrsiz *= 2;
|
|
|
cc3dff |
- tmpgerattrs =
|
|
|
cc3dff |
- (char **)slapi_ch_calloc(1, gerattrsiz*sizeof(char *));
|
|
|
cc3dff |
- if (NULL != gerattrs)
|
|
|
cc3dff |
- {
|
|
|
cc3dff |
- memcpy(tmpgerattrs, gerattrs, gerattrsiz*sizeof(char *));
|
|
|
cc3dff |
- slapi_ch_free((void **)&gerattrs);
|
|
|
cc3dff |
- }
|
|
|
cc3dff |
- gerattrs = tmpgerattrs;
|
|
|
cc3dff |
- }
|
|
|
cc3dff |
- for ( j = 0; gerattrs; j++ )
|
|
|
cc3dff |
- {
|
|
|
cc3dff |
- char *attri = NULL;
|
|
|
cc3dff |
- if ( NULL == gerattrs[j] )
|
|
|
cc3dff |
- {
|
|
|
cc3dff |
- if (0 == j)
|
|
|
cc3dff |
- {
|
|
|
cc3dff |
- /* first time */
|
|
|
cc3dff |
- gerattrs[gerattridx++] = attrs[i];
|
|
|
cc3dff |
- /* get rid of "@<objectclass>" part from the attr
|
|
|
cc3dff |
- list, which is needed only in gerattr list */
|
|
|
cc3dff |
- *p = '\0';
|
|
|
cc3dff |
- attri = slapi_ch_strdup(attrs[i]);
|
|
|
cc3dff |
- attrs[i] = attri;
|
|
|
cc3dff |
- *p = '@';
|
|
|
cc3dff |
- }
|
|
|
cc3dff |
- else
|
|
|
cc3dff |
- {
|
|
|
cc3dff |
- break; /* done */
|
|
|
cc3dff |
- }
|
|
|
cc3dff |
- }
|
|
|
cc3dff |
- else if ( 0 == strcasecmp( attrs[i], gerattrs[j] ))
|
|
|
cc3dff |
- {
|
|
|
cc3dff |
- /* skip if attrs[i] is already in gerattrs */
|
|
|
cc3dff |
- continue;
|
|
|
cc3dff |
- }
|
|
|
cc3dff |
- else
|
|
|
cc3dff |
- {
|
|
|
cc3dff |
- char *q = strchr(gerattrs[j], '@'); /* q never be 0 */
|
|
|
cc3dff |
- if ( 0 != strcasecmp( p+1, q+1 ))
|
|
|
cc3dff |
- {
|
|
|
cc3dff |
- /* you don't want to display the same template
|
|
|
cc3dff |
- entry multiple times */
|
|
|
cc3dff |
- gerattrs[gerattridx++] = attrs[i];
|
|
|
cc3dff |
- }
|
|
|
cc3dff |
- /* get rid of "@<objectclass>" part from the attr
|
|
|
cc3dff |
- list, which is needed only in gerattr list */
|
|
|
cc3dff |
- *p = '\0';
|
|
|
cc3dff |
- attri = slapi_ch_strdup(attrs[i]);
|
|
|
cc3dff |
- attrs[i] = attri;
|
|
|
cc3dff |
- *p = '@';
|
|
|
cc3dff |
- }
|
|
|
cc3dff |
+ slapi_log_error( SLAPI_LOG_ARGS, "do_search",
|
|
|
cc3dff |
+ "invalid attribute [%s] in list - must be of the form "
|
|
|
cc3dff |
+ "attributename@objectclassname where attributename is the "
|
|
|
cc3dff |
+ "name of an attribute or \"*\" or \"+\" and objectclassname "
|
|
|
cc3dff |
+ "is the name of an objectclass\n", attrs[i] );
|
|
|
cc3dff |
+ continue;
|
|
|
cc3dff |
}
|
|
|
cc3dff |
+ dummyary[0] = p; /* p = @objectclassname */
|
|
|
cc3dff |
+ dummyary[1] = NULL;
|
|
|
cc3dff |
+ /* copy string to gerattrs with leading @ - disallow dups */
|
|
|
cc3dff |
+ charray_merge_nodup(&gerattrs, dummyary, 1);
|
|
|
cc3dff |
+ /* null terminate the attribute name at the @ after it has been copied */
|
|
|
cc3dff |
+ *p = '\0';
|
|
|
cc3dff |
}
|
|
|
cc3dff |
else if ( !aciin && strcasecmp(attrs[i], LDAP_ALL_USER_ATTRS) == 0 )
|
|
|
cc3dff |
{
|
|
|
cc3dff |
@@ -324,10 +281,6 @@ do_search( Slapi_PBlock *pb )
|
|
|
cc3dff |
aciin = 1;
|
|
|
cc3dff |
}
|
|
|
cc3dff |
}
|
|
|
cc3dff |
- if (NULL != gerattrs)
|
|
|
cc3dff |
- {
|
|
|
cc3dff |
- gerattrs[gerattridx] = NULL;
|
|
|
cc3dff |
- }
|
|
|
cc3dff |
|
|
|
cc3dff |
if (config_get_return_orig_type_switch()) {
|
|
|
cc3dff |
/* return the original type, e.g., "sn (surname)" */
|
|
|
cc3dff |
--
|
|
|
cc3dff |
1.7.1
|
|
|
cc3dff |
|