From: Solar Designer <solar@openwall.com>
To: Salvatore Mesoraca <s.mesoraca16@gmail.com>
Cc: Kernel Hardening <kernel-hardening@lists.openwall.com>
Subject: [kernel-hardening] Re: [PATCH v3 0/2] Restrict dangerous open in sticky directories
Date: Mon, 27 Nov 2017 02:14:41 +0100 [thread overview]
Message-ID: <20171127011441.GA15063@openwall.com> (raw)
In-Reply-To: <1511337706-8297-1-git-send-email-s.mesoraca16@gmail.com>
Replying to kernel-hardening only, so we can consider the below thoughts
in a smaller group before bothering LKML:
On Wed, Nov 22, 2017 at 09:01:44AM +0100, Salvatore Mesoraca wrote:
> This patch-set introduces two separate features aimed at restricting
> dangerous open in world or group writable sticky directories.
> The purpose is to prevent exploitable bugs in user-space programs
> that don't access sticky directories in the proper way.
> The first patch prevents the O_CREAT open of FIFOs and regular files
> in world or group writable sticky directories, if they already exists
> and are owned by someone else.
> The second patch prevents O_CREAT open in world or group writable
> sticky when the O_EXCL flag is not set, even if the file doesn't
> exist yet.
When I suggested the O_CREAT-without-O_EXCL checks, I didn't mean you'd
try to introduce them at the same time with the restrictions on FIFOs
and regular files. I think that bundling these together might be a
recipe for never getting any of them in, or for getting in the latter
with unnecessarily limited scope. I think we need an optional policy
against O_CREAT-without-O_EXCL not only for sticky directories, but also
for other directories writable by other than the current fsuid - there
may be several levels or individual flags here.
So maybe unbundle these or at least avoid forever limiting them to
sticky directories (don't include "sticky" in the sysctl name).
Meanwhile, here's a scenario where I think the FIFO restrictions are
most obviously still worthwhile: attacks on system bootup scripts, where
the attacker would plant a FIFO on a persistent /tmp or the like and the
system would access it on next bootup. The attacker's exploit program
would not yet be running during the bootup, so it wouldn't be able to
even try winning a race, but a FIFO would be able to keep the vulnerable
service (or its startup script, etc.) stuck until the attacker has
access again. On the other hand, /tmp is commonly on tmpfs these days,
whereas some other shared writable directories (not necessarily world
writable and not necessarily sticky) are persistent (mail and cron job
spools, preformatted man page cache, etc.) So maybe this, too, is a
reason to eventually extend these protections beyond sticky directories
(of course, only as an option). We shouldn't using naming that would be
against such extension, or/and we shouldn't think of the
O_CREAT-without-O_EXCL checks as permanently only for extra detection
and reporting - they may also prevent more attacks if we eventually
extend them to non-sticky, but not (yet) similarly extent the file type
specific protections.
Alexander
next prev parent reply other threads:[~2017-11-27 1:14 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-22 8:01 [kernel-hardening] [PATCH v3 0/2] Restrict dangerous open in sticky directories Salvatore Mesoraca
2017-11-22 8:01 ` Salvatore Mesoraca
2017-11-22 8:01 ` [kernel-hardening] [PATCH v3 1/2] Protected FIFOs and regular files Salvatore Mesoraca
2017-11-22 8:01 ` Salvatore Mesoraca
2017-11-23 22:43 ` [kernel-hardening] " Tobin C. Harding
2017-11-24 8:24 ` Salvatore Mesoraca
2017-11-22 8:01 ` [kernel-hardening] [PATCH v3 2/2] Protected O_CREAT open in sticky directories Salvatore Mesoraca
2017-11-22 8:01 ` Salvatore Mesoraca
2017-11-22 12:03 ` [kernel-hardening] " Pavel Vasilyev
2017-11-24 8:28 ` Salvatore Mesoraca
2017-11-22 13:22 ` [kernel-hardening] " Matthew Wilcox
2017-11-22 13:22 ` Matthew Wilcox
2017-11-22 14:38 ` [kernel-hardening] " Pavel Vasilyev
2017-11-24 8:29 ` Salvatore Mesoraca
2017-11-24 8:29 ` Salvatore Mesoraca
2017-11-22 16:51 ` [kernel-hardening] " Alan Cox
2017-11-22 16:51 ` Alan Cox
2017-11-24 8:31 ` [kernel-hardening] " Salvatore Mesoraca
2017-11-24 8:31 ` Salvatore Mesoraca
2017-11-24 10:53 ` [kernel-hardening] " David Laight
2017-11-24 10:53 ` David Laight
2017-11-24 11:43 ` [kernel-hardening] " Salvatore Mesoraca
2017-11-24 11:43 ` Salvatore Mesoraca
2017-11-24 11:53 ` [kernel-hardening] " David Laight
2017-11-24 11:53 ` David Laight
2017-11-26 11:29 ` [kernel-hardening] " Salvatore Mesoraca
2017-11-26 11:29 ` Salvatore Mesoraca
2017-11-27 0:26 ` [kernel-hardening] " Solar Designer
2017-11-27 0:26 ` Solar Designer
2017-11-30 14:39 ` [kernel-hardening] " Salvatore Mesoraca
2017-11-30 14:39 ` Salvatore Mesoraca
2017-11-30 14:57 ` [kernel-hardening] " Ian Campbell
2017-11-30 16:30 ` [kernel-hardening] " Solar Designer
2017-12-05 10:21 ` Salvatore Mesoraca
2017-12-07 21:47 ` Solar Designer
2017-12-11 12:08 ` Salvatore Mesoraca
2017-11-23 22:57 ` Tobin C. Harding
2017-11-24 8:34 ` Salvatore Mesoraca
2017-11-30 16:53 ` [kernel-hardening] " David Laight
2017-11-30 16:53 ` David Laight
2017-11-30 17:51 ` [kernel-hardening] " Solar Designer
2017-11-30 17:51 ` Solar Designer
2017-12-01 9:46 ` [kernel-hardening] " David Laight
2017-12-01 9:46 ` David Laight
2017-12-01 15:52 ` [kernel-hardening] " Alan Cox
2017-12-01 15:52 ` Alan Cox
2017-11-27 1:14 ` Solar Designer [this message]
2017-11-27 13:18 ` [kernel-hardening] Re: [PATCH v3 0/2] Restrict dangerous " Solar Designer
2017-11-30 14:38 ` Salvatore Mesoraca
2017-11-30 14:37 ` Salvatore Mesoraca
2017-11-30 19:05 ` Solar Designer
2017-11-30 19:14 ` Solar Designer
2017-12-05 10:13 ` Salvatore Mesoraca
2017-12-07 22:23 ` Solar Designer
2017-12-08 12:17 ` Solar Designer
2017-12-11 12:07 ` Salvatore Mesoraca
2017-12-11 15:33 ` Solar Designer
2017-12-12 18:00 ` Salvatore Mesoraca
2017-12-11 16:07 ` Solar Designer
2017-12-12 18:01 ` Salvatore Mesoraca
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=20171127011441.GA15063@openwall.com \
--to=solar@openwall.com \
--cc=kernel-hardening@lists.openwall.com \
--cc=s.mesoraca16@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.