mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: "Sören Tempel" <soeren@soeren-tempel.net>
Cc: musl@lists.openwall.com
Subject: Re: [musl] tzset() cannot handle arbitrary inputs
Date: Sun, 5 Sep 2021 19:11:35 -0400	[thread overview]
Message-ID: <20210905231135.GG13220@brightrain.aerifal.cx> (raw)
In-Reply-To: <38ZW90QHEA9XD.3GB2I1P1ZLKDB@8pit.net>

On Sun, Sep 05, 2021 at 11:26:08PM +0200, Sören Tempel wrote:
> Markus Wichmann <nullplan@gmx.net> wrote:
> > Hi all,
> 
> Hi,
> 
> > The user setting TZ is also the one getting the crashes. The
> > assumption is less that the input is always valid, but more that if it
> > is invalid, the user will only be hacking themselves.
> 
> This is only true under the assumption that $TZ itself is never set to a
> value derived from an untrusted source. See the aforementioned calcurse
> code for example where this assumption does not hold. If you search
> GitHub or use codesearch.debian.net you will find plenty additional
> examples where people "abuse" $TZ to query information about zonefiles
> by name. Please also note that these spatial memory safety violations
> are UB and thus might or might not lead to a crash.

There are all sorts of reasons this is a really bad idea, especially
if no filtering on the accepted names is performed. For instance, TZ
strings taken from malicious data files could cause device files with
side effects to be opened (including acquisition of a controlling
tty), or coule potentially leak private data. If applications are
doing this, they really should be ensuring that the string fits a
reasonably "safe" form -- for example, not starting with ./ or / and
not containing .. components, or even more restrictive like just
/[[:alnum:]]+(/[[:alnum:]]+)?/

I think we could and should do some basic things on the musl side to
ensure at least memory safety (bounding all accesses within the mapped
region) but as long as we're using mmap on systems that lack MAP_COPY,
that's about the limit of what can be done. And I want to approach
this topic with some care not to give the impression that, after
changes are made, it will be "safe" to use untrusted zone files.

Rich

      reply	other threads:[~2021-09-05 23:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-05 13:36 Sören Tempel
2021-09-05 17:39 ` Markus Wichmann
2021-09-05 21:26   ` Sören Tempel
2021-09-05 23:11     ` Rich Felker [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=20210905231135.GG13220@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=soeren@soeren-tempel.net \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).