Skip to content
This repository was archived by the owner on Feb 14, 2025. It is now read-only.

Commit 2202598

Browse files
committed
When elevated place clean room in system Temp folder
To prevent DLL hijacking the clean room process when launched elevated, the system Temp folder will be used instead of the user's temp folder. This ensures the user cannot slip malicious DLLs into the clean room. Fixes wixtoolset/issues#5724
1 parent 0c03134 commit 2202598

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

history/5724.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* RobMen - WIXBUG:5724 - fix DLL hijack of clean room when bundle launched elevated.

src/burn/engine/cache.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,13 +1104,29 @@ static HRESULT CalculateWorkingFolder(
11041104
{
11051105
HRESULT hr = S_OK;
11061106
RPC_STATUS rs = RPC_S_OK;
1107+
BOOL fElevated = FALSE;
11071108
WCHAR wzTempPath[MAX_PATH] = { };
11081109
UUID guid = {};
11091110
WCHAR wzGuid[39];
11101111

11111112
if (!vsczWorkingFolder)
11121113
{
1113-
if (0 == ::GetTempPathW(countof(wzTempPath), wzTempPath))
1114+
ProcElevated(::GetCurrentProcess(), &fElevated);
1115+
1116+
if (fElevated)
1117+
{
1118+
if (!::GetWindowsDirectoryW(wzTempPath, countof(wzTempPath)))
1119+
{
1120+
ExitWithLastError(hr, "Failed to get windows path for working folder.");
1121+
}
1122+
1123+
hr = PathFixedBackslashTerminate(wzTempPath, countof(wzTempPath));
1124+
ExitOnFailure(hr, "Failed to ensure windows path for working folder ended in backslash.");
1125+
1126+
hr = ::StringCchCatW(wzTempPath, countof(wzTempPath), L"Temp\\");
1127+
ExitOnFailure(hr, "Failed to concat Temp directory on windows path for working folder.");
1128+
}
1129+
else if (0 == ::GetTempPathW(countof(wzTempPath), wzTempPath))
11141130
{
11151131
ExitWithLastError(hr, "Failed to get temp path for working folder.");
11161132
}

0 commit comments

Comments
 (0)