nix.module: TCP mode cannot work because of the network sandboxing #60

Open
opened 2026-10-06 13:54:47 +00:00 by ffrauenberger · 0 comments
Owner

Severity: medium (the module's TCP option cannot work)

Where

  • module.nix:94-101, :191-199, :209-216, :267-277

Problem

useSocket defaults to cfg.production, so a non-production deployment binds TCP (--host localhost --port 8501) by default. The systemd unit, however, always sets:

PrivateNetwork = true;              # own network namespace: only an isolated loopback
RestrictAddressFamilies = "AF_UNIX"; # AF_INET/AF_INET6 sockets are forbidden
  • RestrictAddressFamilies = "AF_UNIX" makes socket(AF_INET, …) fail, so uvicorn cannot bind and the service crash-loops.
  • Even if it could bind, PrivateNetwork puts the listener in a private namespace that the nginx upstream localhost:8501 cannot reach.

Steps to reproduce

  1. Enable the ProcessIntel NixOS module with production = false (and useSocket left at its default)
  2. Rebuild the system and check systemctl status / the journal of the service

Expected behavior

The service listens on localhost:8501 and is reachable through nginx.

Actual behavior

The service cannot bind its TCP socket and crash-loops.

Fix

Apply PrivateNetwork / RestrictAddressFamilies = "AF_UNIX" only when useSocket is true (lib.mkIf cfg.useSocket). In TCP mode allow AF_INET AF_INET6 AF_UNIX and drop PrivateNetwork.


from issues/DEP-001-nixos-module-tcp-mode-cannot-work.md (code analysis of commit 6bcc646, 2026-10-03)

**Severity:** medium (the module's TCP option cannot work) ## Where - `module.nix:94-101`, `:191-199`, `:209-216`, `:267-277` ## Problem `useSocket` defaults to `cfg.production`, so a non-production deployment binds TCP (`--host localhost --port 8501`) by default. The systemd unit, however, always sets: ```nix PrivateNetwork = true; # own network namespace: only an isolated loopback RestrictAddressFamilies = "AF_UNIX"; # AF_INET/AF_INET6 sockets are forbidden ``` - `RestrictAddressFamilies = "AF_UNIX"` makes `socket(AF_INET, …)` fail, so uvicorn cannot bind and the service crash-loops. - Even if it could bind, `PrivateNetwork` puts the listener in a private namespace that the nginx upstream `localhost:8501` cannot reach. ### Steps to reproduce 1. Enable the ProcessIntel NixOS module with `production = false` (and `useSocket` left at its default) 2. Rebuild the system and check `systemctl status` / the journal of the service ### Expected behavior The service listens on `localhost:8501` and is reachable through nginx. ### Actual behavior The service cannot bind its TCP socket and crash-loops. ## Fix Apply `PrivateNetwork` / `RestrictAddressFamilies = "AF_UNIX"` only when `useSocket` is true (`lib.mkIf cfg.useSocket`). In TCP mode allow `AF_INET AF_INET6 AF_UNIX` and drop `PrivateNetwork`. --- from `issues/DEP-001-nixos-module-tcp-mode-cannot-work.md` (code analysis of commit 6bcc646, 2026-10-03)
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ffrauenberger/ProcessIntel#60
No description provided.