mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Mickaël Salaün" <mic@digikod.net>
To: Mimi Zohar <zohar@linux.vnet.ibm.com>,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	keescook@chromium.org, matt@nmatt.com
Cc: jason@perfinion.com, linux-security-module@vger.kernel.org,
	Daniel Micay <danielmicay@gmail.com>,
	kernel-hardening <kernel-hardening@lists.openwall.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1] shebang: restrict python interactive prompt/interpreter
Date: Tue, 13 Jun 2017 22:59:11 +0200	[thread overview]
Message-ID: <8a2300ef-1462-0e1f-2d6a-81e6020bc71f@digikod.net> (raw)
In-Reply-To: <1497234757.21594.280.camel@linux.vnet.ibm.com>


[-- Attachment #1.1: Type: text/plain, Size: 2997 bytes --]


On 12/06/2017 04:32, Mimi Zohar wrote:
> On Sun, 2017-06-11 at 13:44 +0200, Mickaël Salaün wrote:
>> On 10/06/2017 07:27, Tetsuo Handa wrote:
>>> Kees Cook wrote:
>>>> On Fri, Jun 9, 2017 at 10:23 AM, Matt Brown <matt@nmatt.com> wrote:
>>>>> what does everyone thing about a envp_blacklist option that is a list of
>>>>> environmental variables that will be stripped from exec calls. This can
>>>>> be done in the LSM hook bprm_check_security.
>>>>>
>>>>> Is there any reason on a hardened system why you would need the
>>>>> PYTHONINSPECT environmental variable?
>>>>
>>>> As part of shebang, it likely makes sense to whitelist (rather than
>>>> blacklist) the env of the restricted interpreters. Though this is
>>>> starting to get complex. :P
>>>
>>> Blacklisting environment variables is dangerous. I think that
>>> administrators can afford whitelisting environment variable names.
>>> I think that implementing whitelist of environment variable names
>>> as an independent LSM module would be fine.
>>>
>>> While it is true that things starts getting complex if we check environment
>>> variables, shebang will already become complex if it starts worrying about
>>> updating inode number list in order to close the race window between doing
>>> creat()+write()+close()+chmod()+rename() by the package manager and teaching
>>> the kernel the new inode number determined by creat(). We will need an
>>> interface for allowing the package manager to teach the kernel the new inode
>>> number and modification of the package manager, for the kernel side is doing
>>> inode number based blacklisting while user side can execute it before rename().
> 
> I don't think we're trying to protect against executing the
> interpreter prior to the rename.  Rename, itself, would trigger
> associating the interpreter name with an inode number.
> 
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>
>> Using filesystem xattr seems like a good idea for this kind of
>> exceptions and instead of a hardcoded interpreter path. Something like
>> "security.tpe.interpreter=1|2" (bitmask for interpreter-only and/or CLI)
>> and "security.tpe.environment=HOME,LOGNAME" would be quite flexible to
>> configure a security policy for some binaries. This could also be
>> protected by IMA/EVM, if needed.
> 
> Checking for the existence of an xattr without caching is relatively
> slow.  I'm not sure that we would want to go this route.
> 
>> This kind of xattr should be writable by the owner of the file. The TPE
>> LSM [1] could then take these xattr into account according to the TPE
>> policy.
> 
> Security xattrs are only writable by root.

This is currently the case but an exception for this kind of LSM could
be allowed, or another dedicated prefix could be used.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2017-06-13 21:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <201706100041.GFH78616.OFtOHFJSLQOMVF@I-love.SAKURA.ne.jp>
     [not found] ` <754b78d1-f7f9-58bd-bf74-fea9e105649a@nmatt.com>
     [not found]   ` <20170609164315.GA1141@meriadoc.perfinion.com>
     [not found]     ` <d84aaf19-307b-4b60-df74-4fb43a218c9c@nmatt.com>
     [not found]       ` <CAGXu5jJt5MRU3ZdKABEbLt4qe-cCLxEm5tMH9SdUh=rtdLUV1w@mail.gmail.com>
     [not found]         ` <201706101427.EEG90168.OtFFHSFMOVOJQL@I-love.SAKURA.ne.jp>
2017-06-11 11:44           ` Mickaël Salaün
2017-06-12  2:32             ` Mimi Zohar
2017-06-12 14:27               ` Mimi Zohar
2017-06-13 20:59                 ` Mickaël Salaün
2017-06-14 14:10                 ` Alan Cox
2017-06-14 20:37                   ` [kernel-hardening] " Boris Lukashev
2017-06-13 20:59               ` Mickaël Salaün [this message]
2017-06-13 21:44                 ` Casey Schaufler

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=8a2300ef-1462-0e1f-2d6a-81e6020bc71f@digikod.net \
    --to=mic@digikod.net \
    --cc=danielmicay@gmail.com \
    --cc=jason@perfinion.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=matt@nmatt.com \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=zohar@linux.vnet.ibm.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

all inboxes | Powered by JetHome®