Skip to content

Commit

Permalink
qga/win32: Use rundll for VSS installation
Browse files Browse the repository at this point in the history
The custom action uses cmd.exe to run VSS Service installation
and removal which causes an interactive command shell to spawn.
This shell can be used to execute any commands as a SYSTEM user.
Even if call qemu-ga.exe directly the interactive command shell
will be spawned as qemu-ga.exe is a console application and used
by users from the console as well as a service.

As VSS Service runs from DLL which contains the installer and
uninstaller code, it can be run directly by rundll32.exe without
any interactive command shell.

Add specific entry points for rundll which is just a wrapper
for COMRegister/COMUnregister functions with proper arguments.

resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2167423
fixes: CVE-2023-0664 (part 2 of 2)

Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Reviewed-by: Yan Vugenfirer <yvugenfi@redhat.com>
Reported-by: Brian Wiltse <brian.wiltse@live.com>
(cherry picked from commit 07ce178)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
kostyanf14 authored and Michael Tokarev committed Aug 2, 2023
1 parent daa3277 commit b629412
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
10 changes: 5 additions & 5 deletions qga/installer/qemu-ga.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,22 @@
</Directory>
</Directory>

<Property Id="cmd" Value="cmd.exe"/>
<Property Id="rundll" Value="rundll32.exe"/>
<Property Id="REINSTALLMODE" Value="amus"/>

<?ifdef var.InstallVss?>
<CustomAction Id="RegisterCom"
ExeCommand='/c "[qemu_ga_directory]qemu-ga.exe" -s vss-install'
ExeCommand='"[qemu_ga_directory]qga-vss.dll",DLLCOMRegister'
Execute="deferred"
Property="cmd"
Property="rundll"
Impersonate="no"
Return="check"
>
</CustomAction>
<CustomAction Id="UnRegisterCom"
ExeCommand='/c "[qemu_ga_directory]qemu-ga.exe" -s vss-uninstall'
ExeCommand='"[qemu_ga_directory]qga-vss.dll",DLLCOMUnregister'
Execute="deferred"
Property="cmd"
Property="rundll"
Impersonate="no"
Return="check"
>
Expand Down
9 changes: 9 additions & 0 deletions qga/vss-win32/install.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,15 @@ STDAPI COMRegister(void)
return hr;
}

STDAPI_(void) CALLBACK DLLCOMRegister(HWND, HINSTANCE, LPSTR, int)
{
COMRegister();
}

STDAPI_(void) CALLBACK DLLCOMUnregister(HWND, HINSTANCE, LPSTR, int)
{
COMUnregister();
}

static BOOL CreateRegistryKey(LPCTSTR key, LPCTSTR value, LPCTSTR data)
{
Expand Down
2 changes: 2 additions & 0 deletions qga/vss-win32/qga-vss.def
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
LIBRARY "QGA-PROVIDER.DLL"

EXPORTS
DLLCOMRegister
DLLCOMUnregister
COMRegister PRIVATE
COMUnregister PRIVATE
DllCanUnloadNow PRIVATE
Expand Down

0 comments on commit b629412

Please sign in to comment.