Skip to content

Windows: elevated session creates .mcp-writer.lock that non-elevated sessions cannot open (open_lock, os_error=5) #5255

Open

Description

@will-j-wright

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:

  1. The OWNER RIGHTS ACE has the inherit-only (IO) flag, so it does not apply to the file itself. Only SYSTEM and Administrators get access.
  2. 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

  1. Configure at least one MCP server.
  2. Delete %USERPROFILE%\.copilot\.mcp-writer.lock and %USERPROFILE%\.copilot\.mcp-writer.binding.
  3. Start copilot in an elevated terminal, then exit.
  4. Start copilot in a non-elevated terminal.
  5. 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 RIGHTS without 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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:mcpMCP server configuration, discovery, connectivity, OAuth, policy, and registryarea:platform-windowsWindows-specific: PowerShell, cmd, Git Bash, WSL, Windows Terminal

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions