HP ToComMsg DLL side loading vulnerability

Abstract

A DLL side loading vulnerability was found in the HP ToComMsg DLL. This issue can be exploited by loading the TcComMsg.AutoTcComMsg object as an embedded OLE object. When instantiating the object Windows will try to load the DLL MFC80ENU.DLL from the current working directory. If an attacker convinces the user to open a specially crafted (Office) document from a directory also containing the attacker's DLL file, it is possible to execute arbitrary code with the privileges of the target user. This can potentially result in the attacker taking complete control of the affected system.

Tested versions

This issue was successfully verified on the HP Color LaserJet CM2320 MFP drivers version 3.1 (CM2320series-win7-full-solution-AM-EMEA1-v3.1.exe).

Fix

There is currently no fix available, HP reports: "Unfortunately, the driver software for these devices can no longer be updated. The devices have ended support life and the engineering resources are no longer available to provide any firmware updates. We do understand the issue, and current drivers are no longer vulnerable to the OLE side load issue".

Introduction

OLE is a technology that enables an application to create compound documents that contain information from a number of different sources. For example, a document in an OLE-enabled word processor can accept an embedded spreadsheet object. Unlike traditional "cut and paste" methods where the receiving application changes the format of the pasted information, embedded documents retain all their original properties. If the user decides to edit the embedded data, Windows activates the originating application and loads the embedded document.

OLE objects are loaded via a CLSID or indirectly via a programmatic identifier (ProgID). The CLSID is used to look up its associated DLL in the Windows Registry. In order to check if the provided CLSID is in fact an OLE object, this DLL needs to be loaded in memory first, even if the CLSID is not really an OLE object. Since the DLL may not be designed to be loaded this way, loading it can introduce security issues like side loading of malicious DLLs.

Vulnerability details

It was discovered that the HP ToComMsg DLL is affected by DLL side loading. Loading the TcComMsg.AutoTcComMsg object (CLSID {2C7DE071-0E6D-11D5-954B-00108302E3C8}) as an OLE object will result in Windows trying to load the DLL MFC80ENU.DLL (on an English version of Windows) from the current working directory.

This issue is caused because the affected DLL uses an MFC DLL from Visual Studio 2005 (MFC80.DLL). This DLL is located in the Windows Side By Side (WinSxS) folder. When loaded, MFC80.DLL will try to load a localized Resource DLL from a relative path. On English versions of Windows, this file is named MFC80ENU.DLL. Since a relative path is used, the current working directory is also searched, rendering the affected component vulnerable to DLL side loading.

Figure 1: Localized Resource DLL loaded from a relative path

An attacker can exploit this issue by convincing a target user into opening a specially crafted (Office) document from a directory containing the attacker's DLL. This allows for the execution of arbitrary code that will be executed with the privileges of the target user, potentially resulting in a full compromise of the affected system.

Proof of concept

hp_laserjet_ole_sideload.rb

Vragen of feedback?