RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1266404 - Memory leak / possible DoS with krb auth. [rhel 6.8.0]
Summary: Memory leak / possible DoS with krb auth. [rhel 6.8.0]
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: sssd
Version: 6.7
Hardware: Unspecified
OS: Unspecified
urgent
urgent
Target Milestone: rc
: 6.8
Assignee: SSSD Maintainers
QA Contact: Namita Soman
URL:
Whiteboard:
: 1272051 (view as bug list)
Depends On:
Blocks: CVE-2015-5292 1268783
TreeView+ depends on / blocked
 
Reported: 2015-09-25 08:17 UTC by Martin Schuppert
Modified: 2020-05-04 10:50 UTC (History)
15 users (show)

Fixed In Version: sssd-1.12.4-51.el6
Doc Type: Release Note
Doc Text:
Clone Of:
: 1267176 1268783 (view as bug list)
Environment:
Last Closed: 2016-05-10 20:19:53 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
FedoraHosted SSSD 2803 0 None None None Never
Github SSSD sssd issues 3844 0 None None None 2020-05-04 10:50:13 UTC
Red Hat Product Errata RHBA-2016:0782 0 normal SHIPPED_LIVE sssd bug fix and enhancement update 2016-05-10 22:36:00 UTC

Description Martin Schuppert 2015-09-25 08:17:26 UTC
Description of problem:

Back port request for upstream fix at https://fedorahosted.org/sssd/ticket/2803#comment:3 to RHEL6

From there:
We believe there is a memory leak in the sssd_pac_plugin (sssd_pac_plugin.so library) distributed with the sssd_client package. 

The issue was revealed in one of our daemons using kerberos 5 authentication and leaking gigabytes of memory after several days (1GB/day on average for 10 authentications per second). Putting it in valgrind, we found the following :

==27734== 1,344 (+1,344) (32 (+32) direct, 1,312 (+1,312) indirect) bytes in 1 (+1) blocks are definitely lost in loss record 484 of 540
==27734==    at 0x4A06A2E: malloc (vg_replace_malloc.c:270)
==27734==    by 0x50D96C2: krb5_pac_init (pac.c:231)
==27734==    by 0x50D9D2D: krb5_pac_parse (pac.c:332)
==27734==    by 0x19C70CA6: sssdpac_verify (sssd_pac.c:144)
==27734==    by 0x50C1E52: krb5int_authdata_verify (authdata.c:617)
==27734==    by 0x50E19CF: rd_req_decoded_opt (rd_req_dec.c:437)
==27734==    by 0x50E1A59: krb5_rd_req_decoded (rd_req_dec.c:599)
==27734==    by 0x50E0A88: krb5_rd_req (rd_req.c:87)
==27734==    by 0x4E49770: kg_accept_krb5 (accept_sec_context.c:643)
==27734==    by 0x4E4B0A9: krb5_gss_accept_sec_context_ext (accept_sec_context.c:1338)
==27734==    by 0x4E4B208: krb5_gss_accept_sec_context (accept_sec_context.c:1367)
==27734==    by 0x4E3AC22: gss_accept_sec_context (g_accept_sec_context.c:203)
==27734==    by 0x19A6C728: Csec_server_establish_context_ext_KRB5 (Csec_plugin_GSS.c:482)
==27734==    by 0x834EBC2: Csec_server_establish_context_ext_caller (Csec_plugin.h:129)
==27734==    by 0x835416A: Csec_server_establish_context_ext (Csec_api.c:277)
==27734==    by 0x8353FE4: Csec_server_establishContext (Csec_api.c:218)
==27734==    by 0x406407: doit (Cns_main.c:747)
==27734==    by 0x8129420: _Cpool_starter (Cpool.c:377)
==27734==    by 0x8124914: _Cthread_start_pthread (Cthread.c:209)
==27734==    by 0x30CCA07A50: start_thread (pthread_create.c:301)
==27734==    by 0x30CC6E89AC: clone (clone.S:115)

The study of the corresponding code clearly shows a genuine bug introduced in sssd_client via commit 92af6f25 in May 2013. Here are the details :

    in krb5int_authdata_verify (authdata.c:617), so krb5 code, the plugin is called :

       code = (*module->ftable->verify)(kcontext,
                                        context,
                                        module->plugin_context,
                                        *(module->request_context_pp),
                                        auth_context,
                                        key,
                                        ap_req);

    this calls sssdpac_verify (sssd_pac.c:144) and the code looks like this (I've dropped irrelevant lines and commented) :

         krb5_pac pac;   // krb5_pac is actually a pointer type
         ...
         kerr = krb5_pac_parse(kcontext, sssdctx->data.data,    // allocation of the pac pointer from input data
                               sssdctx->data.length, &pac);
         ...
         kerr = krb5_pac_verify(kcontext, pac,                  // verification of the pac content
                                req->ticket->enc_part2->times.authtime,
                                req->ticket->enc_part2->client, key, NULL);
         ...           // no reference to pac
         return 0;     // memory leak!

    I did check the code of parse and verify, and they are doing what you expect, so no hidden ref count or anything special. 

So according to all this, the patch to the leak is the following :

diff --git a/src/sss_client/sssd_pac.c b/src/sss_client/sssd_pac.c
index 1939f61..1d1fe8a 100644
--- a/src/sss_client/sssd_pac.c
+++ b/src/sss_client/sssd_pac.c
@@ -150,6 +150,10 @@ static krb5_error_code sssdpac_verify(krb5_context kcontext,
     kerr = krb5_pac_verify(kcontext, pac,
                            req->ticket->enc_part2->times.authtime,
                            req->ticket->enc_part2->client, key, NULL);
+    // deallocate pac - fixes memory leak reported in bug ...
+    krb5_pac_free(kcontext, pac);
+    pac = NULL;
+    // check result of the verification
     if (kerr != 0) {
         /* The krb5 documentation says:
          * A checksum mismatch can occur if the PAC was copied from a


Version-Release number of selected component (if applicable):

This has been found on a machine running the following versions of kerberos and sssd :

  krb5-workstation-1.10.3-33.el6.x86_64
  krb5-libs-1.10.3-33.el6.i686
  krb5-libs-1.10.3-33.el6.x86_64
  sssd-client-1.12.4-47.el6.x86_64

Comment 2 Jakub Hrozek 2015-09-25 08:22:42 UTC
Upstream ticket:
https://fedorahosted.org/sssd/ticket/2803

Comment 3 Jakub Hrozek 2015-09-25 08:24:08 UTC
Upstream ticket:
https://fedorahosted.org/sssd/ticket/2803

Comment 4 Jakub Hrozek 2015-09-25 08:26:51 UTC
Marking as POST since the problem is already fixed in upstream with a patch kindly provided by Thomas Oulevey. The commit hash is b4c44ebb8997d3debb33607c123ccfd9926e0cba

Comment 13 Martin Prpič 2015-10-20 11:19:18 UTC
*** Bug 1272051 has been marked as a duplicate of this bug. ***

Comment 15 Sudhir Menon 2016-03-09 10:57:35 UTC
Verified using 
RHEL7.2 ipa-server-4.2.0-15.el7_2.3.x86_64
RHEL6.8 
ipa-client-3.0.0-50.el6.x86_64
sssd-client-1.13.3-17.el6.x86_64
krb5-libs-1.10.3-56.el6.x86_64
krb5-workstation-1.10.3-56.el6.x86_64

==On IPA Client===
[root@r683 ~]# ssh  -K -l aduser1 `hostname`
Last login: Wed Mar  9 16:24:02 2016 from r683.dhcp20797.in
-sh-4.1$ id
uid=760201642(aduser1) gid=760201642(aduser1) groups=760201642(aduser1),760200513(domain users),760201640(adgroup1),760201641(adgroup2) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023

Comment 17 errata-xmlrpc 2016-05-10 20:19:53 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-0782.html


Note You need to log in before you can comment on or make changes to this bug.