Open in the explorer

MSS: (SafeDllSearchMode) Enable Safe DLL search mode

Type
Computer
GPO path
Computer Configuration › Policies › Administrative Templates › MSS (Legacy)
Supported on
At least Windows Vista
ADMX file
MSS-legacy.admx
Internal name
MSS-legacy/Pol_MSS_SafeDllSearchMode

Explanation

MSS: (SafeDllSearchMode) Enable Safe DLL search mode

Use cases

Enables safe DLL search mode: the application’s current folder is no longer searched right after its own folder, but later in the search order (step 11 instead of step 8, after the system and Windows folders). This reduces DLL hijacking risk, where a booby-trapped DLL planted in the working directory gets loaded instead of the genuine one.

The mode is enabled by default; the policy mostly serves to guarantee it or to catch it being turned off (SafeDllSearchMode set to 0). Note that an application calling SetDllDirectory with a path effectively defeats the mode while that folder is in the search path, which the policy does not cover.

Microsoft source: Dynamic-link library search order

Registry

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager
Value name
SafeDllSearchMode
StateValue written
EnabledREG_DWORD = 1
DisabledREG_DWORD = 0

PowerShell

PowerShell commands that write to the registry what the policy would write. Values in angle brackets (<…>) must be replaced.

Writing directly to the registry bypasses Group Policy: if a GPO manages this value, it will be rewritten at the next gpupdate; otherwise the value stays in place (the "tattooing" effect). Prefer a GPO or, locally, LGPO.exe. Run PowerShell as administrator for HKLM. Some policies need a restart or gpupdate /force.

Enable

# Enable: MSS-legacy/Pol_MSS_SafeDllSearchMode
$k = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager'
if (-not (Test-Path -Path $k)) { New-Item -Path $k -Force | Out-Null }
Set-ItemProperty -Path $k -Name 'SafeDllSearchMode' -Value 1 -Type DWord

Disable

# Disable: MSS-legacy/Pol_MSS_SafeDllSearchMode
$k = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager'
if (-not (Test-Path -Path $k)) { New-Item -Path $k -Force | Out-Null }
Set-ItemProperty -Path $k -Name 'SafeDllSearchMode' -Value 0 -Type DWord

Revert to "Not configured"

# Revert to "Not configured": MSS-legacy/Pol_MSS_SafeDllSearchMode
$k = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager'
Remove-ItemProperty -Path $k -Name 'SafeDllSearchMode' -ErrorAction SilentlyContinue

Application

Microsoft Security Baseline (MSS, SecGuide) (Microsoft) — November 2026 templates

Official templates downloaded on November 12, 2026.