🛠️ CoCreateInstanceEx
🚀 Executive Summary
CoCreateInstanceEx is a powerful Windows API used to create single uninitialized objects remotely. It’s commonly used in enterprise applications and Windows internals, but attackers also leverage it to instantiate COM classes in flexible and stealthy ways. Its support for remote activation and configurable security context allows abuse cases that bypass traditional process boundaries, avoid disk-based payloads, and cross trust levels. For defenders, understanding how this API is abused is key to detecting lateral movement, privilege escalation, and even sandbox evasion techniques.
🔍 What is CoCreateInstanceEx?
CoCreateInstanceEx is part of the Component Object Model (COM) infrastructure in Windows and is defined in objbase.h. It creates and initializes a COM object based on a specified CLSID and can return one or more interface pointers through the MULTI_QI array. This function is a more versatile alternative to CoCreateInstance, as it supports instantiating objects both locally and remotely through DCOM using the COSERVERINFO structure.
Unlike CoCreateInstance, which is limited to single-interface instantiation on the local system, CoCreateInstanceEx offers:
🚩 Why It Matters
While CoCreateInstanceEx is often used for legitimate automation or system integration, its extended capabilities make it an attractive option for attackers. The API allows for instantiation of powerful COM classes both locally and remotely often without spawning new processes or writing payloads to disk.
This flexibility makes it ideal for:
🧬 How Attackers Abuse It
Attackers abuse CoCreateInstanceEx to instantiate COM classes that lead to code execution or privilege escalation, often in a way that bypasses common detection methods. Examples include:
🛡️ Detection Opportunities
While benign applications frequently use CoCreateInstanceEx, several heuristics can signal abuse:
Here are some sample YARA rules to detect suspicious use of CoCreateInstanceEx:
See CoCreateInstanceEx.yar.
Recommended by LinkedIn
Note: Use these YARA rules at your own risk. They are loosely scoped and intended primarily for threat hunting and research purposes; NOT for deployment in detection systems that require a low false positive rate. Please review and test in your environment before use.
🐾 Behavioral Indicators
🦠 Malware & Threat Actors Documented Abusing CoCreateInstanceEx
Ransomware
Commodity Loaders & RATs
APT & Threat Actor Toolkits
Red Team & Open Source Tools
Note: This list isn’t exhaustive. It is possible more modern malware families and offensive security tools use CoCreateInstanceEx.
🧵 CoCreateInstanceEx and Friends
CoCreateInstanceEx often appears alongside other COM-related APIs that enable flexible object instantiation and control. CoInitializeEx is typically called first to initialize the COM library with a specific threading model. In some cases, attackers may opt for CoGetClassObject to retrieve a class factory before creating the object, giving them more direct control over the instantiation process. While CoCreateInstance is a simpler alternative limited to local object creation with a single interface, CoCreateInstanceEx enables more advanced use cases, including remote activation and multiple interface queries. For post-instantiation control, CoSetProxyBlanket is commonly used to set authentication and impersonation levels on the interface proxy — a crucial step for crossing privilege or network boundaries. Interfaces like ICMLuaUtil, IShellWindows, and IWbemLocator are often targeted through CoCreateInstanceEx to achieve UAC bypass, shell manipulation, or system enumeration.
📚 Resources
Open a PR or issue to help keep this list up to date!