The Leaver the Job Was Waiting For: An Active Directory Logic Bomb
The challenge
Code review flagged Brackwater's roster job. Trace which account its hidden check watches. Name the account IT must not disable yet.
What you'll learn
- Recognise a logic bomb hidden behind an innocent-looking scheduled task
- Read an LDAP filter, including the userAccountControl disabled-bit match
- Rebuild a SID from the domain SID and a hex RID, then map it to its account
- Tell a destructive branch from a genuine health check that only alerts
- Plan offboarding so disabling an account does not detonate a trap
Skills tested
Prerequisites
- Reading Java
- What an Active Directory account is
How it works
A logic bomb is code that waits for a condition and then does damage. Insiders like a condition that will only come true when they are gone: their own account being disabled, deleted, or moved to a leavers OU. That makes the trap detonate during offboarding, when the security team is the one pulling the trigger.
In Active Directory every account has a SID: the domain's identifier plus a relative ID (RID) at the end, for example S-1-5-21-...-1103. The SID never changes when the account is renamed, and it does not contain the name, so a review that greps the code for a username finds nothing. AD accepts the string form directly in an LDAP filter ((objectSid=S-1-5-21-...)).
userAccountControl is a bit field: bit 0x2 means disabled, and 514 is a normal account (512) with that bit set. The filter (userAccountControl:1.2.840.113556.1.4.803:=2) is AD's bitwise-AND match for "disabled". In 2025 a US court convicted Davis Lu, a former Eaton developer, of planting exactly this kind of check on his own account.
Common mistakes
- Answering j.okafor. The
@authortag says who wrote the file, not who the trap protects. Nothing in the code looks him up. - Answering svc_rosterdb or svc_smtprelay.
checkServiceAccountsis a genuine health check: when one is disabled it only emails it-ops. - Answering svc_rostersync. It is the account the job binds as, and it is exempt from the damage. Its rights are why the damage is possible, but it is not the trigger.
- Answering r.amari or adm-dpike. r.amari's SID ends in 2742, one after the target. adm-dpike is the same person's admin account with its own SID, 2803.
- Looking for 0xAB5 or AB5 in the list. Java concatenates an int in decimal, so the SID ends in -2741 (0xAB5 = 10 x 256 + 11 x 16 + 5).
- Answering the SID or the number. The question asks for the account, so map the SID to its SamAccountName.
How to defend against it
- Do not disable d.pike yet: first stop the service or remove the job, keep a copy of the code and its commit history as evidence, then offboard.
- Before disabling a departing developer or admin, review what they changed recently: scheduled jobs, scripts, service code, and anything that reads directory state.
- Give sync accounts least privilege: delegate only the attributes and OUs they need, and deny them on privileged accounts, so one account cannot disable the whole domain.
- Require a second reviewer on every change to scheduled tasks and directory-writing code, and alert on bursts of
userAccountControlchanges (event 4738) and mass deletions. - Keep tested offline backups of profile shares.