Event ID 4634
Event ID 4634: Account Logoff
An account was logged off
- Log source
- Security
- How to enable it
- Logon/Logoff > Audit Logoff (Success)
- Category
- Authentication
- Priority
- Low
- Typical volume
- Very high
- MITRE ATT&CK
What Event ID 4634 means
4634 marks the end of a logon session, when the system destroys it. It is the closing bracket for 4624: the same TargetLogonId and LogonType appear in both, and the difference between the two timestamps is the length of the session.
Nobody alerts on logoff by itself. Its worth is in reconstruction. Knowing that a session ended at 02:14 lets an investigator exclude later activity from that account, or prove that a process outlived the person who started it. Network sessions (type 3) that last less than a second across many hosts are typical of automated access.
The event is not reliable as a record of when a person left their desk. It is missing when a computer crashes or loses power, and an interactive session may be held open by a process long after the user signs out. For deliberate sign-outs, 4647 is the better evidence.
Key fields to inspect
| Field | Meaning | Suspicious when |
|---|---|---|
TargetLogonId | Identifier of the session that ended. | A value with no matching 4624, which suggests a gap in collection or a cleared log. |
TargetUserName | Account whose session ended. | A privileged account with sessions on hosts it should never touch. |
TargetDomainName | Domain or computer of the account. | The local computer name, which shows that a local account was used. |
LogonType | Type of the session that ended. | 3 in rapid bursts, or 10 at hours when nobody works. |
TargetUserSid | Security identifier of the account. | A SID ending in 500, the built-in Administrator whatever its name. |
Detection queries
Pair each logon with its logoff to find very short network sessions by one account across many computers. Adjust names and thresholds to your environment. About these queries.
Splunk SPL
index=windows source="XmlWinEventLog:Security" (EventCode=4624 OR EventCode=4634) LogonType=3
| where NOT match(TargetUserName, "\$$")
| stats earliest(_time) AS start latest(_time) AS end dc(EventCode) AS parts BY Computer TargetLogonId TargetUserName
| where parts=2 | eval seconds=end-start
| stats dc(Computer) AS hosts avg(seconds) AS avg_seconds BY TargetUserName
| where hosts>=10 AND avg_seconds<5 Microsoft Sentinel KQL
let logons = SecurityEvent
| where EventID == 4624 and LogonType == 3 and TargetUserName !endswith "$"
| project Computer, TargetLogonId, TargetUserName, Start = TimeGenerated;
SecurityEvent
| where EventID == 4634
| project Computer, TargetLogonId, End = TimeGenerated
| join kind=inner logons on Computer, TargetLogonId
| extend Seconds = datetime_diff("second", End, Start)
| summarize Hosts = dcount(Computer), AverageSeconds = avg(Seconds) by TargetUserName
| where Hosts >= 10 and AverageSeconds < 5 PowerShell
Get-WinEvent -FilterHashtable @{ LogName = 'Security'; Id = 4634; StartTime = (Get-Date).AddDays(-1) } |
ForEach-Object { $d = @{ Time = $_.TimeCreated }; ([xml]$_.ToXml()).Event.EventData.Data | ForEach-Object { $d[$_.Name] = $_.'#text' }; [pscustomobject]$d } |
Where-Object { $_.LogonType -in '2','10' -and $_.TargetUserName -notlike '*$' } |
Select-Object Time, TargetUserName, TargetDomainName, LogonType, TargetLogonId | Format-Table -AutoSize Attack scenarios
Automated share sweeps
Ransomware and discovery tools connect to the administrative shares of every reachable host. Each target records a type 3 logon and a logoff within a second or two, all from the same account and source.
Building an incident timeline
Session boundaries show which actions belong to the intruder and which to the legitimate owner of the account. Overlapping sessions for one person from two places are a strong sign of stolen credentials.
Investigation checklist
- Match TargetLogonId to the 4624 that opened the session, on the same computer and after its last start.
- Calculate the duration and compare it with the account's normal sessions.
- List events with the same identifier between the two timestamps.
- If no logoff exists, check for a restart, a crash or a cleared log (1102).
Common benign causes
- File servers and domain controllers, which end thousands of short network sessions every hour.
- Services that reconnect often, such as backup agents and monitoring probes.
- Delayed logoff of interactive sessions while applications close.
Event ID 4634 FAQ
What is the difference between 4634 and 4647?
4647 is written when a user starts a sign-out from an interactive session. 4634 is written when the session is actually destroyed, for every logon type. A normal desktop sign-out produces 4647 first, and 4634 may follow.
Why is there a 4624 with no 4634?
The computer may have restarted, crashed or lost power, or a process may still hold the session open. Missing logoff events are common and are not evidence of tampering by themselves.
Can I use 4634 to track working hours?
Not reliably. Network sessions end seconds after they begin, and interactive ones may linger. Lock and unlock events (4800 and 4801) together with 4647 give a better picture of presence.