When it is written
AD FS writes 512 to the Security log of the AD FS server, under the event source AD FS Auditing, when a user is in the extranet lockout state and AD FS still lets a sign-in attempt through; its text says the attempt is allowed due to the system configuration. It names the user, the client IP, the bad password count and the time of the last bad password.
Microsoft's current pages do not say which configuration. A 2015 Microsoft post on extranet lockout in AD FS for Windows Server 2012 R2 names the audit ExtranetLockoutAccountThrottledAudit and says it is written when AD FS allows an attempt after the observation window has passed: extranet lockout lets a locked user try once per window. Extranet Smart Lockout in Log-Only mode also lets every request through while it writes its audit events, and the library's lockout rule reads 512 as that case; Microsoft does not confirm that log-only mode writes 512. Either way, it is an attempt on a locked account that AD FS did not stop.
Like the other lockout events, it needs extranet lockout and AD FS auditing, and covers only user name and password requests that come through the Web Application Proxy.
How to turn it on
AD FS Auditing writes the event to the AD FS auditing (Event Viewer > Windows Logs > Security (event source AD FS Auditing)), which is off by default. Microsoft
AD FS writes its audit events to the Security log of each AD FS server, with AD FS Auditing as the event source. Microsoft says these audit logs are not enabled by default; its Connect Health steps add that the two Federation Service check boxes should already be selected. Three settings must all be in place:
- The user right. The AD FS service account must hold Generate security audits (Local Security Policy > Security Settings > Local Policies > User Rights Assignment). Where AD FS runs on a domain controller, Microsoft points to the Default Domain Controllers Policy instead of the local policy.
- The audit subcategory. Audit Application Generated (Object Access) for success and failure, by Group Policy (Advanced Audit Policy Configuration > Audit Policies > Object Access) or locally with
auditpol. Microsoft warns that a Group Policy can turn AD FS auditing off. - The Federation Service audits. In AD FS Management, Edit Federation Service Properties > Events: Success audits and Failure audits. Connect Health's steps make this change on the primary server only, because it is a setting of the farm.
From Windows Server 2016 the farm also has an audit level, shown as AuditLevel by Get-AdfsProperties: Basic, the default, logs no more than five events per request and includes 1200 to 1203; Verbose logs every event, including 411, 412 and 501 (Microsoft's Connect Health tables); None logs nothing. Microsoft Defender for Identity and Connect Health ask for Verbose.
Audit every AD FS server of the farm, because each one logs only the requests it handled. The Web Application Proxy servers do not need auditing. The extranet lockout events (512, 515, 516, 1210) also need extranet lockout to be enabled; the check command below shows its settings.
auditpol /get /subcategory:"Application Generated"auditpol /get /subcategory:"{0CCE9222-69AE-11D9-BED3-505054503030}"auditpol /set /subcategory:"Application Generated" /success:enable /failure:enableGet-AdfsProperties | Format-List AuditLevel, LogLevel, EnableExtranetLockout, ExtranetLockoutMode, ExtranetLockoutThreshold, ExtranetObservationWindowSet-AdfsProperties -AuditLevel VerboseNeeds extranet lockout turned on (EnableExtranetLockout true; with Extranet Smart Lockout, in Log-Only or Enforce mode) and AD FS auditing reaching the Security log. Get-AdfsProperties shows ExtranetLockoutMode, ExtranetLockoutThreshold and ExtranetObservationWindow.
Fields
The template of this event is not part of client Windows and Microsoft does not publish its XML field names, so the fields are named by the labels of Microsoft’s documentation.
| Field | What it holds |
|---|---|
| Activity ID | GUID that AD FS assigns to the request and logs in every event of it, in the audit, admin and debug logs. All zeros for legacy authentication proxied by Exchange Online. |
| User | The locked out user whose sign-in attempt AD FS let through. Microsoft's lockout cmdlets take the user principal name; check which form your events carry. |
| Client IP | Address of the client of the request. Microsoft notes that it can be one of Microsoft's addresses when Exchange Online sends a legacy authentication request for the client. |
| Bad Password Count | Number of bad passwords counted for the user. With the original extranet lockout this is the badPwdCount that AD FS reads from the primary domain controller; with smart lockout, AD FS's own count. |
| Last Bad Password Attempt | Time of the user's most recent bad password, from which the observation window is measured. |
Values to know
Client IP
| Value | Meaning | Signal |
|---|---|---|
The address behind the bad passwords | The source of the attack tries againLook for 515 or 1202 next, which would mean the password it tries is right. | Attack signal |
The user's own usual address | A device of the user with an old passwordHave the saved password updated. | Noise |
A Microsoft address | Legacy authentication through Exchange OnlineMicrosoft says the submitter is then in x-ms-forwarded-client-ip, not in this field. | Worth knowing |
Bad Password Count
| Value | Meaning | Signal |
|---|---|---|
At or above the threshold | The user is in the lockout stateThe count AD FS compares with ExtranetLockoutThreshold. | Worth knowing |
Volume and noise
The user is in the lockout state because bad passwords were submitted for it from the extranet, so the event follows the same causes as the lockout: an attack, or a device that keeps submitting the user's old password. Such a device tries again after each observation window, which writes 512 at a steady pace for the same user and address. Where smart lockout runs in log-only mode, expect more of these events until it is moved to enforce mode.
Keeping it manageable
- Keep every 512: the library's lockout rule reads it, and the volume is low.
- Group by User and Client IP. The same user and the user's own address at regular intervals is a device with an old password; one address for many users is a spray.
- Check the lockout mode with
Get-AdfsPropertiesbefore you rate a burst of 512: in log-only mode no attempt is refused, so the events show what enforce mode would have stopped.
Attacks this event reveals
Detection rules that read this event:
Frequently asked questions
Why does AD FS allow a sign-in attempt for a locked out account?
Extranet lockout is not permanent. Microsoft describes it as refusing the user's password requests from the extranet until the observation window has passed, then allowing one attempt per window. Extranet Smart Lockout in log-only mode refuses nothing and only writes its audit events. Event 512 says an attempt for a locked out user was allowed, without naming which of these applied.
Is AD FS event 512 a sign of an attack?
It means the user's account is in the lockout state, which takes repeated bad passwords from the extranet, and that someone is still trying. Compare the client address with the user's usual addresses: a device with an old password is common, an address that also appears for other users is a spray. Watch for 515 for the same user, which would mean the right password was supplied.
References
- AD FS Extranet Lockout and Extranet Smart Lockout overview (Microsoft)
- Demystify extranet lockout feature in AD FS 3.0, the lockout audits (Microsoft, archived 2015 post)
- Description of the Extranet Smart Lockout feature in Windows Server 2016 (Microsoft)
- Configure AD FS Extranet Lockout Protection (Microsoft)