Kuboid
Open Luck·Kuboid.in
Black Hat2024
Open in YouTube ↗

4 Zero-Days Leading to RCE, LPE and KCE Affecting Millions of OpenVPN Endpoints

Black Hat900 views33:56about 1 year ago

This talk demonstrates four zero-day vulnerabilities in OpenVPN's Windows implementation, including an integer overflow in the TAP driver and a stack overflow in the service's message handling. These vulnerabilities are chained to achieve Remote Code Execution (RCE), Local Privilege Escalation (LPE), and Kernel Code Execution (KCE) via a Bring Your Own Vulnerable Driver (BYOVD) technique. The research highlights how legacy Windows IPC mechanisms like named pipes can be exploited to bypass security boundaries. The presenter provides a full-chain exploit demonstration, including bypassing Protected Process Light (PPL) protections.

Chaining Four Zero-Days to Compromise OpenVPN Endpoints

TLDR: This research details a chain of four zero-day vulnerabilities in OpenVPN’s Windows implementation, including a TAP driver integer overflow and a service-level stack overflow. By exploiting these flaws, an attacker can achieve full system compromise, including kernel-level code execution and bypassing Protected Process Light (PPL) protections. Security teams should prioritize patching OpenVPN clients and auditing local IPC mechanisms to prevent similar privilege escalation chains.

OpenVPN is the backbone of remote access for countless organizations, yet its Windows-specific components often hide legacy attack surfaces that remain overlooked. The recent research presented at Black Hat 2024 exposes how a combination of seemingly minor bugs in the TAP driver and the OpenVPN service can be chained to achieve full system control. For a red teamer, this is a masterclass in how to turn local, low-privilege access into a full kernel-level takeover.

The Vulnerability Chain

The attack surface centers on the interaction between the user-mode OpenVPN service and the kernel-mode TAP driver. The research identified four distinct vulnerabilities, but the most critical ones involve an integer overflow in the TAP driver and a stack overflow within the OpenVPN service’s message handling logic.

The TAP driver, which facilitates the virtual network interface, contains an integer overflow in the tapAdapterTransmit function. When the driver processes network data, it performs a calculation for the buffer size that is susceptible to an overflow. By passing a specifically crafted, large integer, an attacker can trigger a heap-based buffer overflow, leading to a wild kernel memory write.

Once the attacker has achieved this primitive, the next step is to target the OpenVPN service itself. The service uses named pipes for inter-process communication (IPC) to handle configuration and status updates. A stack overflow exists in the message handling routine, which can be triggered by sending an oversized message through the pipe. Because the service runs with high privileges, this stack overflow provides a direct path to code execution in the context of the service.

Exploitation Mechanics

Achieving code execution is only half the battle. The real challenge is escalating to system privileges and maintaining persistence. The researchers demonstrated a Bring Your Own Vulnerable Driver (BYOVD) technique to bridge the gap between user-mode and kernel-mode. By loading a signed but vulnerable third-party driver, they could bypass Windows Driver Signature Enforcement (DSE) and execute arbitrary code in kernel space.

The demo showed a full-chain exploit where the attacker first triggers the service-level stack overflow to gain initial execution. From there, they use the BYOVD technique to escalate privileges. The final stage involves targeting the appids.sys driver, which was identified as having a vulnerability that allows for the modification of process security bits. By flipping the bits associated with the Protected Process Light (PPL) status, the attacker can effectively "un-protect" critical security processes, allowing them to be terminated or injected with malicious code.

For those interested in the underlying mechanics of these IPC vulnerabilities, the OWASP documentation on Broken Access Control provides a solid foundation for understanding why these named pipe configurations are so dangerous. The specific vulnerabilities discussed in the talk align with CVE-2023-28218 and CVE-2024-21338, which highlight the risks of improper input validation in kernel drivers and system services.

Real-World Impact for Pentesters

During a red team engagement, finding an OpenVPN client on a target machine is a goldmine. If the client is outdated, you are not just looking at a potential network pivot; you are looking at a path to local privilege escalation. The attack flow is straightforward:

  1. Identify the version of the OpenVPN client installed on the target.
  2. If vulnerable, establish a low-privilege session.
  3. Use a tool like Process Explorer to inspect the service handles and named pipes.
  4. Deploy the exploit payload to trigger the stack overflow in the service.
  5. Use the BYOVD technique to escalate to kernel privileges.

The impact is absolute. Once you have kernel-level execution, you can disable EDR agents, dump credentials from memory, and move laterally through the network with the identity of a system administrator.

Defensive Considerations

Defending against this requires more than just patching. While updating to the latest version of OpenVPN is the primary requirement, organizations must also implement stricter policies around driver loading. Using Windows Defender Application Control (WDAC) to block known vulnerable drivers is a necessary step to mitigate BYOVD attacks. Furthermore, monitoring for unusual named pipe activity or unauthorized attempts to interact with system services can provide early warning signs of an exploit in progress.

This research serves as a reminder that even the most trusted, widely deployed software is not immune to fundamental memory corruption bugs. When you are auditing a target, do not ignore the "boring" system services. They are often the most direct path to the keys of the kingdom. Keep your eyes on the IPC boundaries, and always verify the integrity of the drivers loaded in your environment.

Talk Type
exploit demo
Difficulty
advanced
Category
red team
Has Demo Has Code Tool Released


Black Hat USA 2024

121 talks · 2024
Browse conference →
Premium Security Audit

We break your app before they do.

Professional penetration testing and vulnerability assessments by the Kuboid Secure Layer team. Securing your infrastructure at every layer.

Get in Touch
Official Security Partner
kuboid.in