Repository navigation
Windows: elevated session creates .mcp-writer.lock that non-elevated sessions cannot open (open_lock, os_error=5) #5255
Description
Describe the bug
On Windows, if an elevated (Run as administrator) session is the first to create %USERPROFILE%\.copilot\.mcp-writer.lock and .mcp-writer.binding, all later non-elevated sessions fail to start MCP servers:
Failed to start MCP Servers: Error: Shared writer storage I/O failed. (operation=open_lock, os_error=5)
Root cause: The two files are created with a protected DACL:
.mcp-writer.lock OWNER RIGHTS:(IO)(F)
NT AUTHORITY\SYSTEM:(F)
BUILTIN\Administrators:(F)
Two problems combine:
- The
OWNER RIGHTSACE has the inherit-only (IO) flag, so it does not apply to the file itself. Only SYSTEM and Administrators get access. - When an admin account creates a file from an elevated process, Windows sets the default owner to
BUILTIN\Administrators, not the user.
A non-elevated token has BUILTIN\Administrators as deny-only, so opening the file returns ERROR_ACCESS_DENIED (5). Changing only the owner to the user does not fix this, because of the IO flag. Other files in ~\.copilot inherit the user ACE from the parent and are not affected.
Affected version
GitHub Copilot CLI 1.0.103
Steps to reproduce the behavior
- Configure at least one MCP server.
- Delete
%USERPROFILE%\.copilot\.mcp-writer.lockand%USERPROFILE%\.copilot\.mcp-writer.binding. - Start
copilotin an elevated terminal, then exit. - Start
copilotin a non-elevated terminal. - See
Shared writer storage I/O failed. (operation=open_lock, os_error=5).
Expected behavior
The same user can open the files from both elevated and non-elevated sessions. Possible fixes:
- Grant the current user SID explicitly.
- Apply
OWNER RIGHTSwithout the inherit-only flag, and set the owner to the user SID. - Do not use a protected DACL. Inherit the ACL from
~\.copilot.
Additional context
- OS: Windows 11 Pro, local admin account with UAC enabled
- CPU architecture: x86_64 (AMD64)
- Terminal: Windows Terminal
- Shell: PowerShell 7.6
Log excerpts:
[ERROR] [rust:copilot_runtime::shared_api::event_log] Failed to retry MCP servers after OAuth listener registration: {"error":"Shared writer storage I/O failed. (operation=open_lock, os_error=5)"}
[ERROR] Failed to start MCP Servers: Error: Shared writer storage I/O failed. (operation=open_lock, os_error=5)
[ERROR] [rust:mcp_engine::session_lifecycle] Failed to initialize MCP host: Shared writer storage I/O failed. (operation=open_lock, os_error=5)
[ERROR] [rust:copilot_runtime::shared_api::lifecycle] Scheduled queue processing failed after retry; queue drain abandoned {"error":"Message(\"Shared writer storage I/O failed. (operation=open_lock, os_error=5)\")"}
Workaround (from an elevated shell):
icacls %USERPROFILE%\.copilot\.mcp-writer.lock /grant "%USERNAME%:F"
icacls %USERPROFILE%\.copilot\.mcp-writer.binding /grant "%USERNAME%:F"
Related, but a different cause: #4998 (macOS stale .mcp-writer.binding).
Activity