Least-Privilege Role Design on a Windows VPS: Auditing Group Membership and Service Accounts

Most Windows VPS breaches do not start with an exploit. They start with an account that has more rights than its job requires: a service running as Domain Administrator because nobody worked out the minimum permission set, a contractor left in the local Administrators group after a project ended, or an application pool identity that was added to Backup Operators to fix a file permission error. Least privilege is not a policy document; it is a recurring audit you can perform with PowerShell in about twenty minutes.

This article covers a practical audit for a Windows VPS: enumerating privileged group membership, examining service accounts and their logon rights, identifying stale accounts, and designing role groups that survive staff turnover. The target environment is a standalone or lightly domain-joined Windows Server 2019/2022 host.

Start by Mapping Every Privileged Group

Local Administrators is only the obvious one. On a Windows server, effective privilege also comes from Remote Desktop Users, Backup Operators, Server Operators, Account Operators, Print Operators, Hyper-V Administrators, and Cryptographic Operators. Several of these grant paths to full control that are not intuitive — Backup Operators can read any file and restore a registry hive, which is equivalent to SYSTEM.

Enumerate them all at once with the local group provider: Get-LocalGroup | ForEach-Object { $g=$_; Get-LocalGroupMember -Group $g.Name -ErrorAction SilentlyContinue | Select @{n='Group';e={$g.Name}},Name,ObjectClass,PrincipalSource }. On a domain-joined host, repeat the exercise against Get-ADGroupMember for Domain Admins, Enterprise Admins, Schema Admins, and Account Operators, and note that nested group membership is invisible to the simple cmdlet — use Get-ADGroupMember -Recursive or a token-based check to catch indirect members.

Auditing Service Accounts and Their Real Rights

Ask Windows which account each service actually runs as, rather than trusting the documentation: Get-CimInstance Win32_Service | Select Name,StartName,StartMode,State | Where-Object {$_.StartName -notmatch 'LocalSystem|NT AUTHORITY'}. Any service running as a named user account is a candidate for review, and any service running as LocalSystem or NT AUTHORITY\NetworkService is by definition more privileged than most application code needs.

For each named service account, determine whether it has interactive logon rights, which no service needs: whoami /priv /user run in that account’s context, or inspect secedit /export /cfg C:\Ops\secpol.inf and read the SeInteractiveLogonRight and SeRemoteInteractiveLogonRight entries. A service account that can log on over RDP is a service account that can be used for lateral movement. The stronger model is a Group Managed Service Account (gMSA), which has a 240-character machine-managed password, no interactive logon by design, and no password to rotate manually.

Finding Stale and Duplicate Accounts

Unused accounts are the quiet half of the problem. Local accounts: Get-LocalUser | Select Name,Enabled,LastLogon,PasswordLastSet. Anything with LastLogon of $null that is enabled deserves a question, and a local account whose password was last set three years ago while being a member of Administrators deserves deletion. Remember that LastLogon on the local provider is not replicated and can lag; on domains, use Get-ADUser -Filter * -Properties LastLogonDate,PasswordLastSet and treat 90 days of inactivity as the review threshold.

Check for duplicated identity next: the same human with a domain account, a local account, and a SQL login, each with different passwords and different privilege. Consolidate to one identity per person per system. Also enumerate accounts with passwords that never expire — Get-LocalUser | Where-Object {$_.PasswordExpires -eq $null} — since non-expiring passwords on privileged accounts are how a forgotten credential from 2019 becomes a 2026 incident.

Designing Roles Instead of Granting People

Stop adding users to groups and start defining role groups with a stated purpose. A workable small-server scheme: VPS-Admins (full local admin, 2-3 people maximum, MFA on the RDP path), VPS-Operators (member of Backup Operators and Event Log Readers, no admin), VPS-WebDeploy (write access to C:\inetpub only, via ACL, not group membership in Administrators), and VPS-ReadOnly (Performance Monitor Users and Event Log Readers). Each group gets a one-line description explaining what it is for and who approves membership.

For the file-system part, use explicit ACLs rather than group sprawl: icacls C:\inetpub\wwwroot /grant "VPS-WebDeploy:(OI)(CI)M" /T and confirm inheritance with icacls C:\inetpub\wwwroot. For service-level delegation, prefer per-service ACLs on the service registry key and the program directory over membership in a privileged group. If an application genuinely needs to write to its own directory and read a config file, grant exactly that and nothing above it.

Verifying That Least Privilege Actually Holds

Configuration is a claim; testing is evidence. For each non-admin role, log on over RDP and confirm that privileged actions fail as expected: opening services.msc and attempting to stop a service, running Get-LocalGroupMember Administrators, and trying to write to C:\Windows\System32. Document the expected failures so that a future “it works for me” claim can be checked against the list.

Then audit the rights themselves rather than the intent. secedit /export /cfg C:\Ops\secpol.inf followed by Select-String -Path C:\Ops\secpol.inf -Pattern "Se" lists every user right assignment. Pay attention to SeDebugPrivilege, SeBackupPrivilege, SeRestorePrivilege, and SeTakeOwnershipPrivilege — each is a documented path to SYSTEM and none should be held by ordinary administrators, let alone operators. Compare against a saved baseline from the previous quarter.

Event IDs That Reveal Privilege Creep

Group membership changes are audited only if you enable the audit policy first. Turn on Audit Account Management under Computer Configuration > Windows Settings > Security Settings > Advanced Audit Policy Configuration > Audit Policies > Account Management, or from the command line: auditpol /set /subcategory:"Security Group Management" /success:enable /failure:enable. Otherwise your change history starts whenever you happen to notice.

Once enabled, event ID 4728 records a member added to a global group, 4732 a member added to a local group, and 4756 a member added to a universal group. Membership removals are 4729, 4733, and 4757. Alert on 4732 for the Administrators group specifically: Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4732; StartTime=(Get-Date).AddDays(-7)}, then read the TargetUserName and MemberName fields. Every unexpected entry is either a process failure or a compromise.

Making the Audit a Standing Habit

Wrap the queries above into one read-only script that emits CSV: privileged groups, named service accounts, stale local users, and the user-rights export. Run it monthly, store the output with the date in the filename, and diff consecutive runs. The diff is the deliverable — it shows exactly what changed and gives you a defensible record of who had what privilege on any given date.

Review the file-system and remote-access assumptions in your Windows VPS hosting arrangement at the same time, since an exposed RDP port with a weak operator password defeats every group design above. Least privilege is a loop: define the role, verify it fails safe, watch for drift, and shrink it again next month.

Leave a Comment