{"id":529,"date":"2019-07-31T15:01:38","date_gmt":"2019-07-31T13:01:38","guid":{"rendered":"https:\/\/www.calypt.com\/blog\/?p=529"},"modified":"2019-09-12T16:05:39","modified_gmt":"2019-09-12T14:05:39","slug":"authenticated-rce-on-webmin","status":"publish","type":"post","link":"https:\/\/www.calypt.com\/blog\/index.php\/authenticated-rce-on-webmin\/","title":{"rendered":"CVE-2019-15642 &#8211; Authenticated RCE on Webmin <= 1.920"},"content":{"rendered":"\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"600\" height=\"150\" src=\"https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/08\/2019-07-30-224808_1076x269_scrot-1024x256.png\" alt=\"\" class=\"wp-image-560\"\/><\/figure>\n\n\n\n<h2>Rpc.cgi<\/h2>\n\n\n<p style=\"text-align: justify;\">After the <a href=\"https:\/\/www.calypt.com\/blog\/index.php\/authenticated-xxe-on-webmin\/\">XXE<\/a>, we found another bug in <a href=\"http:\/\/www.webmin.com\">Webmin<\/a>. This time it&#8217;s <a href=\"https:\/\/github.com\/webmin\/webmin\/blob\/master\/rpc.cgi\"><em>rpc.cgi<\/em><\/a> which is vulnerable. More precisely a call to &#8220;unserialise_variable&#8221; function is done before than checking if the current user is root, admin or sysadm. As parameter of &#8220;unserialise_variable&#8221;, there is the content of the HTTP POST request :<\/p>\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"885\" height=\"972\" src=\"https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/07\/2019-07-31-110751_885x972_scrot.png\" alt=\"\" class=\"wp-image-532\" srcset=\"https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/07\/2019-07-31-110751_885x972_scrot.png 885w, https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/07\/2019-07-31-110751_885x972_scrot-273x300.png 273w, https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/07\/2019-07-31-110751_885x972_scrot-768x843.png 768w\" sizes=\"(max-width: 885px) 100vw, 885px\" \/><figcaption>rpc.cgi is calling unserialise_variable()<\/figcaption><\/figure>\n\n\n\n<h2>Web-lib-funcs.pl<\/h2>\n\n\n<p>In order to call <em>rpc.cgi<\/em> and trigger the vulnerability we need 2 prerequisites :<\/p>\n<ul>\n<li><strong>User-agent set to &#8220;webmin&#8221;<\/strong> (Webmin interprets this as log with basic auth rather than session cookie) ;<\/li>\n<li><strong>Valid Basic auth<\/strong> for a user of Webmin (for this exemple, we use a freshly created user &#8220;toto&#8221; with default rights).<\/li>\n<\/ul>\n<p>Once these two conditions are met we can go further and look around <em>unserialise_variable<\/em> in <a href=\"https:\/\/github.com\/webmin\/webmin\/blob\/master\/web-lib-funcs.pl\">web-lib-funcs.pl<\/a> :<\/p>\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"716\" height=\"1024\" src=\"https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/07\/2019-07-31-112618_949x1358_scrot-716x1024.png\" alt=\"\" class=\"wp-image-533\" srcset=\"https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/07\/2019-07-31-112618_949x1358_scrot-716x1024.png 716w, https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/07\/2019-07-31-112618_949x1358_scrot-210x300.png 210w, https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/07\/2019-07-31-112618_949x1358_scrot-768x1099.png 768w, https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/07\/2019-07-31-112618_949x1358_scrot.png 949w\" sizes=\"(max-width: 716px) 100vw, 716px\" \/><figcaption>Evil eval<\/figcaption><\/figure>\n\n\n<p>If someone POST an OBJECT it will be used directly in the &#8220;eval&#8221; statement and so&#8230; executed&#8230; as root. More precisely it&#8217;s $cls that will be executed which corresponds to the regexp match.<\/p>\n\n\n<h2>Exploit<\/h2>\n\n\n<p>The only thing left to do is write our own code and display the result.<\/p>\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"638\" height=\"484\" src=\"https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/07\/2019-07-31-115451_638x484_scrot.png\" alt=\"\" class=\"wp-image-539\" srcset=\"https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/07\/2019-07-31-115451_638x484_scrot.png 638w, https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/07\/2019-07-31-115451_638x484_scrot-395x300.png 395w\" sizes=\"(max-width: 638px) 100vw, 638px\" \/><\/figure>\n\n\n\n<h2>Response from vendor \/ fix<\/h2>\n\n\n<blockquote>\n<p>Thanks for the bug report! Can you check if this patch fixes the issue for you :&nbsp;<a href=\"https:\/\/github.com\/webmin\/webmin\/commit\/df8a43fb4bdc9c858874f72773bcba597ae9432c\" target=\"_blank\" rel=\"noopener noreferrer\" data-saferedirecturl=\"https:\/\/www.google.com\/url?q=https:\/\/github.com\/webmin\/webmin\/commit\/df8a43fb4bdc9c858874f72773bcba597ae9432c&amp;source=gmail&amp;ust=1566978128188000&amp;usg=AFQjCNEXnfGuXyMr9vpB6zOrw6ay5D0Cuw\">https:\/\/github.com\/webmin\/<wbr>webmin\/commit\/<wbr>df8a43fb4bdc9c858874f72773bcba<wbr>597ae9432c<\/a><\/p>\n<p>Fortunately this isn&#8217;t super high risk, <strong>as any Webmin user with permissions to call rpc.cgi can already execute any code was root<\/strong>.&nbsp;<\/p>\n<\/blockquote>\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"449\" src=\"https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-26-153120_1504x660_scrot-1024x449.png\" alt=\"\" class=\"wp-image-551\" srcset=\"https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-26-153120_1504x660_scrot-1024x449.png 1024w, https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-26-153120_1504x660_scrot-600x263.png 600w, https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-26-153120_1504x660_scrot-768x337.png 768w, https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/08\/2019-08-26-153120_1504x660_scrot.png 1504w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Rpc.cgi After the XXE, we found another bug in Webmin. This time it&#8217;s rpc.cgi which is vulnerable. More precisely a call to &#8220;unserialise_variable&#8221; function is done before than checking if the current user is root, admin or sysadm. As parameter of &#8220;unserialise_variable&#8221;, there is the content of the HTTP POST request : Web-lib-funcs.pl In order [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[1],"tags":[68,70,74,69,73],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v16.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<meta name=\"description\" content=\"How to exploit the remote code execution vulnerability on Webmin known as CVE-2019-XXXXX. Authenticated RCE+LPE in Webmin &lt;= 1.920\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.calypt.com\/blog\/index.php\/authenticated-rce-on-webmin\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CVE-2019-15642 - Authenticated RCE on Webmin\" \/>\n<meta property=\"og:description\" content=\"How to exploit the remote code execution vulnerability on Webmin known as CVE-2019-XXXXX. Authenticated RCE+LPE in Webmin &lt;= 1.920\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.calypt.com\/blog\/index.php\/authenticated-rce-on-webmin\/\" \/>\n<meta property=\"og:site_name\" content=\"Calypt\" \/>\n<meta property=\"article:published_time\" content=\"2019-07-31T13:01:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-09-12T14:05:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/08\/2019-07-30-224808_1076x269_scrot-1024x256.png\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"1 minute\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.calypt.com\/blog\/#website\",\"url\":\"https:\/\/www.calypt.com\/blog\/\",\"name\":\"Calypt\",\"description\":\"Security thoughts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.calypt.com\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.calypt.com\/blog\/index.php\/authenticated-rce-on-webmin\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/08\/2019-07-30-224808_1076x269_scrot-1024x256.png\",\"contentUrl\":\"https:\/\/www.calypt.com\/blog\/wp-content\/uploads\/2019\/08\/2019-07-30-224808_1076x269_scrot-1024x256.png\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.calypt.com\/blog\/index.php\/authenticated-rce-on-webmin\/#webpage\",\"url\":\"https:\/\/www.calypt.com\/blog\/index.php\/authenticated-rce-on-webmin\/\",\"name\":\"CVE-2019-15642 - Authenticated RCE on Webmin\",\"isPartOf\":{\"@id\":\"https:\/\/www.calypt.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.calypt.com\/blog\/index.php\/authenticated-rce-on-webmin\/#primaryimage\"},\"datePublished\":\"2019-07-31T13:01:38+00:00\",\"dateModified\":\"2019-09-12T14:05:39+00:00\",\"author\":{\"@id\":\"https:\/\/www.calypt.com\/blog\/#\/schema\/person\/b39592c4058c8985f373832ef96a7cf6\"},\"description\":\"How to exploit the remote code execution vulnerability on Webmin known as CVE-2019-XXXXX. Authenticated RCE+LPE in Webmin &lt;= 1.920\",\"breadcrumb\":{\"@id\":\"https:\/\/www.calypt.com\/blog\/index.php\/authenticated-rce-on-webmin\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.calypt.com\/blog\/index.php\/authenticated-rce-on-webmin\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.calypt.com\/blog\/index.php\/authenticated-rce-on-webmin\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.calypt.com\/blog\/\",\"url\":\"https:\/\/www.calypt.com\/blog\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.calypt.com\/blog\/index.php\/authenticated-rce-on-webmin\/\",\"url\":\"https:\/\/www.calypt.com\/blog\/index.php\/authenticated-rce-on-webmin\/\",\"name\":\"CVE-2019-15642 &#8211; Authenticated RCE on Webmin &lt;= 1.920\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.calypt.com\/blog\/#\/schema\/person\/b39592c4058c8985f373832ef96a7cf6\",\"name\":\"Lo\\u00efc\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.calypt.com\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3c9955a661ca1f761736f9a7f32772c3?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3c9955a661ca1f761736f9a7f32772c3?s=96&d=mm&r=g\",\"caption\":\"Lo\\u00efc\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.calypt.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/529"}],"collection":[{"href":"https:\/\/www.calypt.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.calypt.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.calypt.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.calypt.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=529"}],"version-history":[{"count":16,"href":"https:\/\/www.calypt.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/529\/revisions"}],"predecessor-version":[{"id":564,"href":"https:\/\/www.calypt.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/529\/revisions\/564"}],"wp:attachment":[{"href":"https:\/\/www.calypt.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.calypt.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.calypt.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}