]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Test bogus KDC-REQs
authorTom Yu <tlyu@mit.edu>
Wed, 1 Jan 2014 00:43:28 +0000 (19:43 -0500)
committerTom Yu <tlyu@mit.edu>
Wed, 1 Jan 2014 01:40:35 +0000 (20:40 -0500)
Send encodings that are invalid KDC-REQs, but pass krb5_is_as_req()
and krb5_is_tgs_req(), to make sure that the KDC recovers correctly
from failures in decode_krb5_as_req() and decode_krb5_tgs_req().  Also
send an encoding that isn't a valid KDC-REQ.

ticket: 7811 (new)
target_version: 1.12.1
tags: pullup

src/tests/Makefile.in
src/tests/t_bogus_kdc_req.py [new file with mode: 0644]

index a412ba9a8e19e10bf00439f0b922366c2e12433f..2bd7a5ce1d36da2fce79453a2673310feeca60f7 100644 (file)
@@ -128,6 +128,7 @@ check-pytests:: t_init_creds t_localauth
        $(RUNPYTEST) $(srcdir)/jsonwalker.py -d $(srcdir)/au_dict.json \
                        -i au.log
        $(RUNPYTEST) $(srcdir)/t_salt.py $(PYTESTFLAGS)
+       $(RUNPYTEST) $(srcdir)/t_bogus_kdc_req.py $(PYTESTFLAGS)
 
 clean::
        $(RM) gcred hist hrealm kdbtest plugorder responder s2p
diff --git a/src/tests/t_bogus_kdc_req.py b/src/tests/t_bogus_kdc_req.py
new file mode 100644 (file)
index 0000000..b6208ca
--- /dev/null
@@ -0,0 +1,44 @@
+#!/usr/bin/python
+
+import base64
+import socket
+from k5test import *
+
+realm = K5Realm()
+
+# Send encodings that are invalid KDC-REQs, but pass krb5_is_as_req()
+# and krb5_is_tgs_req(), to make sure that the KDC recovers correctly
+# from failures in decode_krb5_as_req() and decode_krb5_tgs_req().
+
+s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+a = (hostname, realm.portbase)
+
+
+# Bogus AS-REQ
+
+x1 = base64.b16decode('6AFF')
+s.sendto(x1, a)
+
+# Make sure kinit still works.
+
+realm.kinit(realm.user_princ, password('user'))
+
+# Bogus TGS-REQ
+
+x2 = base64.b16decode('6CFF')
+s.sendto(x2, a)
+
+# Make sure kinit still works.
+
+realm.kinit(realm.user_princ, password('user'))
+
+# Not a KDC-REQ, even a little bit
+
+x3 = base64.b16decode('FFFF')
+s.sendto(x3, a)
+
+# Make sure kinit still works.
+
+realm.kinit(realm.user_princ, password('user'))
+
+success('Bogus KDC-REQ test')