xref: /freebsd/crypto/krb5/src/tests/t_cve-2012-1015.py (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy Schubertimport base64
2*7f2fe78bSCy Schubertimport socket
3*7f2fe78bSCy Schubertfrom k5test import *
4*7f2fe78bSCy Schubert
5*7f2fe78bSCy Schubertrealm = K5Realm()
6*7f2fe78bSCy Schubert
7*7f2fe78bSCy Schubert# CVE-2012-1015 KDC frees uninitialized pointer
8*7f2fe78bSCy Schubert
9*7f2fe78bSCy Schubert# Force a failure in krb5_c_make_checksum(), which causes the cleanup
10*7f2fe78bSCy Schubert# code in kdc_handle_protected_negotiation() to free an uninitialized
11*7f2fe78bSCy Schubert# pointer in an unpatched KDC.
12*7f2fe78bSCy Schubert
13*7f2fe78bSCy Schuberts = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
14*7f2fe78bSCy Schuberta = (hostname, realm.portbase)
15*7f2fe78bSCy Schubert
16*7f2fe78bSCy Schubertx1 = base64.b16decode('6A81A030819DA103020105A20302010A' +
17*7f2fe78bSCy Schubert                      'A30E300C300AA10402020095A2020400' +
18*7f2fe78bSCy Schubert                      'A48180307EA00703050000000000A120' +
19*7f2fe78bSCy Schubert                      '301EA003020101A11730151B066B7262' +
20*7f2fe78bSCy Schubert                      '7467741B0B4B5242544553542E434F4D' +
21*7f2fe78bSCy Schubert                      'A20D1B0B4B5242544553542E434F4DA3' +
22*7f2fe78bSCy Schubert                      '20301EA003020101A11730151B066B72' +
23*7f2fe78bSCy Schubert                      '627467741B0B4B5242544553542E434F' +
24*7f2fe78bSCy Schubert                      '4DA511180F3139393430363130303630' +
25*7f2fe78bSCy Schubert                      '3331375AA7030201')
26*7f2fe78bSCy Schubert
27*7f2fe78bSCy Schubertx2 = base64.b16decode('A8083006020106020112')
28*7f2fe78bSCy Schubert
29*7f2fe78bSCy Schubertfor x in range(0, 128):
30*7f2fe78bSCy Schubert    s.sendto(x1 + bytes([x]) + x2, a)
31*7f2fe78bSCy Schubert
32*7f2fe78bSCy Schubert# Make sure kinit still works.
33*7f2fe78bSCy Schubert
34*7f2fe78bSCy Schubertrealm.kinit(realm.user_princ, password('user'))
35*7f2fe78bSCy Schubert
36*7f2fe78bSCy Schubertsuccess('CVE-2012-1015 regression test')
37