NT AUTHORITY\SYSTEM
alias
LocalSystem
account.
%TEMP%\
alias
%LOCALAPPDATA%\Temp\
alias
%USERPROFILE%\AppData\Local\Temp\
alias
%SystemDrive%\Users\%USERNAME%\AppData\Local\Temp\
directory, which is not accessible for other (unprivileged) users.
The user-specific environment variables TEMP
and
TMP
are set with the following registry entries:
REGEDIT4
[HKEY_CURRENT_USER\Environment]
"TEMP"=expand:"%USERPROFILE%\\AppData\\Local\\Temp"
"TMP"=expand:"%USERPROFILE%\\AppData\\Local\\Temp"
For the builtin user accounts
NT AUTHORITY\SYSTEM
alias
LocalSystem
,
NT AUTHORITY\LOCAL SERVICE
alias
LocalService
,
and NT AUTHORITY\NETWORK SERVICE
alias
NetworkService
,
the user-specific environment variables TEMP
and
TMP
are set with the following registry entries:
REGEDIT4
[HKEY_USERS\S-1-5-18\Environment]
"TEMP"=expand:"%USERPROFILE%\\AppData\\Local\\Temp"
"TMP"=expand:"%USERPROFILE%\\AppData\\Local\\Temp"
[HKEY_USERS\S-1-5-19\Environment]
"TEMP"=expand:"%USERPROFILE%\\AppData\\Local\\Temp"
"TMP"=expand:"%USERPROFILE%\\AppData\\Local\\Temp"
[HKEY_USERS\S-1-5-20\Environment]
"TEMP"=expand:"%USERPROFILE%\\AppData\\Local\\Temp"
"TMP"=expand:"%USERPROFILE%\\AppData\\Local\\Temp"
Note: HKEY_USERS\S-1-5-18
is a
symbolic link to the registry key HKEY_USERS\.DEFAULT
.
The user profiles for the
NT AUTHORITY\LOCAL SERVICE
alias
LocalService
and the
NT AUTHORITY\NETWORK SERVICE
alias
NetworkService
accounts are stored in the directories
%SystemRoot%\ServiceProfiles\LocalService\
and
%SystemRoot%\ServiceProfiles\NetworkService\
respectively, which too are not accessible for other (unprivileged)
users.
On 32-bit editions of Windows NT the user profile for
the NT AUTHORITY\SYSTEM
alias
LocalSystem
account is stored in the directory
%SystemRoot%\System32\Config\SystemProfile\
, which also
is not accessible for other (unprivileged) users.
On 64-bit editions of Windows NT, thanks
to the
File System Redirector,
the user profile for the
NT AUTHORITY\SYSTEM
alias
LocalSystem
account is stored in the disjoint directories
%SystemRoot%\System32\Config\SystemProfile\
and
%SystemRoot%\SysWoW64\Config\SystemProfile\
, which are
not accessible for other (unprivileged) users.
Note: the (sub)directory
%SystemRoot%\System32\Config\SystemProfile\AppData\Local\Temp\
,
on 64-bit editions of Windows NT also
%SystemRoot%\SysWoW64\Config\SystemProfile\AppData\Local\Temp\
,
which corresponds to %USERPROFILE%\AppData\Local\Temp\
,
but doesn’t exist, i.e. the user-specific environment
variables TEMP
and TMP
set for the
NT AUTHORITY\SYSTEM
alias
LocalSystem
account have an invalid (dangling) value!
Only for the NT AUTHORITY\SYSTEM
alias
LocalSystem
account the user-specific environment variables TEMP
and TMP
are but ignored and the system-specific
environment variables evaluated instead, which are set with the
following registry entries:
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment]
"TEMP"=expand:"%SystemRoot%\\TEMP"
"TMP"=expand:"%SystemRoot%\\TEMP"
Note:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet
is a
symbolic link to the registry key
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet‹digit›‹digit›‹digit›
,
typically
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001
.
Due to its inheritable
DACL
D:PAI
(A;CI;0x100026;;;BU)
(A;;FA;;;BA)
(A;OICIIO;GA;;;BA)
(A;;FA;;;SY)
(A;OICIIO;GA;;;SY)
(A;OICIIO;GA;;;CO)
the directory %SystemRoot%\Temp\
is writable for
unprivileged users who can create arbitrary files and subdirectories
with full access permission for themselves as well as
NT AUTHORITY\SYSTEM
alias
LocalSystem
and BUILTIN\Administrators
there.
The resulting well-known weaknesses are classified as CWE-378: Creation of Temporary File With Insecure Permissions, CWE-379: Creation of Temporary File in Directory with Incorrect Permissions, CWE-426: Untrusted Search Path and CWE-427: Uncontrolled Search Path Element.
NT AUTHORITY\SYSTEM
alias
LocalSystem
account use the directory %SystemRoot%\Temp\
as their
%TEMP%\
directory, thus defeating their isolation from
unprivileged processes.
Setup programs, most notably self-extractors alias wrappers, unpack
their payload, which typically includes executable files, to the
processes’ %TEMP%\
alias
%SystemRoot%\Temp\
directory and run the extracted
executable files there.
When stored in a directory other than the system directory
%SystemRoot%\System32\
and executed there, programs
susceptible to
CAPEC-471: Search Order Hijacking
load system DLLs and
system programs from their application directory
instead from
the system directory
%SystemRoot%\System32\
: as
documented in the
MSDN articles
Dynamic-Link Library Security,
Dynamic-Link Library Search Order,
LoadLibrary()
and
CreateProcess()
,
the application directory
is searched first per default.
By planting files in the directory %SystemRoot%\Temp\
which are executed from vulnerable programs run there any time
later, unprivileged users can elevate their privileges to those of
NT AUTHORITY\SYSTEM
alias
LocalSystem
and BUILTIN\Administrators
.
%ProgramFiles%\Skype\Updater\Updater.exe
is run
periodically under the
NT AUTHORITY\SYSTEM
alias
LocalSystem
user account. When an update is available,
%ProgramFiles%\Skype\Updater\Updater.exe
copies or
extracts another executable as
%TEMP%\SKY‹abcd›.tmp
alias
%SystemRoot%\Temp\SKY‹abcd›.tmp
and
executes it using the command line
"%SystemRoot%\Temp\SKY‹abcd›.tmp" /QUIET
This executable is susceptible to
CAPEC-471: Search Order Hijacking,
it loads multiple system
DLLs from its
application directory
%SystemRoot%\Temp\
instead from Windows’ system directory
%SystemRoot%\System32\
.
For the full story see Skype – or “Redmond, You’ve got a Problem!”.
For just one case where this still allows local users to escalate their privileges see ADV170017.
Contrary to previous versions, where driver installation initiated
from Driver Manager runs under an administrator
account, driver installation now runs under the
NT AUTHORITY\SYSTEM
alias
LocalSystem
user account.
Processes running under a normal user (or administrator) account use
its (private) %LOCALAPPDATA%\Temp\
alias
%USERPROFILE%\AppData\Local\Temp\
directory, which is
not accessible for other (unprivileged) users, as
%TEMP%\
directory, while processes running under the
NT AUTHORITY\SYSTEM
alias
LocalSystem
account use the (public) %SystemRoot%\Temp\
directory.
Quite some driver packages available on Windows Update
contain besides their primary (kernel) drivers, which are typically
installed via
.inf
scripts, also so-called satellites
, i.e. additional programs
and/or DLLs, which
provide interfaces to configure and control the driver and its
hardware. These satellites are typically installed by separate setup
programs that are run during driver installation.
Note: satellites
(really: arbitrary
applications) can of course be installed via
.inf
scripts too, but seldom are.
These setup programs are typically self-extractors which use the
%TEMP%\
directory to unpack and run their payload.
Instead to create a properly secured subdirectory there, some
self-extractors place their payload in the %TEMP%\
directory itself. Many, if not most payloads are but susceptible to
CAPEC-471: Search Order Hijacking
and execute files planted by unprivileged users in the
%TEMP%\
alias %SystemRoot%\Temp\
directory
with administrative privileges and access rights.
%SystemRoot%\Temp\
directory and
configure the advanced loggingfeature of Software Restriction Policies Software Restriction Policies to track (not only) their execution.
Run the following VBScript elevated, i.e. with administrative privileges, in the 32-bit execution environment:
Rem Copyright © 2004-2024, Stefan Kanthak <stefan.kanthak@nexgo.de>
Option Explicit
Const strCommandLine = "C:\Windows\System32\Cmd.exe /D /K For %? In (*.acm *.ax *.cpl *.dll *.drv *.ocx WBEM\*.dll) Do @MkLink /H C:\Windows\Temp\%~nx? %?"
Const strCurrentDirectory = "C:\Windows\System32"
With GetObject("WinMgmts:{impersonationLevel=Impersonate, (Backup, Restore)}!\\.\Root\CIMv2")
Dim objProcessStartup
Set objProcessStartup = .Get("Win32_ProcessStartup").SpawnInstance_
With objProcessStartup
' .CreateFlags = 8 ' Detached_Process
' .EnvironmentVariables = Array("NoDefaultCurrentDirectoryInExePath=*", _
' "SYSTEMDRIVE=C:", _
' "SYSTEMROOT=C:\Windows", _
' "TEMP=C:\Windows\Temp")
.ErrorMode = 2 ' Fail_Critical_Errors
.FillAttribute = 240 ' Black on White
.PriorityClass = 32 ' Normal
.ShowWindow = 1 ' SW_NORMAL
.Title = vbNull
.WinstationDesktop = vbNull
' .X = 0
.XCountChars = 80
' .XSize = 640
' .Y = 240
.YCountChars = 50
' .YSize = 480
End With
Dim intReturn, intProcessID
intReturn = .Get("Win32_Process").Create(strCommandLine, strCurrentDirectory, objProcessStartup, intProcessID)
If intReturn <> 0 Then
WScript.Echo "Error " & intReturn
Else
WScript.Echo "Process " & intProcessID & " created"
End If
End With
With WScript.CreateObject("WScript.Shell")
.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers\AuthentiCodeEnabled", 0, "REG_DWORD"
.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers\DefaultLevel", 262144, "REG_DWORD"
' .RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers\ExecutableTypes", vbNull, "REG_MULTI_SZ"
.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers\LogFileName", "C:\Windows\System32\LogFiles\SAFER.log", "REG_SZ"
.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers\PolicyScope", 0, "REG_DWORD"
.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers\TransparentEnabled", 2, "REG_DWORD"
End With
Alternative: run the following batch script in
Windows PE
after SETUP.exe /NoReboot
, with the drive letter of the
target volume as its only argument:
Rem Copyright © 2004-2024, Stefan Kanthak <stefan.kanthak@nexgo.de>
If "%~1" == "" Goto :USAGE
If Not "%1" == "%*" Goto :USAGE
If /I Not "%~1" == "%~d1" Goto :USAGE
If "%~d1" == "%SystemDrive%" Goto :USAGE
If Not Exist "%~d1\Windows\System32\Config\SOFTWARE" Goto :USAGE
"%SystemRoot%\System32\Mode.com" CON: LINES=9999
If Exist "%~d1\Windows\SysWoW64" (
For %%? In ("%~d1\Windows\SysWOW64\*.acm"
"%~d1\Windows\SysWOW64\*.ax"
"%~d1\Windows\SysWOW64\*.cpl"
"%~d1\Windows\SysWOW64\*.dll"
"%~d1\Windows\SysWOW64\*.drv"
"%~d1\Windows\SysWOW64\*.ocx"
"%~d1\Windows\SysWOW64\WBEM\*.dll") Do @MkLink /H "%~d1\Windows\Temp\%%~nx?" "%%?"
) Else (
For %%? In ("%~d1\Windows\System32\*.acm"
"%~d1\Windows\System32\*.ax"
"%~d1\Windows\System32\*.cpl"
"%~d1\Windows\System32\*.dll"
"%~d1\Windows\System32\*.drv"
"%~d1\Windows\System32\*.ocx"
"%~d1\Windows\System32\WBEM\*.dll") Do @MkLink /H "%~d1\Windows\Temp\%%~nx?" "%%?"
)
"%SystemRoot%\System32\Reg.exe" LOAD "HKEY_USERS\SOFTWARE" "%~d1\Windows\System32\Config\SOFTWARE"
"%SystemRoot%\System32\Reg.exe" QUERY "HKEY_USERS\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers" /S
"%SystemRoot%\System32\Reg.exe" ADD "HKEY_USERS\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers" /V "AuthentiCodeEnabled" /T REG_DWORD /D 0 /F
"%SystemRoot%\System32\Reg.exe" ADD "HKEY_USERS\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers" /V "DefaultLevel" /T REG_DWORD /D 262144 /F
"%SystemRoot%\System32\Reg.exe" ADD "HKEY_USERS\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers" /V "ExecutableTypes" /T REG_MULTI_SZ /D "" /F
"%SystemRoot%\System32\Reg.exe" ADD "HKEY_USERS\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers" /V "LogFileName" /T REG_SZ /D "C:\Windows\System32\LogFiles\SAFER.log" /F
"%SystemRoot%\System32\Reg.exe" ADD "HKEY_USERS\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers" /V "PolicyScope" /T REG_DWORD /D 0 /F
"%SystemRoot%\System32\Reg.exe" ADD "HKEY_USERS\SOFTWARE\Policies\Microsoft\Windows\Safer\CodeIdentifiers" /V "TransparentEnabled" /T REG_DWORD /D 2 /F
"%SystemRoot%\System32\Reg.exe" UNLOAD "HKEY_USERS\SOFTWARE"
Exit /B
:USAGE
Echo Usage: %~nx0 ^<drive letter^>:
Exit /B
Note: since (the hardlinks of) the system
DLLs are writable
only for the
TrustedInstaller
account or with SeRestorePrivilege
enabled, this
instrumentation inhibits attacks via (malicious) fake system
DLLs and mitigates
the vulnerability!
Note: some hardlinks will become orphans over time
and thus undergo bit rot
, they are not
updated by (security) updates; orphaned hardlinks can be deleted and
recreated any time!
COPY CON: "%TMP%\SAFER.tmp" 50 52 65 67 01 00 00 00 5b 00 53 00 4f 00 46 00 PReg....[.S.O.F. 54 00 57 00 41 00 52 00 45 00 5c 00 50 00 6f 00 T.W.A.R.E.\.P.o. 6c 00 69 00 63 00 69 00 65 00 73 00 5c 00 4d 00 l.i.c.i.e.s.\.M. 69 00 63 00 72 00 6f 00 73 00 6f 00 66 00 74 00 i.c.r.o.s.o.f.t. 5c 00 57 00 69 00 6e 00 64 00 6f 00 77 00 73 00 \.W.i.n.d.o.w.s. 5c 00 53 00 61 00 66 00 65 00 72 00 5c 00 43 00 \.S.a.f.e.r.\.C. 6f 00 64 00 65 00 49 00 64 00 65 00 6e 00 74 00 o.d.e.I.d.e.n.t. 69 00 66 00 69 00 65 00 72 00 73 00 00 00 3b 00 i.f.i.e.r.s...;. 41 00 75 00 74 00 68 00 65 00 6e 00 74 00 69 00 A.u.t.h.e.n.t.i. 63 00 6f 00 64 00 65 00 45 00 6e 00 61 00 62 00 c.o.d.e.E.n.a.b. 6c 00 65 00 64 00 00 00 3b 00 04 00 00 00 3b 00 l.e.d...;.....;. 04 00 00 00 3b 00 00 00 00 00 5d 00 5b 00 53 00 ....;.....].[.S. 4f 00 46 00 54 00 57 00 41 00 52 00 45 00 5c 00 O.F.T.W.A.R.E.\. 50 00 6f 00 6c 00 69 00 63 00 69 00 65 00 73 00 P.o.l.i.c.i.e.s. 5c 00 4d 00 69 00 63 00 72 00 6f 00 73 00 6f 00 \.M.i.c.r.o.s.o. 66 00 74 00 5c 00 57 00 69 00 6e 00 64 00 6f 00 f.t.\.W.i.n.d.o. 77 00 73 00 5c 00 53 00 61 00 66 00 65 00 72 00 w.s.\.S.a.f.e.r. 5c 00 43 00 6f 00 64 00 65 00 49 00 64 00 65 00 \.C.o.d.e.I.d.e. 6e 00 74 00 69 00 66 00 69 00 65 00 72 00 73 00 n.t.i.f.i.e.r.s. 00 00 3b 00 44 00 65 00 66 00 61 00 75 00 6c 00 ..;.D.e.f.a.u.l. 74 00 4c 00 65 00 76 00 65 00 6c 00 00 00 3b 00 t.L.e.v.e.l...;. 04 00 00 00 3b 00 04 00 00 00 3b 00 00 00 04 00 ....;.....;..... 5d 00 5b 00 53 00 4f 00 46 00 54 00 57 00 41 00 ].[.S.O.F.T.W.A. 52 00 45 00 5c 00 50 00 6f 00 6c 00 69 00 63 00 R.E.\.P.o.l.i.c. 69 00 65 00 73 00 5c 00 4d 00 69 00 63 00 72 00 i.e.s.\.M.i.c.r. 6f 00 73 00 6f 00 66 00 74 00 5c 00 57 00 69 00 o.s.o.f.t.\.W.i. 6e 00 64 00 6f 00 77 00 73 00 5c 00 53 00 61 00 n.d.o.w.s.\.S.a. 66 00 65 00 72 00 5c 00 43 00 6f 00 64 00 65 00 f.e.r.\.C.o.d.e. 49 00 64 00 65 00 6e 00 74 00 69 00 66 00 69 00 I.d.e.n.t.i.f.i. 65 00 72 00 73 00 00 00 3b 00 45 00 78 00 65 00 e.r.s...;.E.x.e. 63 00 75 00 74 00 61 00 62 00 6c 00 65 00 54 00 c.u.t.a.b.l.e.T. 79 00 70 00 65 00 73 00 00 00 3b 00 07 00 00 00 y.p.e.s...;..... 3b 00 02 00 00 00 3b 00 00 00 5d 00 5b 00 53 00 ;.....;...].[.S. 4f 00 46 00 54 00 57 00 41 00 52 00 45 00 5c 00 O.F.T.W.A.R.E.\. 50 00 6f 00 6c 00 69 00 63 00 69 00 65 00 73 00 P.o.l.i.c.i.e.s. 5c 00 4d 00 69 00 63 00 72 00 6f 00 73 00 6f 00 \.M.i.c.r.o.s.o. 66 00 74 00 5c 00 57 00 69 00 6e 00 64 00 6f 00 f.t.\.W.i.n.d.o. 77 00 73 00 5c 00 53 00 61 00 66 00 65 00 72 00 w.s.\.S.a.f.e.r. 5c 00 43 00 6f 00 64 00 65 00 49 00 64 00 65 00 \.C.o.d.e.I.d.e. 6e 00 74 00 69 00 66 00 69 00 65 00 72 00 73 00 n.t.i.f.i.e.r.s. 00 00 3b 00 4c 00 6f 00 67 00 46 00 69 00 6c 00 ..;.L.o.g.F.i.l. 65 00 4e 00 61 00 6d 00 65 00 00 00 3b 00 01 00 e.N.a.m.e...;... 00 00 3b 00 4e 00 00 00 3b 00 43 00 3a 00 5c 00 ..;.N...;.C.:.\. 57 00 69 00 6e 00 64 00 6f 00 77 00 73 00 5c 00 W.i.n.d.o.w.s.\. 53 00 79 00 73 00 74 00 65 00 6d 00 33 00 32 00 S.y.s.t.e.m.3.2. 5c 00 4c 00 6f 00 67 00 46 00 69 00 6c 00 65 00 \.L.o.g.F.i.l.e. 73 00 5c 00 53 00 41 00 46 00 45 00 52 00 2e 00 s.\.S.A.F.E.R... 4c 00 6f 00 67 00 00 00 5d 00 5b 00 53 00 4f 00 L.o.g...].[.S.O. 46 00 54 00 57 00 41 00 52 00 45 00 5c 00 50 00 F.T.W.A.R.E.\.P. 6f 00 6c 00 69 00 63 00 69 00 65 00 73 00 5c 00 o.l.i.c.i.e.s.\. 4d 00 69 00 63 00 72 00 6f 00 73 00 6f 00 66 00 M.i.c.r.o.s.o.f. 74 00 5c 00 57 00 69 00 6e 00 64 00 6f 00 77 00 t.\.W.i.n.d.o.w. 73 00 5c 00 53 00 61 00 66 00 65 00 72 00 5c 00 s.\.S.a.f.e.r.\. 43 00 6f 00 64 00 65 00 49 00 64 00 65 00 6e 00 C.o.d.e.I.d.e.n. 74 00 69 00 66 00 69 00 65 00 72 00 73 00 00 00 t.i.f.i.e.r.s... 3b 00 50 00 6f 00 6c 00 69 00 63 00 79 00 53 00 ;.P.o.l.i.c.y.S. 63 00 6f 00 70 00 65 00 00 00 3b 00 04 00 00 00 c.o.p.e...;..... 3b 00 04 00 00 00 3b 00 00 00 00 00 5d 00 5b 00 ;.....;.....].[. 53 00 4f 00 46 00 54 00 57 00 41 00 52 00 45 00 S.O.F.T.W.A.R.E. 5c 00 50 00 6f 00 6c 00 69 00 63 00 69 00 65 00 \.P.o.l.i.c.i.e. 73 00 5c 00 4d 00 69 00 63 00 72 00 6f 00 73 00 s.\.M.i.c.r.o.s. 6f 00 66 00 74 00 5c 00 57 00 69 00 6e 00 64 00 o.f.t.\.W.i.n.d. 6f 00 77 00 73 00 5c 00 53 00 61 00 66 00 65 00 o.w.s.\.S.a.f.e. 72 00 5c 00 43 00 6f 00 64 00 65 00 49 00 64 00 r.\.C.o.d.e.I.d. 65 00 6e 00 74 00 69 00 66 00 69 00 65 00 72 00 e.n.t.i.f.i.e.r. 73 00 00 00 3b 00 54 00 72 00 61 00 6e 00 73 00 s...;.T.r.a.n.s. 70 00 61 00 72 00 65 00 6e 00 74 00 45 00 6e 00 p.a.r.e.n.t.E.n. 61 00 62 00 6c 00 65 00 64 00 00 00 3b 00 04 00 a.b.l.e.d...;... 00 00 3b 00 04 00 00 00 3b 00 02 00 00 00 5d 00 ..;.....;.....]. ^Z MKDIR "‹target drive›:\Windows\System32\GroupPolicy\Machine" CERTUTIL.EXE /DecodeHex /V "%TMP%\SAFER.tmp" "‹target drive›:\Windows\System32\GroupPolicy\Machine\Registry.pol"
1 file(s) copied. Input Length = 4692 Output Length = 1104 CertUtil: -decodehex command completed successfully.
%SystemRoot%\Temp\
directory:
REM Copyright © 2004-2024, Stefan Kanthak <stefan.kanthak@nexgo.de> FIND.EXE /I "%SystemRoot%\Temp\" "%SystemRoot%\System32\LogFiles\SAFER.log"
After exchanging several rounds of mail discussing the case they replied with the following statements:
Because this vulnerability exists in a third-party driver installer, Microsoft cannot fix the vulnerability itself. I had contacted NVIDIA in January and was told that the driver in question is out of support.As for %TEMP% / %TMP% for the SYSTEM account, this is a known issue. We’re experimenting with ways to mitigate this issue in future versions of Windows (https://aka.ms/flighthub). Unfortunately, these mitigations are infeasible on existing Windows versions because they introduce application compatibility issues.
I had asked for more time because I wanted to check if we could implement a limited (i.e., not system-wide) mitigation for the TEMP issue that would not involve updating the third-party installer. After further discussion, my colleagues and I concluded that even a limited mitigation would still introduce application compatibility issues and would not even address all instances of the TEMP issue across all third-party drivers (e.g., third-party drivers that had hardcoded C:\Windows\Temp, though we don’t believe that that’s the case with this specific driver).
Moreover, any TEMP mitigation would not address any memory corruption bugs—like the ones you noted in your original report—in this or other third-party drivers.
We understand that vulnerable drivers are a problem. While we don’t have an immediate solution for this case, MSRC 62886, or other vulnerable third-party drivers (or vulnerable third-party driver installers), we encourage customers to report vulnerable drivers here:
https://www.microsoft.com/en-us/wdsi/driversubmission
Thanks again for reporting this issue, answering our questions, sharing an advance copy of your blog post, and giving us extra time to do some additional analysis.
S:AI
(ML;CIOI;NRNWNX;;;S-1-16-‹integrity level›)
and the protected inheritable
DACL
D:PAI
(A;CIOI;0x1301FF;;;OW)
that overrides the implicit
WDAC
alias
WRITE_DAC
and
WO
alias
WRITE_OWNER
access rights granted to
the object’s owner first, then create files (and
subdirectories) therein, inheriting their parent’s access
rights.
TEMPEST.COM
from the source presented hereafter and execute it under several
user accounts:
Create the text file TEMPEST.C
with the following
content in an arbitrary, preferable empty directory:
// Copyright © 2009-2024, Stefan Kanthak <stefan.kanthak@nexgo.de>
// * The software is provided "as is" without any warranty, neither express
// nor implied.
// * In no event will the author be held liable for any damage(s) arising
// from the use of the software.
// * Redistribution of the software is allowed only in unmodified form.
// * Permission is granted to use the software solely for personal private
// and non-commercial purposes.
// * An individuals use of the software in his or her capacity or function
// as an agent, (independent) contractor, employee, member or officer of
// a business, corporation or organization (commercial or non-commercial)
// does not qualify as personal private and non-commercial purpose.
// * Without written approval from the author the software must not be used
// for a business, for commercial, corporate, governmental, military or
// organizational purposes of any kind, or in a commercial, corporate,
// governmental, military or organizational environment of any kind.
#define STRICT
#define UNICODE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <sddl.h>
#include <aclapi.h>
__declspec(safebuffers)
BOOL CDECL PrintConsole(HANDLE hConsole, [SA_FormatString(Style="printf")] LPCWSTR lpFormat, ...)
{
WCHAR szOutput[1024];
DWORD dwOutput;
DWORD dwConsole;
va_list vaInput;
va_start(vaInput, lpFormat);
dwOutput = wvsprintf(szOutput, lpFormat, vaInput);
va_end(vaInput);
if (dwOutput == 0)
return FALSE;
if (!WriteConsole(hConsole, szOutput, dwOutput, &dwConsole, NULL))
return FALSE;
return dwConsole == dwOutput;
}
typedef struct _ace
{
ACE_HEADER Header;
ACCESS_MASK Mask;
SID Trustee;
} ACE;
static struct _acl
{
ACL acl;
ACE ace;
} dacl = {{ACL_REVISION, 0, sizeof(dacl), 1, 0},
// (A;CIOI;0x1301FF;;;OW)
{{ACCESS_ALLOWED_ACE_TYPE, CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE, sizeof(ACE)},
SYNCHRONIZE | READ_CONTROL | DELETE | FILE_WRITE_ATTRIBUTES | FILE_READ_ATTRIBUTES | FILE_DELETE_CHILD | FILE_TRAVERSE | FILE_WRITE_EA | FILE_READ_EA | FILE_ADD_SUBDIRECTORY | FILE_ADD_FILE | FILE_LIST_DIRECTORY,
{SID_REVISION, 1, SECURITY_CREATOR_SID_AUTHORITY, SECURITY_CREATOR_OWNER_RIGHTS_RID}}},
sacl = {{ACL_REVISION, 0, sizeof(sacl), 1, 0},
// (ML;CIOI;NRNWNX;;;ME)
{{SYSTEM_MANDATORY_LABEL_ACE_TYPE, CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE, sizeof(ACE)},
SYSTEM_MANDATORY_LABEL_NO_EXECUTE_UP | SYSTEM_MANDATORY_LABEL_NO_READ_UP | SYSTEM_MANDATORY_LABEL_NO_WRITE_UP,
{SID_REVISION, 1, SECURITY_MANDATORY_LABEL_AUTHORITY, SECURITY_MANDATORY_MEDIUM_RID}}};
const SECURITY_DESCRIPTOR sd = {SECURITY_DESCRIPTOR_REVISION,
0,
#if 0
SE_DACL_PRESENT | SE_DACL_PROTECTED | SE_SACL_PRESENT | SE_SACL_PROTECTED,
#else
SE_DACL_PRESENT | SE_DACL_PROTECTED | SE_SACL_PRESENT,
#endif
(SID *) NULL,
(SID *) NULL,
&sacl.acl,
&dacl.acl};
const SECURITY_ATTRIBUTES sa = {sizeof(sa),
&sd,
FALSE};
__declspec(noreturn)
VOID CDECL wmainCRTStartup(VOID)
{
struct _token_mandatory_label
{
SID_AND_ATTRIBUTES Label;
SID Sid;
} tml;
SECURITY_DESCRIPTOR *lpSD;
LPWSTR lpSDDL;
DWORD dwError = ERROR_SUCCESS;
DWORD dwBuffer;
WCHAR szBuffer[MAX_PATH + 2];
WCHAR szUnique[MAX_PATH];
UINT uiUnique = ((GetCurrentProcessId() + GetCurrentThreadId()) >> 1) & 65535;
HANDLE hProcess = GetCurrentProcess();
HANDLE hToken;
HANDLE hConsole = GetStdHandle(STD_ERROR_HANDLE);
if (hConsole == INVALID_HANDLE_VALUE)
dwError = GetLastError();
else
{
if (!OpenProcessToken(hProcess, TOKEN_QUERY, &hToken))
PrintConsole(hConsole,
L"%ls() returned error %lu\n",
L"OpenProcessToken", dwError = GetLastError());
else
{
if (!GetTokenInformation(hToken,
TokenIntegrityLevel,
&tml,
sizeof(tml),
&dwBuffer))
PrintConsole(hConsole,
L"%ls() returned error %lu for information class %lu\n",
L"GetTokenInformation", dwError = GetLastError(), TokenIntegrityLevel);
else
{
if (!CopySid(sizeof(sacl.ace.Trustee), &sacl.ace.Trustee, tml.Label.Sid))
PrintConsole(hConsole,
L"%ls() returned error %lu\n",
L"CopySid", dwError = GetLastError());
else
{
dwBuffer = GetTempPath(sizeof(szBuffer) / sizeof(*szBuffer), szBuffer);
if (dwBuffer == 0)
PrintConsole(hConsole,
L"%ls() returned error %lu\n",
L"GetTempPath", dwError = GetLastError());
else
{
PrintConsole(hConsole,
L"%ls() returned pathname \'%ls\' of %lu characters\n",
L"GetTempPath", szBuffer, dwBuffer);
do
{
if (GetTempFileName(szBuffer, L"tmp", uiUnique, szUnique) == 0)
PrintConsole(hConsole,
L"%ls() returned error %lu\n",
L"GetTempFileName", dwError = GetLastError());
else
if (!CreateDirectory(szUnique, &sa))
{
PrintConsole(hConsole,
L"%ls() returned error %lu for pathname \'%ls\'\n",
L"CreateDirectory", dwError = GetLastError(), szUnique);
if (dwError == ERROR_ALREADY_EXISTS)
continue;
}
else
{
dwError = GetNamedSecurityInfo(szUnique,
SE_FILE_OBJECT,
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION,
(SID **) NULL,
(SID **) NULL,
(ACL **) NULL,
(ACL **) NULL,
&lpSD);
if (dwError != ERROR_SUCCESS)
PrintConsole(hConsole,
L"%ls() returned error %lu\n",
L"GetNamedSecurityInfo", dwError);
else
if (!ConvertSecurityDescriptorToStringSecurityDescriptor(lpSD,
SDDL_REVISION_1,
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION,
&lpSDDL,
(LPDWORD) NULL))
PrintConsole(hConsole,
L"%ls() returned error %lu\n",
L"ConvertSecurityDescriptorToStringSecurityDescriptor", dwError = GetLastError());
else
{
PrintConsole(hConsole,
L"Subdirectory \'%ls\' created with security descriptor \'%ls\'\n",
szUnique, lpSDDL);
if (LocalFree(lpSDDL) != NULL)
PrintConsole(hConsole,
L"%ls() returned error %lu\n",
L"LocalFree", dwError = GetLastError());
}
if (GetTempFileName(szUnique, L"tmp", 0, szBuffer) == 0)
PrintConsole(hConsole,
L"%ls() returned error %lu\n",
L"GetTempFileName", dwError = GetLastError());
else
{
dwError = GetNamedSecurityInfo(szBuffer,
SE_FILE_OBJECT,
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION,
(SID **) NULL,
(SID **) NULL,
(ACL **) NULL,
(ACL **) NULL,
&lpSD);
if (dwError != ERROR_SUCCESS)
PrintConsole(hConsole,
L"%ls() returned error %lu\n",
L"GetNamedSecurityInfo", dwError);
else
if (!ConvertSecurityDescriptorToStringSecurityDescriptor(lpSD,
SDDL_REVISION_1,
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION | LABEL_SECURITY_INFORMATION,
&lpSDDL,
(LPDWORD) NULL))
PrintConsole(hConsole,
L"%ls() returned error %lu\n",
L"ConvertSecurityDescriptorToStringSecurityDescriptor", dwError = GetLastError());
else
{
PrintConsole(hConsole,
L"File \'%ls\' created with security descriptor \'%ls\'\n",
szBuffer, lpSDDL);
if (LocalFree(lpSDDL) != NULL)
PrintConsole(hConsole,
L"%ls() returned error %lu\n",
L"LocalFree", dwError = GetLastError());
}
if (!DeleteFile(szBuffer))
PrintConsole(hConsole,
L"%ls() returned error %lu\n",
L"DeleteFile", dwError = GetLastError());
}
if (!RemoveDirectory(szUnique))
PrintConsole(hConsole,
L"%ls() returned error %lu\n",
L"RemoveDirectory", dwError = GetLastError());
}
break;
}
while (--uiUnique > 0);
}
}
}
if (!CloseHandle(hToken))
PrintConsole(hConsole,
L"%ls() returned error %lu\n",
L"CloseHandle", GetLastError());
}
if (!CloseHandle(hConsole))
PrintConsole(hConsole,
L"%ls() returned error %lu\n",
L"CloseHandle", GetLastError());
}
ExitProcess(dwError);
}
Run the following four command lines to compile the source file
TEMPEST.C
created in step 1., link the compiled
object file TEMPEST.OBJ
and cleanup afterwards:
SET CL=/GAFS /Gy /O1isy /W4 /Zl SET LINK=/ENTRY:wmainCRTStartup /LARGEADDRESSAWARE /NOCOFFGRPINFO /NODEFAULTLIB /OSVERSION:6.0 /RELEASE /SUBSYSTEM:CONSOLE /SWAPRUN:CD,NET /VERSION:0.815 CL.EXE /FeTEMPEST.COM TEMPEST.C KERNEL32.LIB USER32.LIB ERASE TEMPEST.OBJFor details and reference see the MSDN articles Compiler Options and Linker Options.
Note: if necessary, see the MSDN article Use the Microsoft C++ toolset from the command line for an introduction.
Note: TEMPEST.COM
is a pure
Win32 console application and builds without the
MSVCRT
libraries.
Note: the command lines can be copied and pasted as block into a Command Processor window.
Microsoft (R) C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86 Copyright (C) Microsoft Corporation. All rights reserved. TEMPEST.C TEMPEST.C(85) : warning C4090: 'initializing' : different 'const' qualifiers TEMPEST.C(154) : warning C4090: 'function' : different 'const' qualifiers Microsoft (R) Incremental Linker Version 10.00.40219.386 Copyright (C) Microsoft Corporation. All rights reserved. …
Create the text file TEMPEST.TXT
with the following
content in an arbitrary, preferable empty directory:
4d 5a 90 00 01 00 00 00 04 00 00 00 ff ff 00 00 MZ..............
e0 00 00 00 43 00 00 00 40 00 00 00 00 00 00 00 ....C...@.......
00 00 00 00 19 57 04 27 00 00 00 00 00 00 00 00 .....W.'........
00 00 00 00 00 00 00 00 00 00 00 00 90 00 00 00 ................
28 43 29 6f 70 79 72 69 67 68 74 20 32 30 30 34 (C)opyright 2004
2d 32 30 32 34 2c 20 53 74 65 66 61 6e 20 4b 61 -2024, Stefan Ka
6e 74 68 61 6b 20 3c 73 74 65 66 61 6e 2e 6b 61 nthak <stefan.ka
6e 74 68 61 6b 40 6e 65 78 67 6f 2e 64 65 3e 0d nthak@nexgo.de>.
0a 07 24 0e 1f 33 d2 b4 09 cd 21 b8 01 4c cd 21 ..$..3....!..L.!
50 45 00 00 4c 01 03 00 56 4f 49 44 00 00 00 00 PE..L...........
00 00 00 00 e0 00 23 0d 0b 01 0a 00 00 04 00 00 ......#.........
00 0a 00 00 00 00 00 00 4e 10 00 00 00 10 00 00 ........N.......
00 20 00 00 00 00 40 00 00 10 00 00 00 02 00 00 . ....@.........
06 00 00 00 00 00 2f 03 05 00 01 00 00 00 00 00 ....../.........
00 40 00 00 00 02 00 00 77 7a 00 00 03 00 00 85 .@......wx......
00 00 10 00 00 10 00 00 00 00 10 00 00 10 00 00 ................
00 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 ................
80 24 00 00 50 00 00 00 00 00 00 00 00 00 00 00 .$..P...........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 20 00 00 5c 00 00 00 ......... ..\...
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 2e 63 6f 64 65 00 00 00 .........code...
c7 03 00 00 00 10 00 00 00 04 00 00 00 02 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 60 ............ ..`
2e 63 6f 6e 73 74 00 00 d8 06 00 00 00 20 00 00 .const....... ..
00 08 00 00 00 06 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 40 00 00 40 2e 64 61 74 61 00 00 00 ....@..@.data...
38 00 00 00 00 30 00 00 00 02 00 00 00 0e 00 00 8....0..........
00 00 00 00 00 00 00 00 00 00 00 00 40 00 00 c0 ............@...
55 8b ec 81 ec 04 08 00 00 56 8d 45 10 50 ff 75 U........V.E.P.u
0c 8d 85 fc f7 ff ff 50 ff 15 54 20 40 00 8b f0 .......P..T @...
85 f6 75 04 33 c0 eb 23 6a 00 8d 45 fc 50 56 8d ..u.3..#j..E.PV.
85 fc f7 ff ff 50 ff 75 08 ff 15 18 20 40 00 85 .....P.u.... @..
c0 74 e1 33 c0 39 75 fc 0f 94 c0 5e c9 c3 81 ec .t.3.9u....^....
3c 04 00 00 53 55 56 ff 15 4c 20 40 00 8b d8 ff <...SUV..L @....
15 48 20 40 00 03 d8 d1 eb 81 e3 ff ff 00 00 89 .H @............
5c 24 10 ff 15 44 20 40 00 6a f4 8b f0 ff 15 40 \$...D @.j.....@
20 40 00 8b e8 83 fd ff 75 0d ff 15 3c 20 40 00 @......u...< @.
8b d8 e9 26 03 00 00 57 8d 44 24 1c 50 6a 08 56 ...&...W.D$.Pj.V
ff 15 0c 20 40 00 85 c0 75 1a 8b 35 3c 20 40 00 ... @...u..5< @.
ff d6 8b d8 53 68 5c 24 40 00 bf 28 24 40 00 e9 ....Sh\$@..($@..
d1 02 00 00 8d 44 24 20 50 6a 14 8d 44 24 2c 50 .....D$ Pj..D$,P
6a 19 ff 74 24 2c ff 15 08 20 40 00 bf 28 24 40 j..t$,... @..($@
00 85 c0 75 25 8b 35 3c 20 40 00 ff d6 6a 19 8b ...u%.5< @...j..
d8 53 68 00 24 40 00 68 98 23 40 00 55 e8 fe fe .Sh.$@.h.#@.U...
ff ff 83 c4 14 e9 75 02 00 00 ff 74 24 24 68 2c ......u....t$$h,
30 40 00 6a 0c ff 15 04 20 40 00 85 c0 75 15 8b 0@.j.... @...u..
35 3c 20 40 00 ff d6 8b d8 53 68 84 23 40 00 e9 5< @.....Sh.#@..
41 02 00 00 8d 84 24 40 02 00 00 50 68 06 01 00 A.....$@...Ph...
00 ff 15 38 20 40 00 89 44 24 20 85 c0 75 15 8b ...8 @..D$ ..u..
35 3c 20 40 00 ff d6 8b d8 53 68 6c 23 40 00 e9 5< @.....Shl#@..
11 02 00 00 50 8d 84 24 44 02 00 00 50 68 6c 23 ....P..$D...Phl#
40 00 68 08 23 40 00 55 e8 83 fe ff ff 8b 35 3c @.h.#@.U......5<
20 40 00 83 c4 14 8d 44 24 38 50 53 68 fc 22 40 @.....D$8PSh."@
00 8d 84 24 4c 02 00 00 50 ff 15 34 20 40 00 85 ...$L...P..4 @..
c0 74 4d 68 74 20 40 00 8d 44 24 3c 50 ff 15 30 .tMht @..D$<P..0
20 40 00 85 c0 75 48 ff d6 8b d8 8d 44 24 38 50 @...uH.....D$8P
53 68 dc 22 40 00 68 80 22 40 00 55 e8 2f fe ff Sh."@.h."@.U./..
ff 83 c4 14 81 fb b7 00 00 00 0f 85 9f 01 00 00 ................
ff 4c 24 14 0f 84 95 01 00 00 8b 5c 24 14 eb 96 .L$........\$...
ff d6 8b d8 53 68 5c 22 40 00 e9 76 01 00 00 8b ....Sh\"@..v....
1d 00 20 40 00 8d 44 24 18 50 33 c0 50 50 50 50 .. @..D$.P3.PPPP
6a 17 6a 01 8d 44 24 54 50 ff d3 85 c0 74 08 50 j.j..D$TP....t.P
68 30 22 40 00 eb 50 6a 00 8d 44 24 14 50 6a 1f h0"@..Pj..D$.Pj.
6a 01 ff 74 24 28 ff 15 10 20 40 00 85 c0 75 0a j..t$(... @...u.
ff d6 50 68 c8 21 40 00 eb 2d ff 74 24 10 8d 44 ..Ph.!@..-.t$..D
24 3c 50 68 50 21 40 00 55 e8 a2 fd ff ff 83 c4 $<PhP!@.U.......
10 ff 74 24 10 ff 15 2c 20 40 00 85 c0 74 12 ff ..t$..., @...t..
d6 50 68 38 21 40 00 57 55 e8 82 fd ff ff 83 c4 .Ph8!@.WU.......
10 8d 84 24 40 02 00 00 50 6a 00 68 fc 22 40 00 ...$@...Pj.h."@.
8d 44 24 44 50 ff 15 34 20 40 00 85 c0 75 0f ff .D$DP..4 @...u..
d6 8b d8 53 68 5c 22 40 00 e9 a4 00 00 00 8d 44 ...Sh\"@.......D
24 18 50 33 c0 50 50 50 50 6a 17 6a 01 8d 84 24 $.P3.PPPPj.j...$
5c 02 00 00 50 ff d3 8b d8 85 db 74 08 53 68 30 \...P......t.Sh0
22 40 00 eb 57 6a 00 8d 44 24 14 50 6a 1f 6a 01 "@..Wj..D$.Pj.j.
ff 74 24 28 ff 15 10 20 40 00 85 c0 75 0c ff d6 .t$(... @...u...
8b d8 53 68 c8 21 40 00 eb 32 ff 74 24 10 8d 84 ..Sh.!@..2.t$...
24 44 02 00 00 50 68 d0 20 40 00 55 e8 ef fc ff $D...Ph. @.U....
ff 83 c4 10 ff 74 24 10 ff 15 2c 20 40 00 85 c0 .....t$..., @...
74 14 ff d6 8b d8 53 68 38 21 40 00 57 55 e8 cd t.....Sh8!@.WU..
fc ff ff 83 c4 10 8d 84 24 40 02 00 00 50 ff 15 ........$@...P..
28 20 40 00 85 c0 75 14 ff d6 8b d8 53 68 b8 20 ( @...u.....Sh.
40 00 57 55 e8 a7 fc ff ff 83 c4 10 8d 44 24 38 @.WU.........D$8
50 ff 15 24 20 40 00 85 c0 75 14 ff d6 8b d8 53 P..$ @...u.....S
68 98 20 40 00 57 55 e8 84 fc ff ff 83 c4 10 ff h. @.WU.........
74 24 1c ff 15 20 20 40 00 85 c0 75 12 ff d6 50 t$... @...u...P
68 80 20 40 00 57 55 e8 64 fc ff ff 83 c4 10 55 h. @.WU.d......U
ff 15 20 20 40 00 85 c0 75 12 ff d6 50 68 80 20 .. @...u...Ph.
40 00 57 55 e8 47 fc ff ff 83 c4 10 5f 53 ff 15 @.WU.G......_S..
1c 20 40 00 5e 5d 5b 00 00 00 00 00 00 00 00 00 . @.^][.........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
64 25 00 00 7c 25 00 00 86 25 00 00 9c 25 00 00 d%..|%...%...%..
2c 25 00 00 00 00 00 00 be 25 00 00 ce 25 00 00 ,%.......%...%..
dc 25 00 00 ea 25 00 00 fe 25 00 00 0c 26 00 00 .%...%...%...&..
18 26 00 00 2c 26 00 00 40 26 00 00 50 26 00 00 .&..,&..@&..P&..
60 26 00 00 70 26 00 00 84 26 00 00 9a 26 00 00 `&..p&...&...&..
00 00 00 00 be 26 00 00 00 00 00 00 00 00 00 00 .....&..........
01 00 17 10 00 00 00 00 00 00 00 00 1c 30 40 00 .............0@.
00 30 40 00 0c 00 00 00 60 20 40 00 00 00 00 00 .0@.....` @.....
43 00 6c 00 6f 00 73 00 65 00 48 00 61 00 6e 00 C.l.o.s.e.H.a.n.
64 00 6c 00 65 00 00 00 52 00 65 00 6d 00 6f 00 d.l.e...R.e.m.o.
76 00 65 00 44 00 69 00 72 00 65 00 63 00 74 00 v.e.D.i.r.e.c.t.
6f 00 72 00 79 00 00 00 44 00 65 00 6c 00 65 00 o.r.y...D.e.l.e.
74 00 65 00 46 00 69 00 6c 00 65 00 00 00 00 00 t.e.F.i.l.e.....
46 00 69 00 6c 00 65 00 20 00 27 00 25 00 6c 00 F.i.l.e. .'.%.l.
73 00 27 00 20 00 63 00 72 00 65 00 61 00 74 00 s.'. .c.r.e.a.t.
65 00 64 00 20 00 77 00 69 00 74 00 68 00 20 00 e.d. .w.i.t.h. .
73 00 65 00 63 00 75 00 72 00 69 00 74 00 79 00 s.e.c.u.r.i.t.y.
20 00 64 00 65 00 73 00 63 00 72 00 69 00 70 00 .d.e.s.c.r.i.p.
74 00 6f 00 72 00 20 00 27 00 25 00 6c 00 73 00 t.o.r. .'.%.l.s.
27 00 0a 00 00 00 00 00 4c 00 6f 00 63 00 61 00 '.......L.o.c.a.
6c 00 46 00 72 00 65 00 65 00 00 00 00 00 00 00 l.F.r.e.e.......
53 00 75 00 62 00 64 00 69 00 72 00 65 00 63 00 S.u.b.d.i.r.e.c.
74 00 6f 00 72 00 79 00 20 00 27 00 25 00 6c 00 t.o.r.y. .'.%.l.
73 00 27 00 20 00 63 00 72 00 65 00 61 00 74 00 s.'. .c.r.e.a.t.
65 00 64 00 20 00 77 00 69 00 74 00 68 00 20 00 e.d. .w.i.t.h. .
73 00 65 00 63 00 75 00 72 00 69 00 74 00 79 00 s.e.c.u.r.i.t.y.
20 00 64 00 65 00 73 00 63 00 72 00 69 00 70 00 .d.e.s.c.r.i.p.
74 00 6f 00 72 00 20 00 27 00 25 00 6c 00 73 00 t.o.r. .'.%.l.s.
27 00 0a 00 00 00 00 00 43 00 6f 00 6e 00 76 00 '.......C.o.n.v.
65 00 72 00 74 00 53 00 65 00 63 00 75 00 72 00 e.r.t.S.e.c.u.r.
69 00 74 00 79 00 44 00 65 00 73 00 63 00 72 00 i.t.y.D.e.s.c.r.
69 00 70 00 74 00 6f 00 72 00 54 00 6f 00 53 00 i.p.t.o.r.T.o.S.
74 00 72 00 69 00 6e 00 67 00 53 00 65 00 63 00 t.r.i.n.g.S.e.c.
75 00 72 00 69 00 74 00 79 00 44 00 65 00 73 00 u.r.i.t.y.D.e.s.
63 00 72 00 69 00 70 00 74 00 6f 00 72 00 00 00 c.r.i.p.t.o.r...
47 00 65 00 74 00 4e 00 61 00 6d 00 65 00 64 00 G.e.t.N.a.m.e.d.
53 00 65 00 63 00 75 00 72 00 69 00 74 00 79 00 S.e.c.u.r.i.t.y.
49 00 6e 00 66 00 6f 00 00 00 00 00 47 00 65 00 I.n.f.o.....G.e.
74 00 54 00 65 00 6d 00 70 00 46 00 69 00 6c 00 t.T.e.m.p.F.i.l.
65 00 4e 00 61 00 6d 00 65 00 00 00 00 00 00 00 e.N.a.m.e.......
25 00 6c 00 73 00 28 00 29 00 20 00 72 00 65 00 %.l.s.(.). .r.e.
74 00 75 00 72 00 6e 00 65 00 64 00 20 00 65 00 t.u.r.n.e.d. .e.
72 00 72 00 6f 00 72 00 20 00 25 00 6c 00 75 00 r.r.o.r. .%.l.u.
20 00 66 00 6f 00 72 00 20 00 70 00 61 00 74 00 .f.o.r. .p.a.t.
68 00 6e 00 61 00 6d 00 65 00 20 00 27 00 25 00 h.n.a.m.e. .'.%.
6c 00 73 00 27 00 0a 00 00 00 00 00 43 00 72 00 l.s.'.......C.r.
65 00 61 00 74 00 65 00 44 00 69 00 72 00 65 00 e.a.t.e.D.i.r.e.
63 00 74 00 6f 00 72 00 79 00 00 00 74 00 6d 00 c.t.o.r.y...t.m.
70 00 00 00 00 00 00 00 25 00 6c 00 73 00 28 00 p.......%.l.s.(.
29 00 20 00 72 00 65 00 74 00 75 00 72 00 6e 00 ). .r.e.t.u.r.n.
65 00 64 00 20 00 70 00 61 00 74 00 68 00 6e 00 e.d. .p.a.t.h.n.
61 00 6d 00 65 00 20 00 27 00 25 00 6c 00 73 00 a.m.e. .'.%.l.s.
27 00 20 00 6f 00 66 00 20 00 25 00 6c 00 75 00 '. .o.f. .%.l.u.
20 00 63 00 68 00 61 00 72 00 61 00 63 00 74 00 .c.h.a.r.a.c.t.
65 00 72 00 73 00 0a 00 00 00 00 00 47 00 65 00 e.r.s.......G.e.
74 00 54 00 65 00 6d 00 70 00 50 00 61 00 74 00 t.T.e.m.p.P.a.t.
68 00 00 00 43 00 6f 00 70 00 79 00 53 00 69 00 h...C.o.p.y.S.i.
64 00 00 00 00 00 00 00 25 00 6c 00 73 00 28 00 d.......%.l.s.(.
29 00 20 00 72 00 65 00 74 00 75 00 72 00 6e 00 ). .r.e.t.u.r.n.
65 00 64 00 20 00 65 00 72 00 72 00 6f 00 72 00 e.d. .e.r.r.o.r.
20 00 25 00 6c 00 75 00 20 00 66 00 6f 00 72 00 .%.l.u. .f.o.r.
20 00 69 00 6e 00 66 00 6f 00 72 00 6d 00 61 00 .i.n.f.o.r.m.a.
74 00 69 00 6f 00 6e 00 20 00 63 00 6c 00 61 00 t.i.o.n. .c.l.a.
73 00 73 00 20 00 25 00 6c 00 75 00 0a 00 00 00 s.s. .%.l.u.....
47 00 65 00 74 00 54 00 6f 00 6b 00 65 00 6e 00 G.e.t.T.o.k.e.n.
49 00 6e 00 66 00 6f 00 72 00 6d 00 61 00 74 00 I.n.f.o.r.m.a.t.
69 00 6f 00 6e 00 00 00 25 00 6c 00 73 00 28 00 i.o.n...%.l.s.(.
29 00 20 00 72 00 65 00 74 00 75 00 72 00 6e 00 ). .r.e.t.u.r.n.
65 00 64 00 20 00 65 00 72 00 72 00 6f 00 72 00 e.d. .e.r.r.o.r.
20 00 25 00 6c 00 75 00 0a 00 00 00 4f 00 70 00 .%.l.u.....O.p.
65 00 6e 00 50 00 72 00 6f 00 63 00 65 00 73 00 e.n.P.r.o.c.e.s.
73 00 54 00 6f 00 6b 00 65 00 6e 00 00 00 00 00 s.T.o.k.e.n.....
d0 24 00 00 00 00 00 00 00 00 00 00 b0 25 00 00 .$...........%..
00 20 00 00 e8 24 00 00 00 00 00 00 00 00 00 00 . ...$..........
b0 26 00 00 18 20 00 00 24 25 00 00 00 00 00 00 .&... ..$%......
00 00 00 00 cc 26 00 00 54 20 00 00 00 00 00 00 .....&..T ......
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
64 25 00 00 7c 25 00 00 86 25 00 00 9c 25 00 00 d%..|%...%...%..
2c 25 00 00 00 00 00 00 be 25 00 00 ce 25 00 00 ,%.......%...%..
dc 25 00 00 ea 25 00 00 fe 25 00 00 0c 26 00 00 .%...%...%...&..
18 26 00 00 2c 26 00 00 40 26 00 00 50 26 00 00 .&..,&..@&..P&..
60 26 00 00 70 26 00 00 84 26 00 00 9a 26 00 00 `&..p&...&...&..
00 00 00 00 be 26 00 00 00 00 00 00 6a 00 43 6f .....&......j.Co
6e 76 65 72 74 53 65 63 75 72 69 74 79 44 65 73 nvertSecurityDes
63 72 69 70 74 6f 72 54 6f 53 74 72 69 6e 67 53 criptorToStringS
65 63 75 72 69 74 79 44 65 73 63 72 69 70 74 6f ecurityDescripto
72 57 00 00 42 01 47 65 74 4e 61 6d 65 64 53 65 rW..B.GetNamedSe
63 75 72 69 74 79 49 6e 66 6f 57 00 76 00 43 6f curityInfoW.v.Co
70 79 53 69 64 00 5a 01 47 65 74 54 6f 6b 65 6e pySid.Z.GetToken
49 6e 66 6f 72 6d 61 74 69 6f 6e 00 f7 01 4f 70 Information...Op
65 6e 50 72 6f 63 65 73 73 54 6f 6b 65 6e 00 00 enProcessToken..
41 44 56 41 50 49 33 32 2e 64 6c 6c 00 00 24 05 ADVAPI32.dll..$.
57 72 69 74 65 43 6f 6e 73 6f 6c 65 57 00 19 01 WriteConsoleW...
45 78 69 74 50 72 6f 63 65 73 73 00 52 00 43 6c ExitProcess.R.Cl
6f 73 65 48 61 6e 64 6c 65 00 03 04 52 65 6d 6f oseHandle...Remo
76 65 44 69 72 65 63 74 6f 72 79 57 00 00 d6 00 veDirectoryW....
44 65 6c 65 74 65 46 69 6c 65 57 00 48 03 4c 6f DeleteFileW.H.Lo
63 61 6c 46 72 65 65 00 81 00 43 72 65 61 74 65 calFree...Create
44 69 72 65 63 74 6f 72 79 57 00 00 83 02 47 65 DirectoryW....Ge
74 54 65 6d 70 46 69 6c 65 4e 61 6d 65 57 00 00 tTempFileNameW..
85 02 47 65 74 54 65 6d 70 50 61 74 68 57 00 00 ..GetTempPathW..
02 02 47 65 74 4c 61 73 74 45 72 72 6f 72 00 00 ..GetLastError..
64 02 47 65 74 53 74 64 48 61 6e 64 6c 65 00 00 d.GetStdHandle..
c0 01 47 65 74 43 75 72 72 65 6e 74 50 72 6f 63 ..GetCurrentProc
65 73 73 00 c1 01 47 65 74 43 75 72 72 65 6e 74 ess...GetCurrent
50 72 6f 63 65 73 73 49 64 00 c5 01 47 65 74 43 ProcessId...GetC
75 72 72 65 6e 74 54 68 72 65 61 64 49 64 00 00 urrentThreadId..
4b 45 52 4e 45 4c 33 32 2e 64 6c 6c 00 00 35 03 KERNEL32.dll..5.
77 76 73 70 72 69 6e 74 66 57 00 00 55 53 45 52 wvsprintfW..USER
33 32 2e 64 6c 6c 00 00 00 00 00 00 00 00 00 00 32.dll..........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
02 00 1c 00 01 00 00 00 00 03 14 00 ff 01 13 00 ................
01 01 00 00 00 00 00 03 04 00 00 00 02 00 1c 00 ................
01 00 00 00 11 03 14 00 07 00 00 00 01 01 00 00 ................
00 00 00 10 00 20 00 00 00 00 00 00 00 00 00 00 ..... ..........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Decode the dump file TEMPEST.TXT
created in
step 3. to recreate the console application
TEMPEST.COM
:
CERTUTIL.EXE /DecodeHex /V TEMPEST.TXT TEMPEST.COM
Input Length = 17408 Output Length = 4096 CertUtil: -decodehex command completed successfully.
Execute the console application TEMPEST.COM
built in
step 2. under a standard user account or unelevated under a
protected administrator
account:
.\TEMPEST.COM
GetTempPath() returned pathname 'C:\Users\Stefan\AppData\Local\Temp\' of 35 characters Subdirectory 'C:\Users\Stefan\AppData\Local\Temp\tmp1992.tmp' created with security descriptor 'O:S-1-5-21-820728443-44925810-1835867902-1000G:S-1-5-21-820728443-44925810-1835867902-513D:P(A;OICI;0x1301ff;;;OW)S:AI(ML;OICI;NWNRNX;;;ME)' File 'C:\Users\Stefan\AppData\Local\Temp\tmp1992.tmp\tmpB9AB.tmp' created with security descriptor 'O:S-1-5-21-820728443-44925810-1835867902-1000G:S-1-5-21-820728443-44925810-1835867902-513D:(A;;0x1301ff;;;OW)S:AI(ML;ID;NWNRNX;;;ME)'
Execute the console application TEMPEST.COM
built in
step 2. elevated under a protected administrator
account:
.\TEMPEST.COM
GetTempPath() returned pathname 'C:\Users\Stefan\AppData\Local\Temp\' of 35 characters Subdirectory 'C:\Users\Stefan\AppData\Local\Temp\tmp2A86.tmp' created with security descriptor 'O:BAG:S-1-5-21-820728443-44925810-1835867902-513D:P(A;OICI;0x1301ff;;;OW)S:AI(ML;OICI;NWNRNX;;;HI)' File 'C:\Users\Stefan\AppData\Local\Temp\tmp2A86.tmp\tmpB9AB.tmp' created with security descriptor 'O:BAG:S-1-5-21-820728443-44925810-1835867902-513D:(A;;0x1301ff;;;OW)S:AI(ML;ID;NWNRNX;;;HI)'
Execute the console application TEMPEST.COM
built in
step 2. under the
BUILTIN\Administrator
account:
.\TEMPEST.COM
GetTempPath() returned pathname 'C:\Users\Administrator\AppData\Local\Temp\' of 42 characters Subdirectory 'C:\Users\Administrator\AppData\Local\Temp\tmp3CDA.tmp' created with security descriptor 'O:BAG:S-1-5-21-3150931553-3643200234-2488609525-513D:P(A;OICI;0x1301ff;;;OW)S:AI(ML;OICI;NWNRNX;;;HI)' File 'C:\Users\Administrator\AppData\Local\Temp\tmp3CDA.tmp\tmp4B12.tmp' created with security descriptor 'O:BAG:S-1-5-21-3150931553-3643200234-2488609525-513D:(A;;0x1301ff;;;OW)S:AI(ML;ID;NWNRNX;;;HI)'
Execute the console application TEMPEST.COM
built in
step 2. under the
NT AUTHORITY\SYSTEM
alias
LocalSystem
account:
.\TEMPEST.COM
GetTempPath() returned pathname 'C:\Windows\Temp\' of 16 characters Subdirectory 'C:\Windows\Temp\tmp4894.tmp' created with security descriptor 'O:SYG:SYD:P(A;OICI;0x1301ff;;;OW)S:AI(ML;OICI;NWNRNX;;;SI)' File 'C:\Windows\Temp\tmp4894.tmp\tmp6E0C.tmp' created with security descriptor 'O:SYG:SYD:(A;;0x1301ff;;;OW)S:AI(ML;ID;NWNRNX;;;SI)'
%SystemRoot%\Temp\
directory; always
create a properly secured subdirectory which other (less privileged)
users can’t access first, then create your files there!
Since this doesn’t help with existing self-extractors which ignore this basic rule of isolation and privilege separation, better use the following alternative mitigation.
%SystemRoot%\System32\Config\SystemProfile\AppData\Local\Temp\
,
on 64-bit systems also
%SystemRoot%\SysWoW64\Config\SystemProfile\AppData\Local\Temp\
,
owned by the NT AUTHORITY\SYSTEM
alias
LocalSystem
user account, and set the system-specific environment variables
TEMP
and TMP
to the value
%USERPROFILE%\AppData\Local\Temp
.
Use the following command lines in the batch script
%SystemRoot%\Setup\Scripts\SetupComplete.cmd
to apply
these changes automatically during Windows Setup:
Rem Copyright © 2009-2024, Stefan Kanthak <stefan.kanthak@nexgo.de>
MkDir "%SystemRoot%\System32\Config\SystemProfile\AppData\Local\Temp"
If Exist "%SystemRoot%\SysWoW64\Config\SystemProfile" MkDir "%SystemRoot%\SysWoW64\Config\SystemProfile\AppData\Local\Temp"
"%SystemRoot%\System32\SetX.exe" TEMP "%%USERPROFILE%%\AppData\Local\Temp" /M
"%SystemRoot%\System32\SetX.exe" TMP "%%USERPROFILE%%\AppData\Local\Temp" /M
Exit /B
Note: this mitigation also stops
many other attacks and thus prevents
vulnerabilities like
Microsoft Windows Defender Elevation of Privilege Vulnerability
alias
CVE-2020-1170
from being exploited in the first place!
Caveat: on 64-bit systems, the disjoint directories may cause surprising behaviour!
(D;OIIO;WP;;;WD)
and
(D;CIOIIO;WD;;;OW)
to the
DACL of
the %SystemRoot%\Temp\
directory: the first
ACE denies
executepermission for all files created there, the second ACE denies the respective owner of files and subdirectories the (otherwise implied) permission to change their DACL:
ICACLs.exe "%SystemRoot%\Temp" /Deny *S-1-1-0:(OI)(IO)(X) *S-1-3-4:(CI)(OI)(IO)(WDAC) /C /Q /THow Security Descriptors and Access Control Lists Work
Also set the attributes hidden
and system
to prevent
File Explorer from granting full
access to any UAC
controlled administrator
account, as documented in the
MSKB
article
950934.
Use the following command lines in the batch script
%SystemRoot%\Setup\Scripts\SetupComplete.cmd
to apply
these changes automatically during Windows Setup:
Rem Copyright © 2009-2024, Stefan Kanthak <stefan.kanthak@nexgo.de>
"%SystemRoot%\System32\CACLs.exe" "%SystemRoot%\Temp" /S:"D:PAR(D;CIOIIO;WD;;;OW)(D;OIIO;WP;;;WD)(A;CI;0x100026;;;BU)(A;;FA;;;BA)(A;OICIIO;GA;;;BA)(A;;FA;;;SY)(A;OICIIO;GA;;;SY)(A;OICIIO;GA;;;CO)"
"%SystemRoot%\System32\Attrib.exe" +H +R +S "%SystemRoot%\Temp" /M
Exit /B
Note: the instrumentation prevents only attacks via
fake system DLLs;
it does not prevent similar attacks via fake system
programs like
Cmd.exe
etc., which
may be called from batch scripts running in the
%SystemRoot%\Temp\
directory via unqualified filenames.
Use the X.509 certificate to send S/MIME encrypted mail.
Note: email in weird format and without a proper sender name is likely to be discarded!
I dislike
HTML (and even
weirder formats too) in email, I prefer to receive plain text.
I also expect to see your full (real) name as sender, not your
nickname.
I abhor top posts and expect inline quotes in replies.
as iswithout any warranty, neither express nor implied.
cookiesin the web browser.
The web service is operated and provided by
Telekom Deutschland GmbH The web service provider stores a session cookie
in the web
browser and records every visit of this web site with the following
data in an access log on their server(s):