Comment on Is this mail something I should be concerned about?
sugar_in_your_tea@sh.itjust.works 1 week agoDon’t require elevated permissions. Either grant the user it runs as permission to that dir, or instruct it to use a different dir that it has access to. Services should have the least permissions possible.
dgdft@lemmy.world 1 week ago
That’s how it already works — Caddy doesn’t require elevated privileges in general. You can toss a binary + config + certs anywhere in the homedir and it’ll go fine if you bind to a non-privileged port.
But users want software to do stuff like help set up certs and serve on ports 80 & 443, so what better option is there than to limit scope of execution by doing pinhole actions with sudo?
sugar_in_your_tea@sh.itjust.works 1 week ago
For binding privileged ports like 80 and 443, use CAP_NET_BIND_SERVICE. For access to protected directories, adjust permissions.
At no point should sudo be necessary, that’s how you get security vulnerabilities.
dgdft@lemmy.world 1 week ago
What kind of vulnerabilities are you worried about from such a sudo call?
sugar_in_your_tea@sh.itjust.works 1 week ago
I’m much less worried about an attacker messing w/ my certs (that’s a pretty sophisticated attack) and more worried about privilege escalation where the attacker gets root access. Caddy is intended to be externally facing, so it’ll be getting the brunt of the attacks (like this one that attacks HTTP 1.1). If someone is able to find an exploit to allow remote code execution, being able to run commands with
sudo
is a pretty big deal.That’s a big part of why I run my services in containers, and also why I’m switching from Docker to Podman. Docker runs everything as root by default, and it’s a pain to run things as non-root. Podman runs everything as an underprivileged user by default, which forces the admin to configure it properly. If an attacker is able to break out of Docker, it’ll have root access to the system, whereas if an attacker breaks out of Podman, they’ll just have whatever that user’s permission is.
If I’m going to expose something to the internet, I want to make sure it’s properly configured to reduce the chances of getting a rootkit or something.