{"id":16663,"date":"2021-07-08T11:45:26","date_gmt":"2021-07-08T09:45:26","guid":{"rendered":"https:\/\/herolab-usd.formwandler.rocks\/security-advisories\/usd-2020-0004\/"},"modified":"2021-07-19T14:14:34","modified_gmt":"2021-07-19T12:14:34","slug":"usd-2020-0004","status":"publish","type":"page","link":"https:\/\/herolab.usd.de\/en\/security-advisories\/usd-2020-0004\/","title":{"rendered":"usd-2020-0004"},"content":{"rendered":"<p>[et_pb_section fb_built=\"1\" _builder_version=\"4.9.4\" _module_preset=\"default\" background_color=\"#2E353D\" custom_padding=\"||0px|||\"][et_pb_row _builder_version=\"4.9.4\" _module_preset=\"default\"][et_pb_column type=\"4_4\" _builder_version=\"4.9.4\" _module_preset=\"default\"][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"cc5ac6f4-ebbd-4b3f-bc92-4dfc1f15fe2c\"]<\/p>\n<h1 class=\"h-custom-headline usd-small-letters h2\"><span>usd-2020-0004 | Nagios NRPE v.3.2.1<\/span><\/h1>\n<p><span><\/span><br \/><strong>Advisory ID<\/strong><span>: usd-2020-0004<\/span><br \/><strong>Affected Product<\/strong><span>: Nagios NRPE<\/span><br \/><strong>Affected Version<\/strong><span>: v.3.2.1<\/span><br \/><strong>Vulnerability Type<\/strong><span>: Logic Error<\/span><br \/><strong>Security Risk<\/strong><span>: None<\/span><br \/><strong>Vendor URL<\/strong><span>: <a href=\"https:\/\/www.nagios.org\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.nagios.org\/<\/a><\/span><br \/><strong>Vendor Status<\/strong><span>: Fixed in v.4.0.0 (not verified)<\/span><\/p>\n<h3><\/h3>\n<h3>Description<\/h3>\n<p>If NRPE is compiled with command line parameter support and if the corresponding option is enabled inside of the NRPE configuration file,<br \/>NRPE are allowed to contain additional parameters that are passed as command line parameters to the configured monitoring scripts.<\/p>\n<p>To check if a packet contains command line parameters, NRPE uses the <strong>validate_request<\/strong>\u00a0function. This function contains the following code:<\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"9e260d37-0be2-4a12-a10e-3ed7e27b6ac6\" hover_enabled=\"0\" sticky_enabled=\"0\"] if (packet_ver == NRPE_PACKET_VERSION_3) {<br \/>\nint32_t   l = ntohs(v3pkt-&amp;gt;buffer_length);<br \/>\nv3pkt-&amp;gt;buffer[l - 1] = '\\x0';<br \/>\nbuff = v3pkt-&amp;gt;buffer;<br \/>\n} else {<br \/>\nv2pkt-&amp;gt;buffer[MAX_PACKETBUFFER_LENGTH - 1] = '\\x0';<br \/>\nbuff = v2pkt-&amp;gt;buffer;<br \/>\n}<\/p>\n<p>[...]<\/p>\n<p>\/* make sure the request doesn't contain arguments *\/<br \/>\nif (strchr(v2pkt-&amp;gt;buffer, '!')) {<br \/>\n#ifdef ENABLE_COMMAND_ARGUMENTS<br \/>\nif (allow_arguments == FALSE) {<br \/>\nlogit(LOG_ERR, \"Error: Request contained command arguments, but argument option is not enabled!\");<br \/>\nreturn ERROR;<br \/>\n}<br \/>\n[...]<\/code><\/pre>\n<p>[\/et_pb_text][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"cc5ac6f4-ebbd-4b3f-bc92-4dfc1f15fe2c\"]<\/p>\n<p>As on can see, this code should block requests if the <em>ENABLE_COMMAND_ARGUMENTS<\/em> flag was set during compilation, but the <strong>allow_arguments<\/strong><br \/>option (dont_blame_nrpe) is not enabled in the configuration file. NRPE packets that contain command line arguments have to contain a <strong>!<\/strong><br \/>sign in their buffer and therefore the above mentioned code should trigger and block the request.<\/p>\n<p>However, as one can see, the code uses the <strong>v2pkt-&gt;buffer<\/strong> instead of the previously declared generic <strong>buff<\/strong>\u00a0variable. Incoming v3 packets<br \/>will never trigger the condition strchr(v2pkt-&gt;buffer, \u201a!\u2018), and will pass this check even if they contain command line arguments.<\/p>\n<p>While this sounds like a serious security issue, it has only minimal impact, since the NRPE source code does only parse command line arguments<br \/>if the <strong>allow_arguments<\/strong>\u00a0(dont_blame_nrpe) option was set:<\/p>\n<p>[\/et_pb_text][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"9e260d37-0be2-4a12-a10e-3ed7e27b6ac6\" hover_enabled=\"0\" sticky_enabled=\"0\"]   #ifdef ENABLE_COMMAND_ARGUMENTS<br \/>\n\/* get command arguments *\/<br \/>\nif (allow_arguments == TRUE) {<br \/>\n\/\/ Process Command Line Args<\/code><\/pre>\n<p>[\/et_pb_text][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"cc5ac6f4-ebbd-4b3f-bc92-4dfc1f15fe2c\"]<\/p>\n<div class=\"e16902-22 x-container max width\">\n<div class=\"e16902-23 x-column x-sm x-1-1\">\n<div class=\"e14110-7 x-container max width\">\n<div class=\"e14110-8 x-column x-sm x-1-1\">\n<div class=\"x-text\">Therefore, even if a v3 packet passes the first check, its arguments will just be ignored in the proceeding code.<br \/>Nonetheless, this is obviously a logical flaw inside the NRPE source code and should be fixed.<\/div>\n<div class=\"x-text\"><\/div>\n<h3 class=\"x-text\"><\/h3>\n<h3 class=\"x-text\"><span><\/span><\/h3>\n<h3 class=\"x-text\"><span>Proof of Concept (PoC) \/ Steps to Reproduce<\/span><\/h3>\n<\/div>\n<\/div>\n<p>0. NRPE has to be compiled with command line parameter support. Additionally, dont_blame_nrpe option inside the NRPE configuration file has to be enabled.<\/p>\n<p>1. Send a v2 packet that contains command line arguments (Packet is rejected).<\/p>\n<p>2. Send a v3 packet that contains command line arguments. (Packet is processed, like a packet without any arguments)<\/p>\n<h3><\/h3>\n<h3><\/h3>\n<h3>Fix<\/h3>\n<p><span>Checking for <\/span><strong>!<\/strong><span> signs should be done on the generic buffer <\/span><strong>buff<\/strong><span>, which applies for v2 and v3 packets.<\/span><\/p>\n<h3><\/h3>\n<h3>Timeline<\/h3>\n<ul>\n<li>2020-01-06 Tobias Neitzel found this vulnerability by manual code review of Nagios NRPE<\/li>\n<li>2020-01-08 Initial Contact<\/li>\n<li>2020-01-15 Nagios NRPE v4.0.0 is released: <a href=\"https:\/\/github.com\/NagiosEnterprises\/nrpe\/releases\/tag\/nrpe-4.0.0\" target=\"_blank\" rel=\"noopener\">https:\/\/github.com\/NagiosEnterprises\/nrpe\/releases\/tag\/nrpe-4.0.0<\/a><\/li>\n<li>2020-03-04 security advisory released<\/li>\n<\/ul>\n<h3>Credits<\/h3>\n<p><span>This security vulnerability was discovered by Tobias Neitzel of usd AG.<\/span><\/p>\n<\/div>\n<\/div>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>usd-2020-0004 | Nagios NRPE v.3.2.1 Advisory ID: usd-2020-0004Affected Product: Nagios NRPEAffected Version: v.3.2.1Vulnerability Type: Logic ErrorSecurity Risk: NoneVendor URL: https:\/\/www.nagios.org\/Vendor Status: Fixed in v.4.0.0 (not verified) Description If NRPE is compiled with command line parameter support and if the corresponding option is enabled inside of the NRPE configuration file,NRPE are allowed to contain additional parameters [&hellip;]<\/p>\n","protected":false},"author":96,"featured_media":0,"parent":16124,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","inline_featured_image":false,"footnotes":""},"class_list":["post-16663","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages\/16663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/users\/96"}],"replies":[{"embeddable":true,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/comments?post=16663"}],"version-history":[{"count":0,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages\/16663\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages\/16124"}],"wp:attachment":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/media?parent=16663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}