In cybersecurity, the concept of automation is provided in two distinct yet complementary areas: network automation and security automation. Network automation simplifies the workflow to deploy and manage security devices. Security automation provides the needed interactions and intelligence to learn, adapt and prevent successful attacks.
There are times in service provider cybersecurity conversations when the descriptors are dropped, and the topic just becomes “automation.” However, based on the audience’s perspective and focus with only the network or security aspects, this may limit complete understanding of the benefits provided when both types of automation are used in tandem.
Network automation and virtualization are coupled to allow for rapid deployment and configuration of devices and applications without slow, error-prone human intervention or purpose-built hardware deployments. Network automation drives the rapid scalability that enables operational benefits from virtualization.
The networking industry continues to transform from purpose-built hardware like routers, switches and firewalls to software-centric models that can leverage general-purpose or mass-market hardware. Network automation is often tossed around in conversations accompanied by acronyms such as SDN (Software-Defined Networking) and NFV (Network Function Virtualization). The key with automation in this environment is the ability to instantiate a virtual system as a piece of the network – that is, to get the system up and running, connected to peers, and ready to move packets – without direct human intervention. Network automation could be applied to internal private networks using VMware, or in public cloud environments such as Amazon Web Services or Microsoft Azure, or with platforms used across public and private deployments, such as OpenStack.
While rapid instantiation of a virtual network function is often good enough for network automation of routing and switching functions, it is only the beginning for security.
Security is a dynamic ecosystem of enforcement, threat analysis, threat feeds and signature updates that allow it to adapt as adversaries leverage previously unknown exploits and malware techniques. This is a world that never sleeps and keeps evolving.
Security automation is the engine that drives this ecosystem. Effective security automation includes automated data collection, analysis, enforcement and feedback.
Data collection: Security automation starts in learning mode by pulling files and links from the network for malware indicator analysis, crawling websites, and receiving third-party information about potential threats.
Analysis and enforcement: Once indicators of compromise are known, they can be converted to threat signatures, URL categorization and threat feeds. This information can be pushed into enforcement points in the network, primarily next-generation firewalls or endpoint protection applications. All of this is done moment by moment, day after day, with little to no human intervention.
Feedback: As enforcement points see attempted attacks, the ecosystem can send alerts, perform dynamic policy updates, quarantine users and devices leveraging network automation, and push out notifications to affected users. The endless feedback loop is only effective when highly automated, without the bottleneck of limited or nonexistent human resources.
Rick Howard, our Chief Security Officer, gives a great perspective on security automation in a March 2017 interview on Federal News Radio. Rick reinforces the idea that manual security techniques will always stay behind automated adversaries and provides insight into how to move to automated security.
As you can see, cybersecurityautomation is really “automation squared” for modern preventive security in a virtualized world: network automation to easily instantiate and bring a firewall online and ready for action anywhere in the world; security automation to work against adversaries and continuously try to prevent successful cyberattacks.
Palo Alto Networks partners with managed security service providers to provide effective and differentiated security services that reduce cost and increase average revenue per customer. For more information, visit our Nextwave Managed Security Service Provider Program.
Ursnif (a.k.a Gozi), the well-known banking Trojan, continues to target millions of users all around the world. Unit 42 recently published a breakdown of the distribution networks used to deploy banking Trojans like Ursnif, specifically targeting Japan and several European nations. With its malware analysis evasion techniques, Ursnif has proven difficult for traditional security tools to detect.
How Does It Work?
Ursnif has used two primary delivery methods: malspam and exploit kits.
Most recently, Ursnif has been using malspam – emails containing malicious attachments – to target users in Japan. The attachment contains a JavaScript downloader that downloads Ursnif from a remote site and executes it on the user’s machine. Other Ursnif malspam attacks have involved password-protected Office document attachments, a technique that minimizes detection by automated analysis tools. The body of the email contains a password to access the attachment, increasing the appearance of the email’s legitimacy. When the victim opens the attachment, his or her system is infected, communication with a command-and-control server is established, and commands from the C2 server, such as installing additional threats, are sent periodically.
Ursnif has also been delivered via RIG exploit kits. When a victim visits a compromised website, he or she is redirected to the RIG landing page, from which the exploit profiles the victim’s system to determine which attack will work best, delivers the attack to compromise the victim’s browser, and delivers the malicious payload onto the victim’s machine.
In both instances, the malicious payload can detect malware analysis tools and check for virtualization. If it determines itself to be in an analysis environment, the payload will avoid conducting malicious activity, making it challenging to detect.
Why Is It Unique?
Ursnif is a widespread, evolving threat that deploys multiple features through multiple attack vectors. Newer versions of the threat allow attackers to steal browsing data such as banking and credit card information, acquire passwords via screenshots and keylogging, execute arbitrary second payloads, infect additional files to further victimize other machines, and communicate peer-to-peer between different Ursnif instances in the same network.
How Do You Stop It?
Palo Alto Networks Traps uses a multi-method approach to malware and exploit prevention that block threats like Ursnif, regardless of whether they are delivered via exploit kits or malspam.
Traps examines macros in Microsoft Office files as the files are opened, performing local checks to determine if the macros are malicious or not. If a macro is malicious, it is prevented from executing. If unknown, the file containing the macro is examined by local analysis via machine learning. In this process, Traps examines various file characteristics to determine if the macro is malicious or benign. Using threat intelligence available from WildFire, a machine learning model is trained to detect malware, including never-before-seen variants. Additionally, if configured to do so, Traps will automatically send the file containing the macro to WildFire for a series of checks, including static, dynamic and bare metal analysis for full hardware execution, to identify even the most evasive threats, like Ursnif.
To prevent exploits, Traps takes a unique approach, focusing on the techniques used by all exploit-based attacks, which rarely change. Traps also prevents attackers from identifying and targeting vulnerable endpoints by blocking the profiling attempts used by exploit kits with its Exploit Kit Fingerprinting Protection Exploitation Prevention Module.
By focusing on the core exploitation techniques and blocking profiling attempts used by exploits, Traps can prevent exploits as soon as they are attempted and before an endpoint can be compromised.
We modeled the Cybersecurity Canon after the Baseball or Rock & Roll Hall-of-Fame, except for cybersecurity books. We have more than 25 books on the initial candidate list, but we are soliciting help from the cybersecurity community to increase the number to be much more than that. Please write a review and nominate your favorite.
The Cybersecurity Canon is a real thing for our community. We have designed it so that you can directly participate in the process. Please do so!
Executive Summary. This is noteworthy as the first cybersecurity book written in Japanese to target government leaders and C-suites to convince them that cybersecurity is a business management issue, not just a technical one. It is also the first Japanese book about cybersecurity to be translated into English.
The authors aim to share with domestic and global audiences what a Japanese company thinks about cybersecurity and what kinds of cybersecurity professionals the company has, because such openness is the only way to obtain feedback from global audiences, build confidence and enhance the company’s cybersecurity capabilities. This is unusual in Japanese business practice, which discourages companies from doing things differently from other companies or breaking with tradition.
The book has three key messages: first, we need to reposition cybersecurity from a technical issue to a business management challenge, as cybersecurity requires a whole-company approach to protect trust. Second, cybersecurity is about everything, and cybersecurity professionals are diverse. Third, the industry needs to work together on cybersecurity, not just leave it to the government and tech companies to solve these issues. These may not sound new to non-Japanese governments and companies. Yet, they show the strong will of Japanese business people to break the silence and reach out to global thought leaders to collaborate on cybersecurity.
Review. This is an epoch-making book in two ways: it is the first one written in Japanese to target government leaders and C-suites to convince them that cybersecurity is not just a technical issue but one of business management; and it is the first Japanese cybersecurity book to be translated into English to reach out to global experts and show Japanese businesspeople are ready for international collaboration. Before this book, cybersecurity books in Japanese had been either technical or national security-focused.
The authors belong to the NTT Cybersecurity Study Group, which consists of Senior Managers from NTT Group companies, including public advocacy personnel. NTT is one of the biggest telecom companies in the world, one of only four such companies globally with annual returns over US$100 billion. The Study Group aims to serve as an information hub for the NTT Group to enhance internal cybersecurity capabilities. Members regularly meet to discuss cybersecurity challenges and share their updates with other Group companies.
The Study Group decided to share what a Japanese company thinks about cybersecurity, as well as information about the kinds of cybersecurity professionals they have, with domestic and global audiences in order to obtain feedback from global audiences, build confidence, and enhance the company’s technical and non-technical cybersecurity capabilities. This is unusual in Japanese business practice, which encourages companies to avoid doing something different from others and from tradition.
When I first found this book, I was pleasantly surprised by the authors’ willingness to change the Japanese mindset, to be open in terms of how their company and cybersecurity professionals think about cybersecurity, and to be game-changing in creating social capital such as trust and norms. Japanese businesses tend to evaluate employees by giving demerit scores. When a new employee starts working for a company, he or she has a full score. As long as the employee performs in line with his or her predecessor, this score remains intact. However, if the employee decides to challenge the company’s traditional approach and try something new, but fails to achieve visible positive results, the score is reduced. Courage is rarely appreciated. This culture discourages employees from testing new approaches and encourages them to stay in a safe zone.
I was also amazed that this book came out two months before the Japanese government issued the Cybersecurity Guidelines for Business Leadership Ver. 1.0 to urge Japanese executives to invest more in cybersecurity as part of their business strategy. Traditionally, Japanese companies have not been proactive about informing the government about what Japan should do, unlike American companies.
The book has three key messages. First, we need to reposition cybersecurity from merely a technical issue to an important business management challenge, as cybersecurity requires a whole-company approach to protect trust. The authors point out that cybersecurity cannot be left solely to several experts because this does not allow an organization to take cybersecurity measures to meet organization-wide needs. Every employee uses information and communications technology these days. Cybersecurity is needed for everybody, yet resources are not limitless. The whole-company approach is crucial to decide how to optimize and prioritize the allocation of limited budgets and manpower.
Second, cybersecurity is about everything, and cybersecurity professionals are diverse. There is a wide variety of cybersecurity skillsets, such as knowledge about cyberattacks and defenses, risk analysis and business strategy, and education and training. Chapter 2 introduces 14 cybersecurity professionals, both Japanese and American, from different parts of NTT Group: white hat hackers, consultants, security operations center personnel, and others from financial security, internal defense, managed security service, hardware security, and encryption.
This is probably the first time any Japanese end-user company has revealed a list of their cybersecurity talent to third parties. Because hackers, even white hats, do not necessarily have a positive image in Japan due to the scarce information available about them, this book must have been encouraging to white hat hackers in Japan.
The examples also would have been useful for other end-user companies to learn what kinds of cybersecurity skillsets and professionals exist. NTT is one of three companies (in addition to Hitachi and NEC) that launched the Industrial Cross-Sectoral Committee for Cybersecurity Human Resources Development in June, 2015, to create an ecosystem between schools, universities, companies and the government to educate, recruit, hire and retain cybersecurity professionals.
Third, the authors argue that the industry needs to work together on cybersecurity and should not just leave issues to the government and tech companies to solve. These points may not sound new to non-Japanese governments and companies, yet they show the strong willingness of Japanese businesspeople to break the silence and reach out to global experts to collaborate on cybersecurity.
The authors use Chapter 3 to show how determined they are to be a game changer in the 21st century, in which cyberattackers tend to have the upper hand over defenders. The authors recognize the importance of a multi-stakeholder approach and public-private partnerships, and they have faith in end-user companies to play proactive roles in cybersecurity to change the game. End-user companies fight cyberattacks on a daily basis and own their defense strategy.
Chapter 3 also introduces examples of U.S. cybersecurity efforts, including the White House’s Summit on Cybersecurity and Consumer Protection in February 2015, and Information Sharing and Analysis Centers (ISACs). This aims to help Japanese readers learn lessons from the U.S. about how ISACs’ cyberthreat intelligence sharing helps the critical infrastructure sector and how U.S. leadership is committed to being involved in cybersecurity discussions and sharing personal experiences.
Conclusion. The message about cybersecurity as business management issue is not new. Global experts, especially Americans, are already familiar with ISACs and the NIST Framework, as mentioned in the closing chapter. Why, then, did the authors translate the book into English and post the translation for free on the NTT Group website?
They did it because this book is not just about cybersecurity for leaders. It is also about public advocacy, which the Japanese do not usually practice in the global community. The authors are aware that the cybersecurity described in this book is not perfect, but they are willing to take any feedback, because openness is the only way to break the current wall and grow out of it.
English speakers will find the book demonstrates how Japanese companies are developing a foundation for global collaboration. After reading how cybersecurity professionals in Japan struggle with, and try to overcome, various challenges, global experts will see how they can work with Japan more closely.
In April, a group known as the “Shadow Brokers” released a cache of stolen information that included multiple tools to exploit vulnerabilities in various versions of Microsoft Windows. The most famous of these is an exploit tool called “EternalBlue” which was repurposed to spread the WanaCrypt0r ransomware/worm earlier this month. Another tool released in this dump is “EsteemAudit”, which exploits CVE-2017-9073, a vulnerability in the Windows Remote Desktop system on Windows XP and Windows Server 2003. Both versions of this operating system are no longer supported by Microsoft (XP ended in 2014, Server 2003 in 2015) and as such Microsoft has not released a patch for the vulnerability.
Organizations that still rely on these out-of-date operating systems need to ensure they are defending against exploitation of this vulnerability, as it allows a remote attacker to take control over the system without any authentication.
Palo Alto Networks defends our customers’ systems from this exploit in the following ways:
Traps prevents exploitation of this vulnerability on Windows XP and Server 2003 hosts.
Threat Prevention Signature 32533 released in Content Update 692 detects the exploit in the NGFW.
Organizations that cannot upgrade systems and do not use the protections describe above should consider disabling the smart card module through Group Policy or in the registry.
Exploitation of the vulnerability is complex, but the EsteemAudit tool makes it possible for novices to use it. The remainder of this blog includes a detailed analysis of where the vulnerability exists and how EsteemAudit exploits it.
EsteemAudit Overview
This RDP remote exploit named EsteemAudit uses an inter-chunk heap overflow in an internal structure (named key_set with a size of 0x24a8) on the system heap allocated by gpkcsp.dll, which is a component of Windows Smart Card. In detail, there is 0x80 sized buffer (named key_data) in the key_set structure to store smart card information, after which there are two key_object pointers in adjacent memory. However, there is a call to memcpy in gpkcsp! MyCPAcquireContext with no boundary check, copying the entire user-controlled sized data to the location of 0x80 sized key_data. If the attacker puts more than 0x80 sized data as the source argument of memcpy, the key_object pointer adjacent with key_data will be overflowed. To exploit this, the EsteemAudit code puts the 0xb2-7 size controlled data as the source argument of memcpy, and overflowed key_object pointer with a fixed address 0x080190dc, which is an address of data section of gpkcsp.dll. After triggering the memcpy path to complete the overflow, the exploiter puts user-controlled data in that global variable at a fixed address 0x080190d8 in data section, and then triggers gpkcsp!ReleaseProvider to release the C++ object key_object (call [vtable+8]) to get control over EIP. Finally, the SharedUserData technique is used to call VirtualProtect by syscall with number 0x8f and the first stage shellcode is executed.
Introduction
Remote RDP exploits are the stuff of legend. Fortunately, no public remote exploit for Windows RDP has been available since the NT4/Win98 era. In April 2017, a group using the name “The Shadowbrokers” released an RDP exploit named EsteemAudit which attacks the remote desktop service on Windows 2003 and Windows XP by using an inter-chunk heap overflow in the Smart Card component gpkscp.dll. In this blog, we will first describe some of the internals of remote desktop protocol and mechanism, and then analyze the EsteemAudit.exe itself. Next we will analyze the details about how to deal with the RDP data in kernel and user land, how the inter-chunk heap overflow occurs, and how to exploit this inter-chunk heap overflow to execute shellcode on the vulnerable system. Finally, we will introduce the possible detection methods and how to mitigate this vulnerability without a patch.
Mechanism and Protocol
The full details of how the Remote Desktop Protocol operates are out of scope for this blog, but in this section we’ll describe the components which are relevant to this exploit.
Architecture and Components
The Terminal Services Architecture has four parts: multi-user kernel, the Remote Desktop client, the Terminal Services Licensing service, and Session Directory Services.
The following table describes the Terminal Services architecture components.
Figure 2 Terminal Services Architecture Components – From Microsoft
Nicolas Collignon describes the relationships between these components in his paper named Tunneling TCP over RDP.
In the kernel-land, the relevant component is rdpwd.sys, which is responsible for MCS (Multipoint Communication Service) stack. The RDP PDU (Protocol Data Unit) are parsed and decrypted in this component.
In user-land, the winlogon component is most relevant. It is responsible for authentication of remote client. For example, if the client request a smart card redirection, the winlogon.exe will launch smart card component and communicate with the client.
MS-RDPBCGR is based on the ITU (International Telecommunication Union) T.120 series of protocols. The T.120 standard is composed of multiple other standards, and uses the X.224 standard for transport layer communications. The X.224 standard specified how RDP packets should be encrypted and we can see this in “request PDU” and “confirm PDU” requests.
The encryptionMethods flag in X.224 request in the example below is set to 0x00000012, which represents the client requesting the 128-bit RC4 encryption [128BIT_ENCRYPTION_FLAG 0x00000002] or FIPS[FIPS_ENCRYPTION_FLAG 0x00000010].
After the RDP connection is created, the PDU between client and server will be encrypted with the negotiated encryption method (for example: 128-bit RC4). Below is an example of Client Info PDU.
Figure 5 RDP Client Info PDU
The data included in this PDU is parsed out into the following components:
64 00 04 03 eb 70 81 56 -> PER encoded (ALIGNED variant of BASIC-PER) SendDataRequestinitiator = 1005 (0x03ed)
We can parse the protocol details from plain TS_INFO_PACKET according the format described in [MS-RDPBCGR].
Figure 6 Info Packet Structure from MS-RDPBCGR
Smart Card Extension
RDP has an extension which supports remote client login using a smart card. From [MS-RDPESC], we can find the protocol sequence and details of protocol flow.
Figure 7 High Level Protocol Sequence Diagram from MS-RDPESC
Figure 8 Protocol Flow Diagram from MS-RDPESC
EsteemAudit uses the type of SCARD_IOCTL_TRANSMIT to communicate with the smart card module on the server.
Figure 9 SCARD_IOCTL_TRANSMIT description from MS-RDPESC
As the specification states, the packet returned to a client by the server has a type of Transmit_Return. The specification describes the various fields this packet includes.
Figure 10: Transmit_Return description from MS-RDPESC
The packet sent from server to server has a type of Transmit_Call.
Figure 11 Transmit_Call description from MS-RDPESC
RDP Exploit Client (EsteemAudit.exe)
After understanding the basic knowledge of architecture, components, protocol and communications of RDP, we can look specifically at what the EsteemAudit.exe exploit client does. EsteemAudit.exe is responsible for communicating with the RDP server just like an RDP Client according the RDP protocol. It emulates an RDP client using a smart card, and sends a smart card redirection authentication request to RDP server to force it to handle the data and structure sent by EsteemAudit using the smart card module gpkcsp.dll where the vulnerability exists.
EsteemAudit.exe Overview
After reverse engineering the EsteemAudit binary, we found the exploit-start function named GoRunExp at the address .text:00381009. We will not show the entire function for brevity, and only introduce the main execution flow here.
GoRunExpà InitializeInputParameters //get the config information
à connect2Target
ààinitRDPLib
ààemulateSmartCard
ààconnect2RDP
ààregisterCallback(CallBackFunction)
à RecvProcessSendPackets
à RdpLib_SendKeyStrokes // Sending Space Bar
à RecvProcessSendPackets
à buildExpBuffer
ààbuild_all_x86
àààbuild_overflow_x86
àààbuild_exploit_x86
àààbuild_egg0_x86
ààà//set auth code, xor mask, open payload dll, etc
ààà build_egg1_payloadxxx
à RdpLib_SendKeyStrokes // Sending Enter key
à RecvProcessSendPackets
…
à RecvProcessSendPackets
àà//send smart card authentication redirection request, receive and process the according response, communicate with the server, in the last phase send the ExpBuffer(including overflow buffer, exploit and egg0 buffer) to the server to control the EIP, at last send the end response to server to end the first stage.
àà//to be mentioned, CallBackFunction registered in connect2Target will be called to process the response and prints logs like “SELECT_FILE – GPK Card MF”, “GET_RESPONSE – data unit size”, “GET_RESPONSE – serial number”.
…
We found that after the preparation work including connect2Target and building the exploit buffer, RecvProcessSendPackets is called repeatedly to receive and process the data from the server and send the buffer previously prepared back to it. RecvProcessSendPackets is responsible for all the details of communicating with smart card modules on the RDP server, which we discuss in an upcoming section. However, we will not introduce the details of this function, but focus on what packets RecvProcessSendPackets sends to exploit the vulnerability.
Overflow Packet
When building the overflow packet, there are only two effective fields: a value at the 0x8d offset and a constant 0x9000 at the 0x91 offset, all other fields are random data.
Figure 12 build_overflow_x86 function assembling the exploit packet.
To see the complete data sent by client, we can inspect one of the overflow packets.
Figure 13 Overflow Packet dissected in Wireshark
As described below, after the offset 0x51, the data named TS_INFO_DATA is encrypted. To decrypt the TS_INFO_DATA, we noticed that all of data are encrypted by client with the Libeay32!RC4 function.
We can get the prototype of the RC4 function — RC4(key, len, in, out) by simply debugging it.
Figure 14 Libeay32!RC4 disassembly.
We can then set a breakpoint before and after the RC4 function execution to print the in and out buffers retrieve the encrypted data and decrypted data.
The exploit buffer packet is also a Device Control Response (DR_CONTROL_RSP) with the kind set to DR_DEVICE_IOCOMPLETION (0x49434472). This is the same as the overflow buffer described earlier.
The final two packets of the first stage are the Select_MF and End Response messages, respectively. We only show the decrypted data here.
The length of pExtraBytes is two. Two two extra bytes “90 00” will be processed by smart card module on the Server.
1
2
len
0178cf980000003c
The length of pExtraBytes is 0, it is just an end response. This completes the traffic from EsteemAudit, next we’ll go into how the server processes this data.
RDP Server
With the details on what the client send to the server and the protocol in the encrypted packet out of the way, we can start looking at how the server processes the packet and where the vulnerability is exploited.
Kernel Layer
As described in the Architecture and Component section, we know that the kernel component is responsible for receiving the RDP data. We need to identify the data entry point function that handles the RAW data sent from the client to the server.
Look at the two stack traces below. It directly shows the execution flows when a DEVICE_IO packet arrives. Termdd is the core dispatcher, RDPWD is responsible for MCS stack ad we can get the raw data sent by client from RDPWD!MCSIcaRawInput. The next several functions parsed data layer by layer according to the RDP protocol described earlier.
After parsing the MCS stack, RDPWD will parse the TS_DATA_INFO part. The data in TS_DATA_INFO is encrypted so the SM_MCSSendDataCallback function calls SMDecryptPacket-> DecryptData->rc4 to decrypt the data first.
Figure 19 Decrypting the TS_DATA_INFO data
For those who want to recreated this, you can also set breakpoint in RDPWD!rc4 function which is a similar implementation with libeay32 like we did in the client to see encrypted and decrypted data on the server.
Next, the SM_MCSSendDataCallback function calls WDW_OnDataReceived will handle the decrypted data.
Figure 20 WDW_OnDataReceived Function Call
After this, the function calls termdd!IcaChannelInput to dispatch decrypted data to different channels. In this example, the buffer overflow packet sent by EsteemAudit is the Device IO packet which is a part of File System Virtual Channel Extension and will be parsed by RDPDR module.
We can find the DR_DEVICE_IOCOMPLETION [MS-RDPEFS.pdf] header in the decrypted buffer overflow packet.
In RDPDR module, we can see there is vtable call to recognize the packet and then handle the packet.
Figure 21 RDPDR Module Handling the packet
If the server receives a packet marked as RDPDR_HEADER, RecognizePacket with the appropriate class is called.
Figure 22 RecognizePacket called for RDPDR_HEADER
The buffer overflow and exploit packets sent by EsteemAudit have the 0x49434472 flag set. 0x4472 is used for the Device redirector core component and 0x4943 is used for Device I/O response.
Figure 23 Packet Type Flags from [MS-RDPESP]
After recognizing the packet type, rdpdr!DrSession::ReadCompletion calls HandlePacket to parse the packet. We can see OnDeviceControlCompletion will deal with the header.
Figure 24 Continued Parsing of the RDP Packet
After handling the packet, we can see rdpdr!DrDevice::CompleteRxContext be notified via I/O that we have processed the packet and we can exchange the context. Other modules are also notified and continue to process the left part of the packet, here is pbExtraBytes buffer.
Figure 25 CompleteRxContext Notified of the Processed Packet
User Land Layer
In user land, winlogon.exe calls the smart card modules, like gpkcsp, scredir, and winscard to communicate with the client.
First, we can investigate the stack trace below. It is a stack trace of copying the pbExtraBytes sent by the client from the kernel to the user land. We see the data sent by client flow into the user land on the server.
WARNING: Stack unwind information not available. Following frames may be wrong.
00fcffec 00000000 kernel32!GetModuleHandleA+0xdf
The most important function in user land on the server is gpkcsp!MyCPAcquireContext. It is responsible for sending, receiving and processing smart card packets, and it corresponds to the RecvProcessSendPackets function of EsteemAudit.
Before we start introduce this function, let’s look at scredir!SCardTransmit. This function is called by gpkcsp!DoSCardTransmit and it is a basic unit for sending and receiving the smart card information.
Figure 26 scredir!SCardTransmit Function
We that the 1st argument to _SendSCardIOCTL, 0x900d0, represents SCARD_IOCTL_TRANSMIT, and the data structure of the send and receive buffer fallows _Transmit_Call and _Transmit_Return structure described earlier. After getting the data from the kernel, Transmit_Return_Decode will decode and process the data. Pay attention to scredir!_CopyReturnToCallerBuffer function, it will copy the data sent by client to a global variable 0x080190d8 in data section. This means that the data in buffer overflow packet and in exploit packet will be copied to the address 0x080190d8. That’s why an absolute address 0x080190dc is hardcoded in buffer overflow packet.
Figure 27 Data from the Overflow and Exploit Packets are copied to 0x080190d8.
Now we can introduce the gpkcsp!MyCPAcquireContext function and the whole exploit process. The details for SCardEstablishContext and ConnectToCard are not shown here, but we will introduce what happened when the data in buffer overflow packet arrived.
Figure 28 gpkcsp!MyCPAcquireContext Function
There is global variable named ProvCont which stores a 0x24a8 sized heap address.
0:003> dc gpkcsp!ProvCont (08176dd8)08176dd8 02cdcb58 X…
0:003> !heap -p -a 0x2cdcb58
address 02cdcb58 found in
_DPH_HEAP_ROOT @ 3a1000
in busy allocation ( DPH_HEAP_BLOCK: UserAddr UserSize – VirtAddr VirtSize)
Figure 29 below graphically shows the data structure of gpkcsp!ProvCont.
Figure 30 Graphical Depiction of the gpkcsp!ProvCont data structure.
After calling DoSCardTransmit to deal with buffer overflow packet and store the data in 0x080190d8, MyCPAcquireContext initialize the KeyData memory (0x80) and copies the data at 0x080190dd with the size in the data sent by client (0xb2-7) to the KeyData memory.
Figure 31 MyCPAcquireContext Initializes data structure and copies data, causing the overflow
Figure 32 below shows how memory is overwritten causing the heap overflow.
Figure 32 Graphical Depiction of the Heap Overflow
The debug log shows where KeyObject object overflows.
0:003> dc 02cdcb58+a0+b8-2002cdcc90 b7314210 544f2b0f 34059cf0 ead224e5 .B1..+OT…4.$..
After KeyObject overflows, we can see how gpkcsp!MyCPAcquireContext deals with the next packets and how the EIP was controlled.
Figure 33 gpkcsp!MyCPAcquireContext handles the subsequent packets
We note that the unsymbolized function sub_8009094 calls DoSCardTransmit and copies expbuffer to 0x080x90d8, which is an always fix address to store any data sent by client without ASLR (Address Space Layout Randomization) on Windows Server 2003.
0:003> dc 080190d8 L1c0/4080190d8 d26ccf61 08011e7a 0801118e 08005e85 a.l.z……..^..
After the exploit buffer is ready, gpkcsp!MyCPAcquireContext processes the ReleaseProvider path.
Figure 34 gpkcsp!MyCPAcquireContext processes the ReleaseProvider path
This will trigger the C++ class vtable call KeyObject->release in the CryptDestroyKey function.
Figure 35 Object is released in the CryptDestroyKey function
The log below show the process from controlling EIP to shellcode execution. The exploit uses the SharedUserData technique to call KiFastSystemCall to execute VirtualProtect and make the memory 0x080180d8 writable and executable, and to execute the shellcode at address 0x08019148. At this point the exploit has completed the first stage.
As CVE-2017-9073 only exists on Windows Server 2003 and Windows XP, both of which are no longer supported by Microsoft, users should first consider upgrading to a newer version of Windows as no official patch is available. However, as this vulnerability exists in the smart card module gpkcsp, there are potential work-arounds.
Do this in the registry: Set/Add key fEnableSmartCard in the path HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services\ to 0 with the type of REG_DWORD.
Traps prevents exploitation of this vulnerability on Windows XP and Server 2003 hosts.
Threat Prevention Signature 32533 released in Content Update 692 detects the exploit in the NGFW.
Wherever possible, disable or restrict access to RDP from external sources
Conclusion
RDP is a very useful but very complex component of Windows. Based on our analysis of the EsteemAudit exploit, we find that the vulnerability itself is not obscure, but it took quite a bit of effort to write a successful exploit. Interestingly, gpkcsp choose a global variable to store the data sent by the client, it supplies a capacity of controlling the arbitrary data in already-known address in the remote server without ASLR. This is a powerful feature for exploit authors to take advantage of. In any case, EsteemAudit is a reliable and powerful RDP exploit tool for Windows XP and Windows 2003. Users should take steps to ensure their Windows XP and Windows Server 2003 are protected through one of the mitigation steps listed above. A network vulnerability like this one can be used in a “worm-able” fashion, similar to the WanaCrypt0r attacks which had global impact earlier this month.
Malicious actors are more resourceful than ever. They have learned the different techniques and processes used for malware analysis, and have created threats that can evade detection by traditional tools such as antivirus. Sun Tzu’s “The Art of War” states: “If you know the enemy and know yourself, you need not fear the result of a hundred battles.” With this in mind, protecting your organization requires both a foundational understanding of highly evasive threats and an updated methodology for malware detection.
Below are links to a few educational resources to equip security teams with greater knowledge about evasive threats and how to prevent them.
Read our white paper “Rethink Your Strategy to Defeat Evasive Attacks” for a comprehensive understanding of evasive malware and effective strategies for preventing these advanced threats.
Watch the Security Lifecycle Review video to learn how an SLR can examine your network traffic, provide a comprehensive report on vulnerabilities in your organization’s security posture and recommend actions for remediation.