Breaking down process injection (T1055)
Content in this page
- What is process injection?
- Understanding process injection
- Breaking down the steps involved in process injection
- Process injection techniques
- Detection and mitigation
- Detecting and mitigating process injection
What is process injection?
Cyberattacks, from a broad perspective, can be classified into two phases. The first phase involves breaking into the network perimeter while the second phase involves moving around the target network. During the second phase, the attacker prefers to stay under the radar and employs various techniques to achieve the same.
One defense evasion technique (ID: TA0005) of the MITRE ATT&CK framework that attackers use is process injection (ID: T1055). It entails running a custom code within the address space of another process. Since the execution is hidden behind a legitimate process, process injection can go undetected.
Understanding process injection
Process injection involves inputting malicious code to a web application with which the user interacts. The injected code runs in the target process and manipulates its behavior. It can give access to sensitive data or exploit the system's resources.
Let's look more in depth at the process injection technique with the help of a use case to better understand how it works.
Consider an adversary who's trying to extract login credentials and perform unauthorized transactions on a banking application. They can employ process injection for their task.
- 1 The threat actor begins by researching the target bank application and identifying potential loopholes.
- 2 They try and discover the specific process on which the banking application relies to handle user authentication. That is fixed as the target process.
- 3 The attacker crafts malicious code that contains instructions to intercept and extract sensitive data.
- 4 A suitable entry point is identified within the processor to inject the code.
- 5 Following successful injection, the code starts running in the context of the target process and monitors user interaction with the application.
- 6 Login credentials are intercepted and transmitted back to the adversary's server, which enables them to perform unauthorized transactions or manipulate sensitive data.
Breaking down the steps involved in process injection:
- Target selection: The attacker looks out for a target process and selects one based on its privileges.
- Reconnaissance: The target system is researched upon and potential vulnerabilities are identified.
- Allocating memory: The attacker allocates memory within the target process to hold the malicious code.
- Code injection: Threat actors come up with malicious code to inject into the target process. This injection can be done using various techniques.
- Execution: Following successful injection, the code performs actions like privilege escalation, data theft, command execution, etc.
- Evasion: The injected code uses different evasion tactics to circumvent security systems.
Process injection techniques
Process injection can be performed by employing many sub tactics like dynamic link library (DLL) injection, process hallowing, portable executable injection, extra window memory injection, etc. Among all, DLL injection is the most popular technique used by threat actors.
DLL injection is a technique where a specific type of file, a DLL, is introduced into a target software process. A process is simply a running instance of a software program. By injecting a DLL into a process, the injector can access the process's memory and use its resources. This is because DLLs are files that hold code that can be used by several programs at once.
While DLL injection can be used for normal operations, like making one program work smoothly with another, it can also be exploited for malicious purposes. Various methods can be employed to perform DLL injection, including techniques known as:
- Load library: This is a method to load and execute code from a DLL.
- Create remote thread: This is a window API that enables the injection of code into another process and runs it as a part of the same.
- SetWindowsHookEx: This is a function that is exploited to inject code into another process through installation of hook procedures.
Detecting and mitigating process injection
DLL injection attacks are quite stealthy and can therefore be challenging to detect. Nevertheless, having a good understanding of the attack mechanism can help us think of ways to discern it.
The following are some ways to spot DLL injection attacks:
- Identify unusual or unauthorized DLL loading and injection attempts by watching the relevant API calls. Function calls connected to DLL injection and loading can be tracked by using API hooking strategies.
- Build a database of hashes or signatures for known harmful DLLs and scan processes, memory, and loaded DLLs for matches against these signatures using antivirus or anti-malware tools.
- To spot suspicious activity, keep an eye on processes and the interactions among them. Identify processes that are acting strangely, injecting code into other processes, or loading DLLs from unusual locations.
- Look for any signs of DLL injection attacks in system logs. Watch out for anomalies, warnings, or unexpected DLL loading events that can point to an ongoing attack.
In order to mitigate DLL injection attacks, we can implement runtime defenses that can instantly identify and stop DLL injection threats and use endpoint security solutions that detect behavioral patterns. Setting up stringent input validation and sanitization controls to stop applications from processing untrusted data can help us stay safe. We can also take system hardening measures and restrict file permissions. However, no single measure can ensure complete defense against the attack. It is recommended to follow a tiered approach combining multiple security controls and user awareness.
Enhance your security posture by leveraging the capabilities of Log360
Let our experts evaluate your security requirements and demonstrate how Log360 can help satisfy them.
Learn how Log360 can help fight against process injection attacks with a suite of security features like:
- MITRE ATT&CK framework implementation
- Instantaneous alert generation
- User behavior analytics
- Event correlation
Detect and mitigate DLL injection attacks using Log360
Learn how to set up correlation rules, alerts, and incident workflows, and customize them to detect and remediate the attack.
- Detection through correlation
- Creating an alert profile and workflow
- Investigation through reports
Detection through correlation
- Event ID 4688 (Windows security log): Monitors the initiation of a new process, which is a critical step in DLL injection.
- Event ID 7 from Sysmon: Analyzes if any anomalous DLLs are being loaded by the process.
- Event ID 8 from Sysmon: Checks for remote thread creation within the process. This step is of utmost importance in DLL injection attacks.
- Event ID 11 from Sysmon: Keeps track of file creation events, which indicate the entry of an injected DLL into a directory.
Note: Depending on how the DLL Injection is performed, new files created could help in detecting the attack. However, if the DLL is injected directly into memory and not written to the disk, this event might not be triggered.
Creating an alert profile and workflow
In the unfortunate event of DLL injection, immediate action should be taken by terminating the process associated with the injection, isolating the system, and blocking the endpoints. Log360's predefined workflow lets you create a sequence of steps that get triggered when the attack is detected. Predefined workflow actions like stop process and shutdown system can be included in the workflow.
Real-time alerts
When DLL injection is detected, alerts can help the security team direct their attention towards the incident right away. Log360 sends an instant alert if an event matches the alert profile. Log360 has various alert profiles that can be configured based on specific requirements. The alert notification feature enables you to receive the alerts via email or SMS, which can help with taking immediate action.
Investigation through reports
Log360 has predefined reports for prominent attacks so that users can get detailed insights about security events of interest. You can select reports relevant to a particular type of attack and add them to incidents. This can help you receive alerts and stay notified incase of any suspicious events. For DLL injection attacks, you can make use of built-in reports like EXE and DLL files allowed to run, EXE and DLL files not allowed to run due to enforced rules, etc.