Least Privilege Access for AI Agents on Windows
In this article
This guide shows you how to give AI agents—like automation scripts, local LLM tools, or coding assistants—only the file and data access they absolutely need on Windows. By applying the principle of least privilege, you reduce the damage a compromised or buggy agent can do, protect sensitive data, and keep your system stable. You'll set up a dedicated user account, create a restricted folder structure, and configure Windows permissions so the agent can read and write only where it must.
What You'll Need
- Windows 10 or 11 with an administrator account
- The AI agent software installed (e.g., a Python script, an LLM tool, or a desktop assistant)
- Basic comfort with Windows Settings and File Explorer
Step-by-Step
- Create a dedicated user account for the AI agent. Go to Settings > Accounts > Family & other users (Windows 10) or Accounts > Other users (Windows 11). Click Add account and choose I don't have this person's sign-in information, then Add a user without a Microsoft account. Set a username like
AI_Agentand a strong password. Make it a Standard user, not an administrator. - Create a dedicated folder for the agent's work. In File Explorer, create a folder like
C:\AI_Workspace. Inside, create subfolders:Input(files the agent reads),Output(files it writes), andTemp(scratch space). - Set permissions on the workspace. Right-click the
AI_Workspacefolder, select Properties > Security. Click Edit, then Add theAI_Agentuser. Grant Modify permission (which includes read, write, and delete) for this folder and its subfolders. Remove any permissions for other non-admin users if you want to isolate it. - Restrict the agent's access to the rest of the system. By default, the new user can still read many system files and other users' public folders. To limit this, you can:
- Remove the
AI_Agentuser from the Users group (which has broad read access) and add it only to a custom group you create. This is advanced but effective. - Alternatively, use Controlled Folder Access (see Tips) to block the agent from writing outside its workspace.
- Remove the
- Run the AI agent under that account. When you launch the agent, use Run as different user (hold Shift and right-click the executable) and enter the
AI_Agentcredentials. For automated services, set the service's Log on as to this account in Services.msc. - Configure the agent to use only the workspace. In the agent's configuration, set its working directory to
C:\AI_Workspace. Ensure it reads input fromInputand writes output toOutput. Avoid giving it paths outside this folder. - Test the restrictions. Log in as the
AI_Agentaccount (or run a command as that user) and try to access a file outside the workspace, likeC:\Windows\System32\drivers\etc\hosts. It should be denied. Also try writing toC:\—that should fail. - Use Windows Defender Firewall to block network access (optional but recommended). If the agent does not need internet, create an outbound rule to block it. In Windows Defender Firewall with Advanced Security, add a new outbound rule for the agent's executable and set it to Block.
- Set up auditing (optional). Enable Audit object access in Local Security Policy and apply auditing to the workspace folder so you can see who accessed what in the event log.
Common Mistakes
- Giving the agent administrator rights. This defeats the purpose. Always run as a standard user.
- Using your own user account. The agent would have all your permissions, including access to your documents and emails.
- Forgetting to restrict network access. An agent with internet can exfiltrate data even if it can't write outside its folder.
- Placing the workspace on a shared drive. If other users have write access, they could tamper with the agent's files.
- Ignoring the Temp folder. Some agents write to
%TEMP%by default. Redirect it to the workspace'sTempfolder to avoid leaving traces elsewhere.
Tips
- Use Windows Sandbox for testing. Before deploying an untrusted agent, run it in a disposable sandbox to see what it tries to access.
- Leverage Controlled Folder Access. In Windows Security > Virus & threat protection > Ransomware protection, add
C:\AI_Workspaceto the protected folders list, and then block the agent from writing to any other folder by adding its executable to the blocked apps list. - Use Group Policy for tighter control. If you're on Windows Pro or Enterprise, use gpedit.msc to restrict the agent's user account further, e.g., disable command prompt or limit logon hours.
- Keep the agent's software updated. Outdated libraries can have vulnerabilities that bypass file permissions.
- Document the permissions you set. This helps when you need to troubleshoot or replicate the setup.
Troubleshooting
- The agent cannot write to the workspace. Check that the
AI_Agentuser has Modify permission on the folder. Also, ensure the folder is not read-only (sometimes inherited from a parent). - The agent can still read files outside the workspace. This is often because the user is in the Users group. Remove it from that group (via lusrmgr.msc) and add it to a custom group with only the needed permissions.
- Run as different user does not work. Make sure the account is not disabled and the password is correct. Also, if the agent is a service, use Services.msc to set the logon account.
- The agent fails to start. If it needs specific system libraries, it may lack read access to them. Grant Read & execute on the specific folders (e.g.,
C:\Windows\System32) but avoid full control. - Windows Security blocks the agent. The Controlled Folder Access may be blocking writes to the workspace because the agent is not recognized. Add the agent's executable to the allowed apps list.
Frequently Asked Questions
Can I use an existing standard user account instead of creating a new one?
Yes, but a dedicated account is cleaner because you can isolate the agent's profile and settings without affecting other users.
Do I need to create a new folder, or can I use an existing one?
You can use an existing folder, but ensure it doesn't contain sensitive data and that you set permissions correctly. A fresh folder is easier to manage.
How do I run the agent as a different user from a script?
Use the runas command in a command prompt: runas /user:AI_Agent "path\to\agent.exe". You'll be prompted for the password.
Will the agent be able to access the internet?
Yes, unless you block it with the firewall. By default, the new user has full network access.
Can I use this method for AI agents that run in a container like Docker?
Yes, but you'd also need to configure Docker's volume mounts to map only the workspace folder into the container. The principle is the same.
What if the agent needs to read files from a specific location like a USB drive?
Grant the agent's user account read permission on that specific drive or folder, but avoid giving write access unless necessary.