mono/mono · warning
attach: disabled listening on an IPC socket when running in
Error message
attach: disabled listening on an IPC socket when running in setuid mode.
What it means
During IPC setup for the attach/diagnostics transport, ipc_connect refuses to create or listen on a UNIX socket when the process is running setuid (getuid() != geteuid()). It prints the warning and returns immediately, disabling the IPC listener for security.
Source
Thrown at mono/metadata/attach.c:357
* Create a UNIX domain socket and bind it to a file in /tmp.
*
* SECURITY: This routine is _very_ security critical since we depend on the UNIX
* permissions system to prevent attackers from connecting to the socket.
*/
static void
ipc_connect (void)
{
struct sockaddr_un name;
int sock, res;
size_t size;
char *filename, *directory;
struct stat stat;
struct passwd pwbuf;
char buf [1024];
struct passwd *pw;
if (getuid () != geteuid ()) {
fprintf (stderr, "attach: disabled listening on an IPC socket when running in setuid mode.\n");
return;
}
/* Create the socket. */
sock = socket (PF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
perror ("attach: failed to create IPC socket");
return;
}
/*
* For security reasons, create a directory to hold the listening socket,
* since there is a race between bind () and chmod () below.
*/
/* FIXME: Use TMP ? */
pw = NULL;
#ifdef HAVE_GETPWUID_R
res = getpwuid_r (getuid (), &pwbuf, buf, sizeof (buf), &pw);View on GitHub (pinned to 0f53e9e151)
Solutions
- Run the process as a non-setuid binary if you need the attach/IPC transport.
- Drop privileges (seteuid(getuid())) before Mono starts the IPC layer, if your security model allows it.
- Accept that the attach mechanism is intentionally disabled in setuid mode and use other diagnostics channels (e.g. logging).
Defensive patterns
Strategy: validation
Validate before calling
// In your launcher, detect setuid and either drop privileges or warn the user that attach is disabled:
// if (getuid() != geteuid()) {
// g_warning ("attach IPC disabled in setuid mode; run non-setuid to enable");
// } Prevention
- Avoid setuid Mono binaries when the attach transport is required.
- Drop privileges before the runtime starts if your threat model permits.
When it happens
Trigger: Running a setuid-root (or any setuid) Mono process; getuid() != geteuid() at the time ipc_connect runs.
Common situations: Deploying Mono behind a setuid wrapper, running under sudo-as-setuid binaries, or hardening scripts that set the setuid bit on the mono executable.
Related errors
- attach: directory '%s' is not owned by the current user.
- attach: directory '%s' should have protection 0700.
- attach: getpwuid_r () failed.
- attach: path '%s' is not a directory.
- attach: failed to bind IPC socket '%s': %s
AI-assisted analysis of mono/mono@0f53e9e151 (2026-08-13).
Data as JSON: /api/errors/817023a02dfd3b25.
Report an issue: GitHub.