Stack-based buffer overflow in ntpq and ntpdc of NTP version 4.2.8p11 allows an attacker to achieve code execution or escalate to higher privileges via a long string as the argument for an IPv4 or IPv6 command-line parameter. NOTE: It is unclear whether there are any common situations in which ntpq or ntpdc is used with a command line from an untrusted source. References: https://gist.github.com/fakhrizulkifli/9b58ed8e0354e8deee50b0eebd1c011f
Created ntp tracking bugs for this issue: Affects: fedora-all [bug 1593581]
Vulnerable code: 623 static int 624 openhost( 625 const char *hname 626 ) 627 { 628 char temphost[LENHOSTNAME]; 629 int a_info, i; 630 struct addrinfo hints, *ai = NULL; 631 register const char *cp; 632 char name[LENHOSTNAME]; 633 char service[5]; 634 635 /* 636 * We need to get by the [] if they were entered 637 */ 638 639 cp = hname; 640 641 if (*cp == '[') { 642 cp++; 643 for (i = 0; *cp && *cp != ']'; cp++, i++) 644 name[i] = *cp; 645 if (*cp == ']') { 646 name[i] = '\0'; 647 hname = name; 648 } else { 649 return 0; 650 } 651 } The memory corruption happens in openhost() function which takes the hostname as given on the input and then it copies it into an array allocated on stack called 'name' with a fixed size LENHOSTNAME defined as 256. It doesn't check bounds when doing the copy. The same vulnerable pattern can be found in both ntpq.c and ntpdc.c files. Our builds have stack smashing protection which detects the overflow and terminates the program, making the exploitation (i.e. arbitrary code execution) more difficult.
This issue has been addressed in the following products: Red Hat Enterprise Linux 6.7 Extended Update Support Via RHSA-2018:3853 https://access.redhat.com/errata/RHSA-2018:3853
This issue has been addressed in the following products: Red Hat Enterprise Linux 6 Via RHSA-2018:3854 https://access.redhat.com/errata/RHSA-2018:3854
Statement: This issue affects the versions of ntp as shipped with Red Hat Enterprise Linux 7. Red Hat Product Security has rated this issue as having a security impact of Low. A future update may address this issue. For additional information, refer to the Issue Severity Classification: https://access.redhat.com/security/updates/classification/. This issue affects the versions of ntp as shipped with Red Hat Enterprise Linux 5. Red Hat Enterprise Linux 5 is now in Extended Life Phase of the support and maintenance life cycle. This issue is not currently planned to be addressed in future updates. For additional information, refer to the Red Hat Enterprise Linux Life Cycle: https://access.redhat.com/support/policy/updates/errata/.
This issue has been addressed in the following products: Red Hat Enterprise Linux 7 Via RHSA-2019:2077 https://access.redhat.com/errata/RHSA-2019:2077
This issue has been addressed in the following products: Red Hat Enterprise Linux 7.6 Extended Update Support Via RHSA-2020:1470 https://access.redhat.com/errata/RHSA-2020:1470