Development discussion of WireGuard
 help / color / mirror / Atom feed
From: Florian Bausch <fbausch@ernw.de>
To: wireguard@lists.zx2c4.com
Subject: Re: [PATCH] wg-tools: Fix too strict file permissions on resolv.conf
Date: Wed, 15 Feb 2023 13:55:47 +0100	[thread overview]
Message-ID: <9191bd2e-5d28-fee3-7fab-246050f20b56@ernw.de> (raw)
In-Reply-To: <5dd37668-9c40-38a9-4655-199d0f11b4d9@ernw.de>

(This time without signature)
Hi,

I hardened my system by setting a strict umask of 077 in
/etc/login.defs. However, this breaks DNS as soon as wg-quick is used to
bring up a WireGuard tunnel. This is, because the strict umask value
will be applied to /etc/resolv.conf (at least if the DNS hatchet is
used) and therefore, unprivileged processes are not able to read
/etc/resolv.conf.

While the behavior can be worked around by setting umask in other
places, the fix below would prevent this behavior to occur. The umask
022 is applied before creating the new /etc/resolv.conf in the DNS hatchet.

Kind regards

Signed-off-by: Florian Bausch <fbausch@ernw.de>
---
  contrib/dns-hatchet/hatchet.bash | 1 +
  1 file changed, 1 insertion(+)

diff --git a/contrib/dns-hatchet/hatchet.bash 
b/contrib/dns-hatchet/hatchet.bash
index bc4d090..807a14a 100644
--- a/contrib/dns-hatchet/hatchet.bash
+++ b/contrib/dns-hatchet/hatchet.bash
@@ -20,6 +20,7 @@ set_dns() {
          [[ ${#DNS_SEARCH[@]} -eq 0 ]] || printf 'search %s\n' 
"${DNS_SEARCH[*]}"
          } | unshare -m --propagation shared bash -c "$(cat <<-_EOF
              set -e
+            umask 022
              context="\$(stat -c %C /etc/resolv.conf 2>/dev/null)" || 
unset context
              mount --make-private /dev/shm
              mount -t tmpfs none /dev/shm
-- 
2.39.1

      reply	other threads:[~2023-02-15 12:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-05 19:19 Florian Bausch
2023-02-07 22:54 ` Jason A. Donenfeld
2023-02-15 12:54   ` Florian Bausch
2023-02-15 12:55     ` Florian Bausch [this message]

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=9191bd2e-5d28-fee3-7fab-246050f20b56@ernw.de \
    --to=fbausch@ernw.de \
    --cc=wireguard@lists.zx2c4.com \
    /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).