sandlock
sandlock copied to clipboard
network: on-behalf named unix connect reports the supervisor as SO_PEERCRED peer
In non-chroot mode with the unix fs gate on, `connect_named_unix_on_behalf` (network/unix.rs) connects from the supervisor, so the peer's `SO_PEERCRED`/`SO_PEERPIDFD` name the supervisor, not the sandboxed caller. When sandlock is embedded as a library, that is the embedder's own pid, so a server that refuses confined clients by peer pid lets them through.
The result is also policy dependent: chroot mode or a policy without the gate returns `Continue` and the peer sees the real pid.
The kernel takes peer creds from the connecting task, so the identity cannot be kept on-behalf. At minimum, document that peers must treat the supervisor's pid as untrusted.