{"id":1972,"date":"2022-02-16T23:48:46","date_gmt":"2022-02-17T06:48:46","guid":{"rendered":"https:\/\/wpsites.ucalgary.ca\/isec-601-f21\/?p=1972"},"modified":"2022-02-16T23:48:49","modified_gmt":"2022-02-17T06:48:49","slug":"adobe-commerce-why-input-validation-matters","status":"publish","type":"post","link":"https:\/\/wpsites.ucalgary.ca\/isec-601-f21\/2022\/02\/16\/adobe-commerce-why-input-validation-matters\/","title":{"rendered":"Adobe Commerce: Why Input Validation Matters"},"content":{"rendered":"\n<p>Last Sunday Adobe issued an extremely highly rated CVE under CVE-2022-24086 with a rating of 9.8\/10 for their &#8220;Adobe Commerce&#8221; platform. The vulnerability allows anyone to execute arbitrary code execution, without any prior credentials or admin powers! The weakness found was based off input validation which is a relatively common weakness. If you&#8217;ve ever heard of SQL injection attacks, both attacks use the same general method to get code somewhere it shouldn&#8217;t be.<\/p>\n\n\n\n<p>For quick reference, Adobe Commerce is a web platform for selling products &amp; working through the back-end logistics. For example, an online store could use it to host their website while keeping their Amazon page up-to-date, as well as handle shipping providers. This makes it customer-facing, causing a vulnerability like this one to be even worse, since you can&#8217;t just wall it off as some internal-only application.<\/p>\n\n\n\n<p>Thankfully, by looking into the source code of the vulnerability patch, we can get a glimmer of how this specific attack works:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>        $pattern = '\/{{.*?}}\/';\n        do {\n            $result = preg_replace($pattern, '', (string)$result);\n        } while (preg_match($pattern, $result));<\/code><\/pre>\n\n\n\n<p>This newly added snippet of code uses regular expressions (Regex) to look for a particular pattern in an incoming string, and remove all occurrences. The pattern is two set of curly braces, one within another, with any amount of characters (including none) between them. This specific formatting is used in YAML to embed code.<\/p>\n\n\n\n<p>This is entirely speculation, but my guess at the mechanics behind this attack would be sending YAML queries to the Adobe Commerce backend with a carefully crafted bit of code within a set of {{}} that the backend accidentally then executed to do some further unknown function.<\/p>\n\n\n\n<p>Unfortunately the specific attack details are still scarce due to Adobe waiting for their customers to patch before releasing how the vulnerability is acted upon. The vulnerability effects all versions up to two minor versions ago (current: 2.4.5, &lt; 2.4.4 effected). Adobe also stated they&#8217;ve gotten reports of this vulnerability being exploited &#8220;in the wild&#8221; and have stated that there are &#8220;very limited attacks&#8221; on customers using Adobe Commerce, but gave no hard numbers.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"input-validation-rce\">Input Validation &amp; RCE<\/h2>\n\n\n\n<p>How do you tell a computer what is code, and what is data? If we were trying to encode the string &#8220;print(&#8220;Hello, World!&#8221;)&#8221;, how does Python know whether or not to execute the print() function within the string? If you call print() on that string, then what happens?<\/p>\n\n\n\n<p>A very important part of writing programs is input validation. Things as simple as checking whether a string can get parsed into a number, to complex error &amp; RCE checking. There are other forms of input validation (such as checking for concurrent sessions for the same user) to be aware of as well. For string-based input validation, it is recommended to look for specific code-related characters &amp; remove them from the input to ensure the string won&#8217;t get mis-read as code:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Comment tags such as \/\/ or \/* *\/<\/li><li>Semicolons ;<\/li><li>String delimiters such as &#8216; or &#8220;<\/li><li>Newline and null characters: \\n and \\0<\/li><li>Braces and Bracket pairs such as &lt;&gt;, {} and []<\/li><\/ul>\n\n\n\n<p>When an input is mis-read as code, it allows attackers to run effectively anything they want in the worst case as shown in this CVE. It can also result in crashing or causing incorrect behaviour in a system, which I&#8217;ve seen firsthand at an internship last summer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"examples-of-similar-exploits\">Examples of Similar Exploits<\/h2>\n\n\n\n<p>The classic example of improper input validation comes from XKCD:<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img decoding=\"async\" data-src=\"https:\/\/imgs.xkcd.com\/comics\/exploits_of_a_mom.png\" alt=\"https:\/\/imgs.xkcd.com\/comics\/exploits_of_a_mom.png\" width=\"666\" height=\"205\" title=\"Her daughter is named Help I'm trapped in a driver's license factory.\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 666px; --smush-placeholder-aspect-ratio: 666\/205;\" \/><\/figure>\n\n\n\n<p>Another recent example has been the RCE exploit in Dark Souls 3, where the game&#8217;s multiplayer has been temporarily disabled to fix the problem. Another blog post has already covered this, here:<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-cpsc-329-602-w-22 wp-block-embed-cpsc-329-602-w-22\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"ow0M9eAAFN\"><a href=\"https:\/\/wpsites.ucalgary.ca\/isec-601-f21\/2022\/01\/25\/your-computer-died-dark-souls-3-rce-and-cvd\/\">YOU(R COMPUTER) DIED: Dark Souls 3, RCE, and CVD<\/a><\/blockquote><iframe class=\"wp-embedded-content lazyload\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;YOU(R COMPUTER) DIED: Dark Souls 3, RCE, and CVD&#8221; &#8212; CPSC 329\/602 W22\" data-src=\"https:\/\/wpsites.ucalgary.ca\/isec-601-f21\/2022\/01\/25\/your-computer-died-dark-souls-3-rce-and-cvd\/embed\/#?secret=ops1deSozB#?secret=ow0M9eAAFN\" data-secret=\"ow0M9eAAFN\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" data-load-mode=\"1\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>Links:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Adobe page regarding the CVE: <a href=\"https:\/\/helpx.adobe.com\/security\/products\/magento\/apsb22-12.html\">https:\/\/helpx.adobe.com\/security\/products\/magento\/apsb22-12.html<\/a><\/li><li>ZDNet Article regarding the CVE: <a href=\"https:\/\/www.zdnet.com\/article\/patch-now-adobe-releases-emergency-fix-for-exploited-commerce-magento-zero-day\/\">https:\/\/www.zdnet.com\/article\/patch-now-adobe-releases-emergency-fix-for-exploited-commerce-magento-zero-day\/<\/a><\/li><li>Sansec Article Regarding the CVE: <a href=\"https:\/\/sansec.io\/research\/magento-2-cve-2022-24086\">https:\/\/sansec.io\/research\/magento-2-cve-2022-24086<\/a><\/li><li>Defeating Input Validation: <a href=\"https:\/\/www.secjuice.com\/bypass-strict-input-validation-with-remove-suffix-and-prefix-pattern\/\">https:\/\/www.secjuice.com\/bypass-strict-input-validation-with-remove-suffix-and-prefix-pattern\/<\/a><\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last Sunday Adobe issued an extremely highly rated CVE under CVE-2022-24086 with a rating of 9.8\/10 for their &#8220;Adobe Commerce&#8221; platform. The vulnerability allows anyone to execute arbitrary code execution, without any prior credentials or admin powers! The weakness found was based off input validation which is a relatively common weakness. If you&#8217;ve ever heard &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/wpsites.ucalgary.ca\/isec-601-f21\/2022\/02\/16\/adobe-commerce-why-input-validation-matters\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Adobe Commerce: Why Input Validation Matters&#8221;<\/span><\/a><\/p>\n","protected":false},"author":379,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[15],"tags":[],"class_list":["post-1972","post","type-post","status-publish","format-standard","hentry","category-cpsc-329-602-w22","entry"],"featured_image_src":null,"featured_image_src_square":null,"author_info":{"display_name":"Kell Larson","author_link":"https:\/\/wpsites.ucalgary.ca\/isec-601-f21\/author\/kell-larson\/"},"_links":{"self":[{"href":"https:\/\/wpsites.ucalgary.ca\/isec-601-f21\/wp-json\/wp\/v2\/posts\/1972","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpsites.ucalgary.ca\/isec-601-f21\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpsites.ucalgary.ca\/isec-601-f21\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpsites.ucalgary.ca\/isec-601-f21\/wp-json\/wp\/v2\/users\/379"}],"replies":[{"embeddable":true,"href":"https:\/\/wpsites.ucalgary.ca\/isec-601-f21\/wp-json\/wp\/v2\/comments?post=1972"}],"version-history":[{"count":11,"href":"https:\/\/wpsites.ucalgary.ca\/isec-601-f21\/wp-json\/wp\/v2\/posts\/1972\/revisions"}],"predecessor-version":[{"id":2013,"href":"https:\/\/wpsites.ucalgary.ca\/isec-601-f21\/wp-json\/wp\/v2\/posts\/1972\/revisions\/2013"}],"wp:attachment":[{"href":"https:\/\/wpsites.ucalgary.ca\/isec-601-f21\/wp-json\/wp\/v2\/media?parent=1972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpsites.ucalgary.ca\/isec-601-f21\/wp-json\/wp\/v2\/categories?post=1972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpsites.ucalgary.ca\/isec-601-f21\/wp-json\/wp\/v2\/tags?post=1972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}