CVE-2022-0336: pytest: Add a test for an SPN conflict with a re-added SPN
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Mon, 17 Jan 2022 22:56:38 +0000 (11:56 +1300)
committerStefan Metzmacher <metze@samba.org>
Mon, 31 Jan 2022 15:27:37 +0000 (15:27 +0000)
This test currently fails, as re-adding an SPN means that later checks
do not run.

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

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/tests/ldap_spn.py
selftest/knownfail.d/ldap_spn

index 8a398ffaa491e89bcbd3f35f7b20e31b1818bed9..6ebdf8f9a32d4d737944fd4850d41e43e791013c 100644 (file)
@@ -268,6 +268,8 @@ class LdapSpnTestBase(TestCase):
             for k in ('dNSHostName', 'servicePrincipalName'):
                 if isinstance(m.get(k), str):
                     m[k] = m[k].format(dnsname=f"x.{REALM}")
+                elif isinstance(m.get(k), list):
+                    m[k] = [x.format(dnsname=f"x.{REALM}") for x in m[k]]
 
             msg = ldb.Message.from_dict(samdb, m, op)
 
@@ -727,6 +729,11 @@ class LdapSpnSambaOnlyTest(LdapSpnTestBase):
          ('user:C', 'host/{dnsname}', '*', ok),
          ('user:D', 'www/{dnsname}', 'D', denied),
         ),
+        ("add a conflict, along with a re-added SPN",
+         ('A', 'cifs/{dnsname}', '*', ok),
+         ('B', 'cifs/heeble.example.net', 'B', ok),
+         ('B', ['cifs/heeble.example.net', 'host/{dnsname}'], 'B', constraint),
+        ),
 
         ("changing dNSHostName after host",
          ('A', {'dNSHostName': '{dnsname}'}, '*', ok),
index 63f9fe02ef7df4b0b9880b2ea23325df7e7954f2..16dafa91b665e6e838032dc933ec5ce6ebca7b75 100644 (file)
@@ -1 +1,2 @@
 samba.tests.ldap_spn.+LdapSpnTest.test_spn_dodgy_spns
+samba.tests.ldap_spn.+LdapSpnSambaOnlyTest.test_spn_add_a_conflict_along_with_a_re_added_SPN