Repository navigation
Run login payloads once per desktop sign-in, not on every interactive logon - #22
Merged
Merged
Conversation
… logon Event 4624 with logon type 2, 10 or 11 is also written for scheduled tasks, services calling LogonUser and runas, and twice for an administrator's own sign-in. Each of those ran the whole login batch against the console session. The worker now asks LSA which session the logon belongs to and ignores logons in session 0 or ones that have already closed. After the desktop wait it runs the batch only when the logon's account is the one signed in to that session, and only once for each sign-in, identified by session, user and logon time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The login worker treats every 4624 event with logon type 2, 10 or 11 as a user arriving at the desktop, and runs the whole login batch against the console session for each one. Those logon types are also written by:
runas, and elevation prompts that take another account's credentialsThe session lookup also never worked. It read a
SessionIdfield that event 4624 doesn't have, so it always fell back to the console session.Change
LogonSessions(new, insrc/Engine/Native) usesLsaGetLogonSessionDatato find which desktop session the event'sTargetLogonIdbelongs to, andWTSQuerySessionInformationto read when that session was signed in to.LoginGate(new, insrc/Engine) checks each logon in two steps:LogonEventWorkerapplies both checks. The start-up catch-up goes through the same claim, so a later event for that sign-in doesn't run the batch again.Tests
dotnet test tests/StartSet.Tests -c Release: 303 passed, 0 failed.LoginGateTestscheck that:They also check the native lookups against the test process's own logon session: LSA maps it to the process's own session id, and the session's sign-in time is in the past.
Not covered here
The change has not been run on a VM against real scheduled-task,
runasand administrator sign-ins. That needs the Security log read as SYSTEM.