1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

CVE-2018-10919 tests: Add test case for object visibility with limited rights

Currently Samba is a bit disclosive with LDB_OP_PRESENT (i.e.
attribute=*) searches compared to Windows.

All the acl.py tests are based on objectClass=* searches, where Windows
will happily tell a user about objects they have List Contents rights,
but not Read Property rights for. However, if you change the attribute
being searched for, suddenly the objects are no longer visible on
Windows (whereas they are on Samba).

This is a problem, because Samba can tell you about which objects have
confidential attributes, which in itself could be disclosive.

This patch adds a acl.py test-case that highlights this behaviour. The
test passes against Windows but fails against Samba.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
This commit is contained in:
Tim Beale 2018-07-25 10:08:34 +12:00 committed by Karolin Seeger
parent 375f48f779
commit 9eb8340e32
2 changed files with 69 additions and 0 deletions

1
selftest/knownfail.d/acl Normal file
View File

@ -0,0 +1 @@
^samba4.ldap.acl.python.*test_search7

View File

@ -1010,6 +1010,74 @@ class AclSearchTests(AclTests):
res_list = list(res[0].keys())
self.assertEquals(sorted(res_list), sorted(ok_list))
def assert_search_on_attr(self, dn, samdb, attr, expected_list):
expected_num = len(expected_list)
res = samdb.search(dn, expression="(%s=*)" % attr, scope=SCOPE_SUBTREE)
self.assertEquals(len(res), expected_num)
res_list = [ x["dn"] for x in res if x["dn"] in expected_list ]
self.assertEquals(sorted(res_list), sorted(expected_list))
def test_search7(self):
"""Checks object search visibility when users don't have full rights"""
self.create_clean_ou("OU=ou1," + self.base_dn)
mod = "(A;;LC;;;%s)(A;;LC;;;%s)" % (str(self.user_sid),
str(self.group_sid))
self.sd_utils.dacl_add_ace("OU=ou1," + self.base_dn, mod)
tmp_desc = security.descriptor.from_sddl("D:(A;;RPWPCRCCDCLCLORCWOWDSDDTSW;;;DA)" + mod,
self.domain_sid)
self.ldb_admin.create_ou("OU=ou2,OU=ou1," + self.base_dn, sd=tmp_desc)
self.ldb_admin.create_ou("OU=ou3,OU=ou2,OU=ou1," + self.base_dn,
sd=tmp_desc)
self.ldb_admin.create_ou("OU=ou4,OU=ou2,OU=ou1," + self.base_dn,
sd=tmp_desc)
self.ldb_admin.create_ou("OU=ou5,OU=ou3,OU=ou2,OU=ou1," + self.base_dn,
sd=tmp_desc)
self.ldb_admin.create_ou("OU=ou6,OU=ou4,OU=ou2,OU=ou1," + self.base_dn,
sd=tmp_desc)
ou2_dn = Dn(self.ldb_admin, "OU=ou2,OU=ou1," + self.base_dn)
ou1_dn = Dn(self.ldb_admin, "OU=ou1," + self.base_dn)
# even though unprivileged users can't read these attributes for OU2,
# the object should still be visible in searches, because they have
# 'List Contents' rights still. This isn't really disclosive because
# ALL objects have these attributes
visible_attrs = ["objectClass", "distinguishedName", "name",
"objectGUID"]
two_objects = [ou2_dn, ou1_dn]
for attr in visible_attrs:
# a regular user should just see the 2 objects
self.assert_search_on_attr(str(ou1_dn), self.ldb_user3, attr,
expected_list=two_objects)
# whereas the following users have LC rights for all the objects,
# so they should see them all
self.assert_search_on_attr(str(ou1_dn), self.ldb_user, attr,
expected_list=self.full_list)
self.assert_search_on_attr(str(ou1_dn), self.ldb_user2, attr,
expected_list=self.full_list)
# however when searching on the following attributes, objects will not
# be visible unless the user has Read Property rights
hidden_attrs = ["objectCategory", "instanceType", "ou", "uSNChanged",
"uSNCreated", "whenCreated"]
one_object = [ou1_dn]
for attr in hidden_attrs:
self.assert_search_on_attr(str(ou1_dn), self.ldb_user3, attr,
expected_list=one_object)
self.assert_search_on_attr(str(ou1_dn), self.ldb_user, attr,
expected_list=one_object)
self.assert_search_on_attr(str(ou1_dn), self.ldb_user2, attr,
expected_list=one_object)
# admin has RP rights so can still see all the objects
self.assert_search_on_attr(str(ou1_dn), self.ldb_admin, attr,
expected_list=self.full_list)
#tests on ldap delete operations
class AclDeleteTests(AclTests):