Performing Service Account Audit
Overview
Audit service accounts across enterprise infrastructure to identify orphaned, over-privileged, and non-compliant accounts. This skill covers discovery of service accounts in Active Directory, cloud platforms, databases, and applications, assessing privilege levels, identifying missing owners, and enforcing lifecycle policies.
Anti-Rationalization Table
| Rationalization |
Reality |
| "I'll figure it out as I go" |
A structured approach saves time and reduces errors. Follow the workflow in this skill rather than improvising. |
| "I already know this topic" |
Familiarity breeds shortcuts. Use the checklist to verify you haven't missed critical steps. |
| "This doesn't apply to my situation" |
The patterns here generalize across contexts. Adapt, don't skip — the underlying principles hold. |
| "One more tool will fix it" |
Adding complexity rarely solves process gaps. Master the core workflow first. |
When to Use
Trigger phrases:
"performing service account audit"
"Audit service accounts across enterprise infrastructure to identify orphaned, ov"
When conducting security assessments that involve performing service account audit
When following incident response procedures for related security events
When performing scheduled security testing or auditing activities
When validating security controls through hands-on testing
Prerequisites
- Familiarity with identity access management concepts and tools
- Access to a test or lab environment for safe execution
- Python 3.8+ with required dependencies installed
- Appropriate authorization for any testing activities
Objectives
- Discover all service accounts across AD, cloud, databases, and applications
- Identify orphaned accounts with no valid owner or associated application
- Assess privilege levels and flag over-privileged service accounts
- Check for non-rotating passwords and weak authentication
- Map service account dependencies for safe remediation
- Generate compliance reports for SOX, PCI DSS, and HIPAA audits
Key Concepts
This section covers key concepts for performing service account audit.
- Ensure all prerequisites are met before proceeding
- Follow the documented workflow steps in sequence
- Record results and any anomalies encountered during this phase
Service Account Types
- AD Service Accounts: Windows services, scheduled tasks, IIS app pools
- Managed Service Accounts (gMSA): AD-managed automatic password rotation
- Cloud IAM Service Accounts: AWS IAM roles/users, Azure service principals, GCP service accounts
- Database Service Accounts: Application connection accounts, replication accounts
- Application Service Accounts: API keys, bot accounts, integration accounts
Audit Dimensions
- Ownership: Who is responsible for this account?
- Purpose: What application/service uses this account?
- Privileges: What permissions does this account have?
- Authentication: How does this account authenticate (password, key, certificate)?
- Rotation: When was the credential last changed?
- Activity: When was this account last used?
Workflow
# Example: IOC detection
import re
IOC_PATTERNS = {
"ip": r"\b(?:\d{1,3}\.){3}\d{1,3}\b",
"domain": r"\b[a-z0-9-]+\.[a-z]{2,}\b",
"hash_md5": r"\b[a-f0-9]{32}\b",
"hash_sha256": r"\b[a-f0-9]{64}\b",
}
def extract_iocs(text: str) -> dict:
return {k: re.findall(v, text) for k, v in IOC_PATTERNS.items()}
- Scope the task — define objectives, boundaries, and success criteria
- Gather information — collect all necessary data and context before proceeding
- Execute the core workflow — follow the domain-specific steps methodically
- Validate results — verify outputs against expected outcomes or baselines
- Document findings — record results, anomalies, and recommendations
Step 1: Discovery - Active Directory
- Query AD for all service accounts (filter by description, OU, naming convention)
- Identify accounts with
ServicePrincipalName set
- List accounts in privileged groups (Domain Admins, Enterprise Admins)
- Check for gMSA vs traditional service accounts
- Identify accounts with
PasswordNeverExpires flag
Step 2: Discovery - Cloud Platforms
- AWS: List IAM users with access keys, check last used date, identify unused roles
- Azure: Enumerate service principals, app registrations, managed identities
- GCP: List service accounts, check key age, identify unused permissions
Step 3: Assessment
- Flag accounts with admin/privileged group membership
- Check password age against rotation policy (90 days max)
- Identify accounts with no login activity in 90+ days
- Verify account ownership against CMDB/asset inventory
- Check for shared credentials (same password hash across accounts)
Step 4: Risk Classification
- Critical: Domain/cloud admin privileges, no password rotation
- High: Access to sensitive data, no identified owner
- Medium: Standard service permissions, password older than 90 days
- Low: Read-only access, managed credentials (gMSA, managed identity)
Step 5: Remediation
- Disable orphaned accounts after validation with application teams
- Convert traditional service accounts to gMSA where possible
- Rotate credentials older than policy threshold
- Reduce privileges to minimum required
- Assign owners and document dependencies
Security Controls
| Control |
NIST 800-53 |
Description |
| Account Management |
AC-2 |
Service account lifecycle |
| Account Review |
AC-2(3) |
Periodic review of accounts |
| Least Privilege |
AC-6 |
Minimum service account permissions |
| Authenticator Management |
IA-5 |
Service credential rotation |
| Audit Review |
AU-6 |
Review service account activity |
Common Pitfalls
- Disabling service accounts without verifying application dependencies first
- Not discovering service accounts outside of Active Directory
- Missing cloud service principals and managed identities
- Not checking for interactive logon rights on service accounts
- Failing to document dependencies before remediation
Verification
When NOT to Use
- You don't have explicit written authorization to test
- Task is about defense/detection, not offense (use detection skills)
- You need to implement security controls (use implementing-* skills)
- Task requires compliance auditing (use auditing-* skills)
- You're investigating an incident (use incident response skills)
- Target is out of scope for your engagement
- Task is about vulnerability scanning only (use scanning tools)
Red Flags
- Performing actions without explicit written authorization from the asset owner
- Testing against production systems without a defined scope and rules of engagement
- Treating compliance checklists as security guarantees rather than minimum baselines
- Failing to document exceptions and risk acceptance decisions
- Relying on point-in-time audits instead of continuous monitoring
Process
- Analyze the task requirements
- Apply domain expertise
- Verify output quality
1---2name: performing-service-account-audit3description: Use when auditing service accounts across enterprise infrastructure to4 identify orphaned, over-privileged, and non-compliant accounts. This skill covers5 discovery of service accounts in Active Directory, cloud pl6domain: cybersecurity7subdomain: identity-access-management8tags:9- iam10- identity11- access-control12- service-accounts13- audit14- governance15version: '1.0'16author: oyi7717license: Apache-2.018nist_csf:19- PR.AA-0120- PR.AA-0221- PR.AA-0522- PR.AA-0623category: cybersecurity24metadata:25 source: https://skillmd.com/skills/oyi77/performing-service-account-audit26---2728# Performing Service Account Audit2930## Overview31Audit service accounts across enterprise infrastructure to identify orphaned, over-privileged, and non-compliant accounts. This skill covers discovery of service accounts in Active Directory, cloud platforms, databases, and applications, assessing privilege levels, identifying missing owners, and enforcing lifecycle policies.32333435## Anti-Rationalization Table3637| Rationalization | Reality |38|---|---|39| "I'll figure it out as I go" | A structured approach saves time and reduces errors. Follow the workflow in this skill rather than improvising. |40| "I already know this topic" | Familiarity breeds shortcuts. Use the checklist to verify you haven't missed critical steps. |41| "This doesn't apply to my situation" | The patterns here generalize across contexts. Adapt, don't skip — the underlying principles hold. |42| "One more tool will fix it" | Adding complexity rarely solves process gaps. Master the core workflow first. |4344## When to Use45**Trigger phrases:**46- "performing service account audit"47- "Audit service accounts across enterprise infrastructure to identify orphaned, ov"484950- When conducting security assessments that involve performing service account audit51- When following incident response procedures for related security events52- When performing scheduled security testing or auditing activities53- When validating security controls through hands-on testing5455## Prerequisites5657- Familiarity with identity access management concepts and tools58- Access to a test or lab environment for safe execution59- Python 3.8+ with required dependencies installed60- Appropriate authorization for any testing activities6162## Objectives63- Discover all service accounts across AD, cloud, databases, and applications64- Identify orphaned accounts with no valid owner or associated application65- Assess privilege levels and flag over-privileged service accounts66- Check for non-rotating passwords and weak authentication67- Map service account dependencies for safe remediation68- Generate compliance reports for SOX, PCI DSS, and HIPAA audits6970## Key Concepts7172This section covers key concepts for performing service account audit.7374- Ensure all prerequisites are met before proceeding75- Follow the documented workflow steps in sequence76- Record results and any anomalies encountered during this phase77### Service Account Types781. **AD Service Accounts**: Windows services, scheduled tasks, IIS app pools792. **Managed Service Accounts (gMSA)**: AD-managed automatic password rotation803. **Cloud IAM Service Accounts**: AWS IAM roles/users, Azure service principals, GCP service accounts814. **Database Service Accounts**: Application connection accounts, replication accounts825. **Application Service Accounts**: API keys, bot accounts, integration accounts8384### Audit Dimensions85- **Ownership**: Who is responsible for this account?86- **Purpose**: What application/service uses this account?87- **Privileges**: What permissions does this account have?88- **Authentication**: How does this account authenticate (password, key, certificate)?89- **Rotation**: When was the credential last changed?90- **Activity**: When was this account last used?9192## Workflow9394```python95# Example: IOC detection96import re9798IOC_PATTERNS = {99 "ip": r"\b(?:\d{1,3}\.){3}\d{1,3}\b",100 "domain": r"\b[a-z0-9-]+\.[a-z]{2,}\b",101 "hash_md5": r"\b[a-f0-9]{32}\b",102 "hash_sha256": r"\b[a-f0-9]{64}\b",103}104105def extract_iocs(text: str) -> dict:106 return {k: re.findall(v, text) for k, v in IOC_PATTERNS.items()}107```1081091. **Scope the task** — define objectives, boundaries, and success criteria1102. **Gather information** — collect all necessary data and context before proceeding1113. **Execute the core workflow** — follow the domain-specific steps methodically1124. **Validate results** — verify outputs against expected outcomes or baselines1135. **Document findings** — record results, anomalies, and recommendations114### Step 1: Discovery - Active Directory1151. Query AD for all service accounts (filter by description, OU, naming convention)1162. Identify accounts with `ServicePrincipalName` set1173. List accounts in privileged groups (Domain Admins, Enterprise Admins)1184. Check for gMSA vs traditional service accounts1195. Identify accounts with `PasswordNeverExpires` flag120121### Step 2: Discovery - Cloud Platforms122- **AWS**: List IAM users with access keys, check last used date, identify unused roles123- **Azure**: Enumerate service principals, app registrations, managed identities124- **GCP**: List service accounts, check key age, identify unused permissions125126### Step 3: Assessment127- Flag accounts with admin/privileged group membership128- Check password age against rotation policy (90 days max)129- Identify accounts with no login activity in 90+ days130- Verify account ownership against CMDB/asset inventory131- Check for shared credentials (same password hash across accounts)132133### Step 4: Risk Classification134- **Critical**: Domain/cloud admin privileges, no password rotation135- **High**: Access to sensitive data, no identified owner136- **Medium**: Standard service permissions, password older than 90 days137- **Low**: Read-only access, managed credentials (gMSA, managed identity)138139### Step 5: Remediation140- Disable orphaned accounts after validation with application teams141- Convert traditional service accounts to gMSA where possible142- Rotate credentials older than policy threshold143- Reduce privileges to minimum required144- Assign owners and document dependencies145146## Security Controls147| Control | NIST 800-53 | Description |148|---------|-------------|-------------|149| Account Management | AC-2 | Service account lifecycle |150| Account Review | AC-2(3) | Periodic review of accounts |151| Least Privilege | AC-6 | Minimum service account permissions |152| Authenticator Management | IA-5 | Service credential rotation |153| Audit Review | AU-6 | Review service account activity |154155## Common Pitfalls156- Disabling service accounts without verifying application dependencies first157- Not discovering service accounts outside of Active Directory158- Missing cloud service principals and managed identities159- Not checking for interactive logon rights on service accounts160- Failing to document dependencies before remediation161162## Verification163- [ ] Service accounts inventoried across all platforms164- [ ] Each account has assigned owner165- [ ] Privileged service accounts documented with justification166- [ ] Password rotation compliance checked167- [ ] Orphaned accounts flagged for remediation168- [ ] gMSA migration candidates identified169- [ ] Compliance report generated170## When NOT to Use171172- You don't have explicit written authorization to test173- Task is about defense/detection, not offense (use detection skills)174- You need to implement security controls (use implementing-* skills)175- Task requires compliance auditing (use auditing-* skills)176- You're investigating an incident (use incident response skills)177- Target is out of scope for your engagement178- Task is about vulnerability scanning only (use scanning tools)179180181## Red Flags182183- Performing actions without explicit written authorization from the asset owner184- Testing against production systems without a defined scope and rules of engagement185- Treating compliance checklists as security guarantees rather than minimum baselines186- Failing to document exceptions and risk acceptance decisions187- Relying on point-in-time audits instead of continuous monitoring188189## Process1901911. Analyze the task requirements1922. Apply domain expertise1933. Verify output quality