Auditing Unmanaged Service Accounts: Preventing Silent Privilege Escalation

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 sudo or group memberships that the policy engine never sees.

Step‑by‑step audit workflow

  1. Discover all non‑human accounts

    awk -F: '($3 >= 1000 && $3 < 65534) {print $1}' /etc/passwd
    

    This pulls out users with UIDs in the normal range, skipping system users (< 1000) and nobody (65534). Cross‑check the list against your corporate IdP (Azure AD, Okta) via API or LDAP.

  2. Map account usage

    • systemd-analyze and systemctl list-unit-files --type=service show which services reference each account.
    • grep -R "User=" /etc/systemd/system/*.service pulls explicit User= directives.
    • For cron: crontab -l -u <user> and grep -R "^<user>" /etc/cron.d/.
  3. Check for orphaned credentials

    • Verify each account has a password policy that enforces rotation.
    • For key‑based logins, audit /home/<user>/.ssh/authorized_keys for key age and revoke keys older than the policy window.
  4. 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.

  5. 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 sudo or privileged group memberships can still be abused.
  • Ignoring containerized environments – Kubernetes service accounts can map to host users; audit the serviceAccountName field 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 sudo or wheel membership.
  • 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