CVE-2023-0614 ldb: Prevent disclosure of confidential attributes
commitc1921f5ae0840c455ad18b2fa19839242bd8a3e8
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Fri, 3 Mar 2023 04:34:29 +0000 (3 17:34 +1300)
committerJule Anger <janger@samba.org>
Mon, 20 Mar 2023 09:03:45 +0000 (20 10:03 +0100)
tree4a335e233dc282632c6b55318280cbb257b93219
parent2e3ed6cfd24cb5f4d75d248cca1eb791c6c44250
CVE-2023-0614 ldb: Prevent disclosure of confidential attributes

Add a hook, acl_redact_msg_for_filter(), in the aclread module, that
marks inaccessible any message elements used by an LDAP search filter
that the user has no right to access. Make the various ldb_match_*()
functions check whether message elements are accessible, and refuse to
match any that are not. Remaining message elements, not mentioned in the
search filter, are checked in aclread_callback(), and any inaccessible
elements are removed at this point.

Certain attributes, namely objectClass, distinguishedName, name, and
objectGUID, are always present, and hence the presence of said
attributes is always allowed to be checked in a search filter. This
corresponds with the behaviour of Windows.

Further, we unconditionally allow the attributes isDeleted and
isRecycled in a check for presence or equality. Windows is not known to
make this special exception, but it seems mostly harmless, and should
mitigate the performance impact on searches made by the show_deleted
module.

As a result of all these changes, our behaviour regarding confidential
attributes happens to match Windows more closely. For the test in
confidential_attr.py, we can now model our attribute handling with
DC_MODE_RETURN_ALL, which corresponds to the behaviour exhibited by
Windows.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15270

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
[abartlet@samba.org adapted due to Samba 4.17 and lower
not having the patches for CVE-2020-25720]
12 files changed:
lib/ldb-samba/ldb_matching_rules.c
lib/ldb/common/ldb_match.c
lib/ldb/include/ldb_module.h
lib/ldb/include/ldb_private.h
lib/ldb/ldb_key_value/ldb_kv_index.c
lib/ldb/ldb_key_value/ldb_kv_search.c
selftest/knownfail.d/confidential-attr-timing [deleted file]
source4/dsdb/samdb/ldb_modules/acl.c
source4/dsdb/samdb/ldb_modules/acl_read.c
source4/dsdb/samdb/samdb.h
source4/dsdb/tests/python/confidential_attr.py
source4/setup/schema_samba4.ldif