<div dir="ltr"><div dir="ltr">On Wed, Mar 4, 2020 at 11:09 PM Matt Zagrabelny <<a href="mailto:mzagrabe@d.umn.edu">mzagrabe@d.umn.edu</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hey Mantas,</div><div><br></div><div>Thanks for the reply.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 4, 2020 at 12:06 PM Mantas Mikulėnas <<a href="mailto:grawity@gmail.com" target="_blank">grawity@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Wed, Mar 4, 2020 at 7:26 PM Matt Zagrabelny <<a href="mailto:mzagrabe@d.umn.edu" target="_blank">mzagrabe@d.umn.edu</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Greetings,<div><br></div><div>Do folks use non-root users to own AF_INET sockets</div></div></blockquote><div><br></div><div>This bit *really* doesn't make sense.</div></div></div></blockquote><div><br></div><div>Sure. That is why I asked if it was even a sensible question.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div> You're not changing the socket ownership in your examples at all -- you're changing the *service's* user account.</div></div></div></blockquote><div><br></div><div>Agreed. I wasn't trying to imply that I was changing socket ownership. Agreed - I did mean to change the user that the service runs as.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div> Who owns the socket has nothing to do with who owns the service process. (And the socket is still owned by root, as the whole point of .socket units is that socket creation is handled by pid1.)</div></div></div></blockquote><div><br></div><div>Okay. I wasn't sure if pid1 (systemd) could create the AF_INET socket and have it owned by another user. Sort of like the AF_UNIX socket ownership:</div><div><br></div><div>       SocketUser=, SocketGroup=<br>           Takes a UNIX user/group name. When specified, all AF_UNIX sockets and FIFO nodes in the file system are owned by the specified user and<br>           group. If unset (the default), the nodes are owned by the root user/group (if run in system context) or the invoking user/group (if run in<br>           user context). If only a user is specified but no group, then the group is derived from the user's default group.<br></div><div> </div></div></div></blockquote><div><br></div><div>AF_UNIX sockets only have ownership because they exist as filesystem objects and also have file permissions – using standard `chmod` it is possible to restrict which users or groups can connect to the socket.</div><div><br></div><div>But none of that exists for AF_INET sockets (UID-based permissions can't really apply across the network), so inet sockets don't have any reason for the owner to be changeable either. Aside from iptables '-m owner' filtering, I don't think changing the socket's owner would affect anything at all.</div><div><br></div><div>Either way – whether the systemd-created socket is AF_UNIX or AF_INET, its ownership still has nothing to do with "root exposure". Even if you have an AF_UNIX socket with SocketUser=root, it doesn't grant the service any more privileges, and it doesn't make the service any more vulnerable.</div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Mantas Mikulėnas</div></div></div>