Github messages for voidlinux
 help / color / mirror / Atom feed
From: chexum <chexum@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: caddy 2.6.4 package setcaps directly
Date: Sun, 18 Jun 2023 07:39:49 +0200	[thread overview]
Message-ID: <20230618053949.hUSC_-6DST7mfBqnIRLHtQvWz0lAGXgG07sZ_DUdgLg@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-44500@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 2821 bytes --]

New comment by chexum on void-packages repository

https://github.com/void-linux/void-packages/issues/44500#issuecomment-1595969943

Comment:
Not running caddy as root is good.  The suggested changes to use setpriv makes it work in an equivalent way.  I am using caddy, and I am running with those changes. (Might need to change runtime pkg dependencies, as chpst does not have this, well, capability)

If Alpine distributes a setcap binary, then they too have an issue.  Capabilities are not meant to be given to binaries that don't verify their uses. They are a responsibility of things split from the all-powerful root permissions.  The binary installed here allows everyone to bind to nonprivileged ports, which normally is restricted to root. With this binary, it's possible to do that by any user.  This might be a CVE level issue.  It's not with caddy, caddy does not expect users to have this capability - it's only making single user development easier, but bad on a generic Linux/Unix system in general.

This is what Apache has to say about the scheme if used for development:
"with this setup, any nonprivileged user can now run Apache on privileged ports. So, be very careful about what you do. Additionally, you can further restrict execution of the httpd binary, either using standard credentials (chmod, chown et al) or, even better, ACLs;" (https://cwiki.apache.org/confluence/display/httpd/NonRootPortBinding)

Allow me to describe a full demonstration of what the problem is:

(void with no caddy installed, just to not disturb the configuration):
```
xbps-install -Su caddy
umask 022
mkdir /tmp/q1
echo good >/tmp/q1/myfile
sudo vi /etc/caddy/Caddyfile
contents:
http://localhost:80, http://127.0.0.1:80 {
  root * /tmp/q1
  file_server browse
}
ln -s /etc/sv/caddy /var/service
```

expected result:
`curl -v http://localhost/myfile` should work (as any user), no issue as web service was explicitly configured by root

after stopping it with `sv stop caddy` (again, not necessary, only to make the following configuration simpler without documenting the full way to take over a service port in case the caddy process is still running.)

as a nonroot user:
```
umask 022
mkdir /tmp/q2
echo badport >/tmp/q2/myfile
vi $HOME/Caddyfile
contents:
http://127.0.0.1:334 {
  root * /tmp/q2
  file_server browse
}
caddy run --config $HOME/Caddyfile
```
Now, in another window, `curl -v http://127.0.0.1:334/myfile` produces the file contents on a privileged port, while the user `caddy` is run by the user.  Only root should be able to start caddy this way, no exceptions.  No addition verification of ports is done.  This could take over ssh or smtp ports (as an example) if they are not in use, or provide an opportunity to take them over during service restarts.

  parent reply	other threads:[~2023-06-18  5:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-17 20:36 [ISSUE] " chexum
2023-06-17 22:35 ` paper42
2023-06-18  5:39 ` chexum [this message]
2023-06-18  5:52 ` chexum
2023-06-21 21:16 ` cattyhouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230618053949.hUSC_-6DST7mfBqnIRLHtQvWz0lAGXgG07sZ_DUdgLg@z \
    --to=chexum@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).