Attack on Critical Infrastructure Leverages Template Injection

2017-07-07T13:34:00
ID TALOSBLOG:B098449DDF82EDA299C95AB8F10BFBD6
Type talosblog
Reporter noreply@blogger.com (Earl Carter)
Modified 2017-07-28T15:12:49

Description

<br />Contributors:  <a href="https://www.linkedin.com/in/seanrichardbaird/">Sean Baird</a>, <a href="https://www.blogger.com/profile/07833323932899203321">Earl Carter</a>, <a href="http://twitter.com/krabsonsecurity">Erick Galinkin</a>, <a href="https://www.linkedin.com/in/christophermarczewski/">Christopher Marczewski </a>& <a href="https://twitter.com/ImmortanJo3">Joe Marshall </a><br /><br /><div class="separator" style="clear: both; text-align: center;"></div><br /><h2>Executive Summary</h2><br />Attackers are continually trying to find new ways to target users with malware sent via email. Talos has identified an email-based attack targeting the energy sector, including nuclear power, that puts a new spin on the classic word document attachment phish. Typically, malicious Word documents that are sent as attachments to phishing emails will themselves contain a script or macro that executes malicious code. In this case, there is no malicious code in the attachment itself. The attachment instead tries to download a template file over an SMB connection so that the user's credentials can be silently harvested. In addition, this template file could also potentially be used to download other malicious payloads to the victim's computer.<br /><br /><a name='more'></a><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://3.bp.blogspot.com/-M7_TVig0AcU/WV_2Dubji2I/AAAAAAAAAOU/PjPQDCPcQ48pZhZcBc84OYwn02UQTEcNgCEwYBhgL/s1600/talos-social.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="627" data-original-width="1200" height="208" src="https://3.bp.blogspot.com/-M7_TVig0AcU/WV_2Dubji2I/AAAAAAAAAOU/PjPQDCPcQ48pZhZcBc84OYwn02UQTEcNgCEwYBhgL/s400/talos-social.png" width="400" /></a></div><br /><h2>Background</h2><br />Since at least May 2017, Talos has observed attackers targeting critical infrastructure and energy companies around the world, primarily in Europe and the United States. These attacks target both the critical infrastructure providers, and the vendors those providers use to deliver critical services. Attacks on critical infrastructure are not a new concern for security researchers, as adversaries are keen to understand critical infrastructure ICS networks for reasons unknown, but surely nefarious.<br /><br />One objective of this most recent attack appears to be to harvest credentials of users who work within critical infrastructure and manufacturing industries. Using a new twist on an old attack method, a clever adversary stole credentials from their victims by sending malicious word documents via email. These documents when opened, attempt to retrieve a template file from an attacker controlled external SMB server.<br /><br /><h2>Technical Investigation</h2><br />In the midst of recent attack trends and global campaigns, it has become easier to pass over simple techniques that serve attackers' best interests for years. As Talos has recently observed, sometimes new takes on reliable techniques can make them even more effective.<br /><br />While investigating a recently reported attack and pivoting on the data provided, we landed on several interesting DOCX samples which were delivered as attachments in malicious spam emails. As shown below, these documents often claimed to be environmental reports or resumés/CVs.<br /><br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"><a href="https://4.bp.blogspot.com/-hbtJ8O9-dVI/WV_mogDXuDI/AAAAAAAAANk/V8qFZAC7WIQn3GCx-7IdBsJRBpWf9gNGgCLcBGAs/s1600/image5.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="627" data-original-width="1600" height="249" src="https://4.bp.blogspot.com/-hbtJ8O9-dVI/WV_mogDXuDI/AAAAAAAAANk/V8qFZAC7WIQn3GCx-7IdBsJRBpWf9gNGgCLcBGAs/s640/image5.png" width="640" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Sample email containing a malicious document</td></tr></tbody></table><br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"><a href="https://3.bp.blogspot.com/-4bq7xG7VppY/WV_nK4PkZkI/AAAAAAAAANo/gF40I3Ayk1YnPsOHME2H92DwbwVrVUdbQCLcBGAs/s1600/image6.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="1130" data-original-width="1600" height="450" src="https://3.bp.blogspot.com/-4bq7xG7VppY/WV_nK4PkZkI/AAAAAAAAANo/gF40I3Ayk1YnPsOHME2H92DwbwVrVUdbQCLcBGAs/s640/image6.png" width="640" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">One DOCX sample used during this attack</td></tr></tbody></table><br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"><a href="https://2.bp.blogspot.com/-5gBa-QSqir4/WV_nYAkzf7I/AAAAAAAAANs/-XMKtTtA4gQKVgcLcxQMCjmGa3BFihM8gCLcBGAs/s1600/image4.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="1128" data-original-width="1600" height="450" src="https://2.bp.blogspot.com/-5gBa-QSqir4/WV_nYAkzf7I/AAAAAAAAANs/-XMKtTtA4gQKVgcLcxQMCjmGa3BFihM8gCLcBGAs/s640/image4.png" width="640" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Another DOCX sample used during this attack</td></tr></tbody></table>Applying social engineering techniques to craft convincing documents to entice targets to open them is a technique frequently used by attackers. We have no evidence that these documents are anything other than malicious. Additionally, we have no information to suggest that any entity mentioned in any of these documents have themselves been subject to an attack as part of this campaign.<br /><br />Our first expectation was that we would find some malicious VBA macros or embedded scripting within the sample itself. Examination of the VBA code provided no such leads:<br /><br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"><a href="https://1.bp.blogspot.com/-uItWiRZ0zyg/WV_nfOHzyvI/AAAAAAAAANw/TsH-ePQbgyoeer5Y1WGfQNZvv5sMMOspwCLcBGAs/s1600/image9.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="127" data-original-width="637" height="126" src="https://1.bp.blogspot.com/-uItWiRZ0zyg/WV_nfOHzyvI/AAAAAAAAANw/TsH-ePQbgyoeer5Y1WGfQNZvv5sMMOspwCLcBGAs/s640/image9.png" width="640" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Analysis of the document using oletools</td></tr></tbody></table>We confirmed this by running the sample against another similar tool:<br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"><a href="https://2.bp.blogspot.com/-y823HJm7b10/WV_nkxfveyI/AAAAAAAAAN0/FompxNcn5VshkEqYIqPE3DTb0E2z_2XLwCLcBGAs/s1600/image10.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="461" data-original-width="773" height="380" src="https://2.bp.blogspot.com/-y823HJm7b10/WV_nkxfveyI/AAAAAAAAAN0/FompxNcn5VshkEqYIqPE3DTb0E2z_2XLwCLcBGAs/s640/image10.png" width="640" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Further analysis of the DOCX</td></tr></tbody></table>Again, none of the usual indicators of an embedded binary that would contain such code appeared in our analysis. The sample had been acquired from our sandbox by researching an IP address related to the attack, but the server was no longer accepting such requests at the time of the sandbox run. While we investigated other leads, we set up an isolated environment with a server listening on TCP 80 to determine what the document was trying to obtain, if anything.<br /><br />At the loading screen for Word, we noticed something interesting:<br /><br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"><a href="https://1.bp.blogspot.com/-vxnNdT0YnvU/WV_nrcWKyoI/AAAAAAAAAN4/oBwYRkPdDIQP2nX-OX4JP5RGU7sGWWI3gCLcBGAs/s1600/image8.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="983" data-original-width="1600" height="392" src="https://1.bp.blogspot.com/-vxnNdT0YnvU/WV_nrcWKyoI/AAAAAAAAAN4/oBwYRkPdDIQP2nX-OX4JP5RGU7sGWWI3gCLcBGAs/s640/image8.png" width="640" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Word attempting to load a template</td></tr></tbody></table>The document was trying to pull down a template file from a particular IP, but no connection over TCP 80 had yet reached our decoy server. Sure enough, our live capture showed a failed handshake over TCP 445 instead. It was now time to manually parse the contents of the document for the IP address in question. Instead of code, we found an instance of template injection:<br /><br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"><a href="https://3.bp.blogspot.com/-MNDGZHHcFMg/WV_nxX6Z6iI/AAAAAAAAAN8/RVNxKd32XPA-5RFPpY52JAbhZX1BWd0ngCLcBGAs/s1600/image7.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="284" data-original-width="1600" height="112" src="https://3.bp.blogspot.com/-MNDGZHHcFMg/WV_nxX6Z6iI/AAAAAAAAAN8/RVNxKd32XPA-5RFPpY52JAbhZX1BWd0ngCLcBGAs/s640/image7.png" width="640" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Instance of template injection found in the document</td></tr></tbody></table>Our initial intelligence concerning the attack suggested that a malicious SMB server was being used to silently harvest user credentials. As conveyed in the sample, we can now see that an injected template was used to establish such a connection to an external server over SMB. Still, this did not explain why the same sample had attempted a session over TCP 80. After further research, we determined that the sandbox VM had an established preference over SMB when it came to this connection type. In short, due to the network preference of the host, a WebDAV connection was attempted over an SMB session when requesting the template. This was confirmed with another related sample when another external server was still listening on TCP 80 but no longer serving the template.<br /><br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"><a href="https://3.bp.blogspot.com/-V7ne8pl6dcc/WV_n28iiIfI/AAAAAAAAAOA/kYTidFAKYhIHkE3JRrP4Cb90ZgDeC-OtQCLcBGAs/s1600/image1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="1403" data-original-width="1600" height="560" src="https://3.bp.blogspot.com/-V7ne8pl6dcc/WV_n28iiIfI/AAAAAAAAAOA/kYTidFAKYhIHkE3JRrP4Cb90ZgDeC-OtQCLcBGAs/s640/image1.png" width="640" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">Sandbox PCAP of the sample</td></tr></tbody></table>The only entity left to move on from the template settings was the specific Relationship ID that was present in word/_rels/settings.xml.rels within the sample: rId1337. Researching this Relationship ID led us to the GitHub page of a phishing tool named <a href="https://github.com/ryhanson/phishery">Phishery</a> which happened to use the exact same ID in its template injection:<br /><br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"><a href="https://2.bp.blogspot.com/-ZOFmAV42hvE/WV_n-MsM7hI/AAAAAAAAAOE/DZ28t2qo-w4oLmDr6WZZiyTCGGKuanPBQCLcBGAs/s1600/image2.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="648" data-original-width="992" height="418" src="https://2.bp.blogspot.com/-ZOFmAV42hvE/WV_n-MsM7hI/AAAAAAAAAOE/DZ28t2qo-w4oLmDr6WZZiyTCGGKuanPBQCLcBGAs/s640/image2.png" width="640" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">GitHub page of the Phishery tool</td></tr></tbody></table><br /><br />Suprisingly, the same ID is found at the bottom of the aforementioned Go source:<br /><br /><table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"><a href="https://3.bp.blogspot.com/-5XRY9WwnHBU/WV_oD4PBRBI/AAAAAAAAAOI/GPtFmRchtDU8SdwCtoPCm_HoYFENcFIIACLcBGAs/s1600/image3.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="255" data-original-width="1001" height="161" src="https://3.bp.blogspot.com/-5XRY9WwnHBU/WV_oD4PBRBI/AAAAAAAAAOI/GPtFmRchtDU8SdwCtoPCm_HoYFENcFIIACLcBGAs/s640/image3.png" width="640" /></a></td></tr><tr><td class="tr-caption" style="text-align: center;">"rId1337" found in the Phishery tool, line 105.</td></tr></tbody></table>Phishery, however, does NOT rely on a malicious SMB server. Rather, the connection is handled over HTTPS, and the user credentials are harvested via Basic Authentication with a prompt for the credentials. Such a prompt was not needed nor seen for samples requesting the template over SMB. The fact that both this tool and the reported attack rely on template injection with the exact same Relationship ID suggests one of the following:<br /><br />1. Mere coincidence (always a possibility);<br />2. The attackers took notice of this tool and either modified it or developed their attack from scratch while sticking to the same concept used by the tool; or<br />3. The attackers used the same Relationship ID to thwart analysis of the attack itself (remember: our first inclination was to follow-up on the failed connection attempts over TCP 80).<br /><br />At this time, there is no evidence to confirm any of the three possibilities. However, the attackers' reliance on a successful SMB session stemming from outbound traffic over TCP 445 further confirms that organizations are still failing to properly block such egress traffic to public hosts. With no credential prompt needed for the SMB variation, we can come to understand the simplicity and effectiveness of such a technique. If an attacker is able to compromise a host and run such a server internally, the situation becomes significantly more grave.<br /><br />Furthermore, since the attacker controlled SMB server was down when we analyzed these samples, it is not possible to determine the ultimate payloads (if any) that could have been dropped by the template being downloaded. As we have seen with recent attacks, the intent of an attack is not always obvious. Forcing SMB requests to an external server has been a known security vulnerability for many years. Without further information it is impossible to conclude what the true scope of this attack was or what malicious payloads could have been involved.<br /><br /><h2>Conclusion</h2><br />Talos responded to these attacks by reaching out to known affected customers and ensuring that they were aware of and capable of responding to the threat. It also illustrates the importance of controlling your network traffic and not allowing outbound protocols such as SMB except where specifically required for your environment. Additionally, a number of ClamAV signatures and email rules were written in order to ensure that threats leveraging this Office template injection technique are blocked in the future.<br /><br /><h2>Coverage</h2><br />ClamAV signatures created to identify this attack:<br /><br />Doc.Tool.Phishery-6331699-0<br />Doc.Downloader.TemplateInjection-6332119-0<br />Doc.Downloader.TemplateInjection-6332123-0<br /><br />Additional ways our customers can detect and block this threat are listed below.<br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://2.bp.blogspot.com/-opOM7Rp6Y9g/WV_oKXSoC0I/AAAAAAAAAOM/ZGFJdzGqCXItlK4Y24IarhhA34WIRWCiwCLcBGAs/s1600/image11.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" data-original-height="268" data-original-width="320" src="https://2.bp.blogspot.com/-opOM7Rp6Y9g/WV_oKXSoC0I/AAAAAAAAAOM/ZGFJdzGqCXItlK4Y24IarhhA34WIRWCiwCLcBGAs/s1600/image11.png" /></a></div><br /><br />Advanced Malware Protection (<a href="https://www.cisco.com/c/en/us/support/security/amp-firepower-software-license/tsd-products-support-series-home.html">AMP</a>) blocks the malicious word documents used by these threat actors.<br /><br /><a href="https://www.cisco.com/c/en/us/products/security/cloud-web-security/index.html">CWS</a>,<a href="https://www.cisco.com/c/en/us/products/security/web-security-appliance/index.html"> </a><a href="https://www.cisco.com/c/en/us/products/security/web-security-appliance/index.html">WSA</a>, and<a href="https://umbrella.cisco.com/"> </a><a href="https://umbrella.cisco.com/">Umbrella</a> can help identify outbound connections used by these threat actors.<br /><br /><a href="https://www.cisco.com/c/en/us/products/security/email-security-appliance/index.html">Email Security</a> can block malicious emails sent by threat actors as part of their campaign. <br /><br /><a href="https://www.cisco.com/c/en/us/solutions/enterprise-networks/amp-threat-grid/index.html">AMP Threat Grid</a> helps identify malicious binaries and builds protection into all Cisco Security products.<br /><br /><br /><br /><h2></h2><h2>IOCs</h2><br />Due to the nature in which we obtained intelligence related to these attacks, we are unable to share all of the IOCs related to this event; however, we wanted to share as much as possible in the spirit of transparency and collaboration.<br /><br /><b>Malicious Documents</b><br />Filename: Report03-23-2017.docx<br />SHA256: 93cd6696e150caf6106e6066b58107372dcf43377bf4420c848007c10ff80bc9<br /><br />Filename: Controls Engineer.docx<br />SHA256: (1) b02508baf8567e62f3c0fd14833c82fb24e8ba4f0dc84aeb7690d9ea83385baa<br />                (2) 3d6eadf0f0b3fb7f996e6eb3d540945c2d736822df1a37dcd0e25371fa2d75a0<br />                (3) ac6c1df3895af63b864bb33bf30cb31059e247443ddb8f23517849362ec94f08<br /><br /><b>Related IP Addresses</b><br />184[.]154[.]150[.]66<br />5[.]153[.]58[.]45<br />62[.]8[.]193[.]206<br /><br /><div class="feedflare"> <a href="http://feeds.feedburner.com/~ff/feedburner/Talos?a=sNpalbGj2jI:zKMslyTByhw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/feedburner/Talos?d=yIl2AUoC8zA" border="0"></img></a> </div><img src="http://feeds.feedburner.com/~r/feedburner/Talos/~4/sNpalbGj2jI" height="1" width="1" alt=""/>