Service accounts that drift without an owner or a lifecycle policy are a classic breeding ground for privilege creep. In 2025 a mid‑size SaaS vendor hit the headlines when a legacy Windows service account had been reused on dozens of VMs, giving attackers a foothold that sidestepped MFA. The same pattern shows up on Linux: systemd units or cron jobs pointing at accounts that never show up in the central identity store.
Why unmanaged accounts matter
- Silent escalation – An attacker can drop a malicious binary into a directory owned by an unmanaged account and get elevated rights without tripping the usual audit trails.
- No revocation – When someone leaves, the account stays alive because there’s no HR hook to disable it.
- Shadow privileges – Untracked accounts can be granted
sudoor group memberships that the policy engine never sees.
Step‑by‑step audit workflow
-
Discover all non‑human accounts
awk -F: '($3 >= 1000 && $3 < 65534) {print $1}' /etc/passwdThis pulls out users with UIDs in the normal range, skipping system users (
< 1000) andnobody(65534). Cross‑check the list against your corporate IdP (Azure AD, Okta) via API or LDAP. -
Map account usage
systemd-analyzeandsystemctl list-unit-files --type=serviceshow which services reference each account.grep -R "User=" /etc/systemd/system/*.servicepulls explicitUser=directives.- For cron:
crontab -l -u <user>andgrep -R "^<user>" /etc/cron.d/.
-
Check for orphaned credentials
- Verify each account has a password policy that enforces rotation.
- For key‑based logins, audit
/home/<user>/.ssh/authorized_keysfor key age and revoke keys older than the policy window.
-
Validate group memberships
id <user>Make sure the account isn’t a member of privileged groups (
sudo,wheel,admin). If it is, document why and set a review cadence. -
Automate alerts
- Set a cron job that runs the discovery script nightly and emails the output to the SOC.
- Hook the script into a SIEM (Splunk, ELK) so a new unmanaged account triggers an alert.
Practical example: a misconfigured service account
# /etc/systemd/system/backup.service
[Service]
User=backup
Group=backup
ExecStart=/usr/local/bin/backup.sh
If backup isn’t in the corporate IdP, anyone who can write to /usr/local/bin/backup.sh can inject code that runs as backup. The audit script will flag backup as unmanaged, prompting a review.
Trade‑offs and caveats
| Approach | Benefit | Drawback |
|---|---|---|
| Strict policy enforcement (no unmanaged accounts) | Cuts privilege creep in half | Requires tight onboarding/offboarding |
| Periodic manual reviews | Human oversight catches nuance | Resource‑heavy; easy to miss |
| Automated tooling | Scales as infrastructure grows | Can flag legitimate accounts that just aren’t in the IdP |
A hybrid model usually works best: let automation surface the oddball accounts, then have analysts triage, document, and close each case. Use a ticketing system to track remediation and enforce a 30‑day deprovisioning window for orphaned accounts.
Common pitfalls
- Assuming UID 0 is the only danger – non‑root users with
sudoor privileged group memberships can still be abused. - Ignoring containerized environments – Kubernetes service accounts can map to host users; audit the
serviceAccountNamefield in pod specs. - Overlooking legacy scripts – Perl or Python batch jobs that hard‑code usernames can bypass systemd checks.
Quick checklist for teams
- Run the discovery script nightly and archive the results.
- Verify each account against the central IdP.
- Ensure no unmanaged account has
sudoorwheelmembership. - Rotate credentials for all service accounts every 90 days.
- Document ownership and purpose for every non‑human account.
Resources
- NIST SP 800‑53 Rev. 5 – Access Control
- OWASP Identity Management Cheat Sheet
See also
- How ML and Behavioral Analysis Are Changing WAFs
- Using Attack Trees to Spot OAuth Token Leakage in Microservices
- Using NetFlow Anomaly Scoring to Spot Lateral Movement in Hybrid Clouds
- Using Abuse‑Case Playbooks to Spot Hidden API Injection Paths
- Recovering from RDP‑to‑Admin lateral move: post‑mortem containment tactics
- Avoiding Session Fixation in OAuth 2.0 Implementations