CVE-2023-0614 s4:dsdb/extended_dn_in: Don't modify a search tree we don't own
commit5f6e01c029d17eb277e6e3d81b14d3b79ea71463
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Mon, 6 Feb 2023 20:35:24 +0000 (7 09:35 +1300)
committerJule Anger <janger@samba.org>
Mon, 20 Mar 2023 09:03:50 +0000 (20 10:03 +0100)
treee2685f2d1059d8d99df502874d778d779d0e560a
parent7689a2caeb4d804b671cdffbc4251279dd7d3783
CVE-2023-0614 s4:dsdb/extended_dn_in: Don't modify a search tree we don't own

In extended_dn_fix_filter() we had:

    req->op.search.tree = ldb_parse_tree_copy_shallow(req, req->op.search.tree);

which overwrote the parse tree on an existing ldb request with a fixed
up tree. This became a problem if a module performed another search with
that same request structure, as extended_dn_in would try to fix up the
already-modified tree for a second time. The fixed-up tree element now
having an extended DN, it would fall foul of the ldb_dn_match_allowed()
check in extended_dn_filter_callback(), and be replaced with an
ALWAYS_FALSE match rule. In practice this meant that <GUID={}> searches
would only work for one search in an ldb request, and fail for
subsequent ones.

Fix this by creating a new request with the modified tree, and leaving
the original request unmodified.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/dsdb/samdb/ldb_modules/extended_dn_in.c