Skip to content

[Breaking change]: Unix Named Mutex default scope and storage location changes #56396

Closed

Description

@jkoritzinsky

Description

In the following .NET versions, we have made the following changes to Named Mutex support in Unix.

The default scope for a named mutex on Unix is now user-scoped, instead of globally-scoped. Additionally, user-scoped mutexes now live in a system-defined user-only directory or a subdirectory of such a directory.

.NET Runtime 11.0-rc2
.NET Runtime 10.0.13
.NET Runtime 9.0.21
.NET Runtime 8.0.32

Version

Other (please put exact version in description textbox)

Previous behavior

Named mutexes on Unix platforms were globally-scoped across all users by default. User-scoped named mutexes were only definable with the System.Threading.Mutex constructors that take a System.Threading.NamedWaitHandleOptions parameter, available on .NET 10 or newer.

Additionally, user-scoped named mutexes are backed by files in a directory nested under /tmp/.

New behavior

Named mutexes on Unix platforms now default to user-scoped instead of globally-scoped. Globally scoped mutexes can be explicitly opted-into with the System.Threading.Mutex constructors that take a System.Threading.NamedWaitHandleOptions parameter on .NET 10 or newer, or by setting the System.Threading.Mutex.UnsafeDefaultMutexScopeGlobal runtime configuration option to true in your runtimeconfig.json for all affected platforms.

User-scoped mutexes are now stored under one of the following directories:

  • $TMPDIR when on a platform that defines $TMPDIR as a user-scoped directory.
  • $XDG_RUNTIME_DIR when on a platform that conforms to the XDG Base Directory specification.
  • $HOME/.dotnet/ otherwise.

Type of breaking change

  • Binary incompatible: Existing binaries might encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
  • Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code might require source changes to compile successfully.
  • Behavioral change: Existing binaries might behave differently at run time.

Reason for change

Due to security reasons, the default behavior needed to be adjusted to ensure that user-scoped mutexes are stored in user-owned locations. Additionally, for security reasons, the default was changed to ensure that usages across all versions of .NET default to a secure feature set by default.

Recommended action

If your named mutexes do not require cross-user access and your application can access the specified system directories for your platform, no changes are required.

If your named mutexes require cross-user access, you can opt into the unsafe global mutex behavior using the System.Threading.Mutex constructors that take a System.Threading.NamedWaitHandleOptions parameter on .NET 10 or newer, or by setting the System.Threading.Mutex.UnsafeDefaultMutexScopeGlobal runtime configuration option to true in your runtimeconfig.json for all affected platforms. Note that, per https://learn.microsoft.com/en-us/dotnet/api/system.threading.mutex?view=net-10.0#remarks, globally scoped mutexes are considered unsafe when used with multiple untrusted users on the same machine.

Feature area

Core .NET libraries

Affected APIs

All overloads of constructors for System.Threading.Mutex that take a string parameter.


Associated WorkItem - 638885

Activity

  1. added
    breaking-change
    on Oct 14, 2026
  2. added a commit that references this issue on Oct 14, 2026
  3. added
    🗺️ reQUEST
    and removed
    ⌚ Not Triaged
    on Oct 14, 2026
  4. added
    🗺️ mapQUEST
    on Oct 14, 2026
  5. moved this from 🔖 Ready to 🏗 In progress in dotnet/docs October 2026 Sprint projecton Oct 14, 2026
  6. removed
    🗺️ mapQUEST
    on Oct 14, 2026
  7. 7 remaining items

  8. added 2 commits that reference this issue on Oct 14, 2026
  9. added a commit that references this issue on Oct 14, 2026
  10. added
    🗺️ mapQUEST
    on Oct 15, 2026
  11. moved this from 🏗 In progress to 👀 In review in dotnet/docs October 2026 Sprint projecton Oct 15, 2026
  12. removed
    🗺️ mapQUEST
    on Oct 15, 2026
  13. added
    📌 seQUESTered
    and removed
    🗺️ reQUEST
    on Oct 15, 2026
  14. added 3 commits that reference this issue on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

📌 seQUESTeredbreaking-change

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions