Back to Blog

Event ID 3065 and 3066 CodeIntegrity Audit Before Turning On LSA Protection

Christopher 4 min read
referencewindows

Event IDs 3065 and 3066 are written to the Code Integrity operational log when LSASS.exe loads a module that would fail to load with added LSA protection turned on. In Event Viewer the log is under "Applications and Services Logs" > "Microsoft" > "Windows" > "CodeIntegrity" > "Operational". Microsoft describes the two events this way.

What it means

LSASS is running in audit mode, so the module still loaded. Once LSA protection (RunAsPPL) is turned on, LSASS runs as a protected process and refuses that module. Protected mode requires every plug-in loaded into LSA to be signed with a Microsoft signature. Event 3066 means the module doesn't meet that signing level. Event 3065 means the module contains shared sections, and a module with shared sections logs 3066 together with 3065.

How to find the cause

Turn on audit mode on each server or domain controller before you turn on LSA protection. Create the DWORD value AuditLevel with the value 8 under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\LSASS.exe, then restart. Microsoft documents audit mode as on by default on Windows 11 version 22H2 and later.

Confirm the name of the Code Integrity log on the machine.

Get-WinEvent -ListLog *CodeIntegrity* | Select-Object LogName

List the audit events with the time, ID, and message of each.

Get-WinEvent -FilterHashtable @{ LogName='Microsoft-Windows-CodeIntegrity/Operational'; Id=3065,3066 } | Select-Object TimeCreated,Id,Message

Collect the same events from every server you plan to protect. -ComputerName takes one computer name per call, so loop over a text file with one server name per line.

foreach ($s in Get-Content .\servers.txt) { Get-WinEvent -ComputerName $s -FilterHashtable @{ LogName='Microsoft-Windows-CodeIntegrity/Operational'; Id=3065,3066 } | Select-Object @{n='Server';e={$s}},TimeCreated,Id,Message }

Check the signature of each file the messages name.

Get-AuthenticodeSignature -FilePath 'C:\Path\To\module.dll' | Format-List *

Microsoft's recommended practice is to identify every LSA plug-in and driver before broad deployment, including smart card, cryptographic, and password filter software, and to test that each one loads and works. Audit events aren't written while Smart App Control is on or while a kernel debugger is attached and enabled.

Fixes

Update each module that logged 3066 to a version its vendor has signed with a Microsoft signature. LSA plug-ins that are drivers, such as smart card drivers, need Windows Hardware Quality Labs (WHQL) certification. Other plug-ins are signed through the file signing service for LSA.

Get a version without shared sections for each module that logged 3065. Removing the shared sections stops both events unless the module also fails the signing level check.

Turn on LSA protection once no new 3065 or 3066 events appear. Set the DWORD RunAsPPL under HKLM\SYSTEM\CurrentControlSet\Control\Lsa to 1 to store the setting in a UEFI variable, or to 2 to enable it without the UEFI variable. The value 2 is only enforced on Windows 11 22H2 and later. On Windows 11 22H2 and later you can use the Group Policy setting "Configures LSASS to run as a protected process" under "Computer Configuration" > "Administrative Templates" > "System" > "Local Security Authority" instead.

After the restart, check the System log for WinInit event 12, which reads "LSASS.exe was started as a protected process with level: 4".

Plan the rollback before you set 1. With the UEFI lock, setting RunAsPPL back to 0 has no effect. Remove the UEFI variable with Microsoft's Local Security Authority (LSA) Protected Process Opt-out tool. The tool is an EFI application (LsaPplConfig.efi), so plan console access for each server. When the Group Policy setting was used, set it to "Disabled". "Not Configured" leaves the earlier setting in force.

Related events

Where ET Ducky shows it

I build ET Ducky. A Live Session on a managed Windows server runs an AI-driven investigation where the AI picks the ETW providers to capture in each round, and only counts-only summaries leave the host. Beyond the fifteen built-in behavioral rules, you can create custom rules using a rule builder to monitor for events that are unique in your environment.

Sources

Live Sessions on a managed endpoint

Read how a Live Session runs an AI-driven ETW investigation on one host and what leaves the host.

Read the Live Sessions docs