lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1581205431.5585.645.camel@linux.ibm.com>
Date:   Sat, 08 Feb 2020 18:43:51 -0500
From:   Mimi Zohar <zohar@...ux.ibm.com>
To:     Eric Snowberg <eric.snowberg@...cle.com>
Cc:     Nayna <nayna@...ux.vnet.ibm.com>, dmitry.kasatkin@...il.com,
        jmorris@...ei.org, serge@...lyn.com, dhowells@...hat.com,
        geert@...ux-m68k.org, gregkh@...uxfoundation.org,
        nayna@...ux.ibm.com, tglx@...utronix.de, bauerman@...ux.ibm.com,
        mpe@...erman.id.au, linux-integrity@...r.kernel.org,
        linux-security-module@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Roberto Sassu <roberto.sassu@...wei.com>
Subject: Re: [RFC PATCH 0/2] ima: uncompressed module appraisal support

On Fri, 2020-02-07 at 14:38 -0700, Eric Snowberg wrote:
> > On Feb 7, 2020, at 11:54 AM, Mimi Zohar <zohar@...ux.ibm.com> wrote:
> > 
> > On Fri, 2020-02-07 at 11:45 -0700, Eric Snowberg wrote:
> >> 
> >>> On Feb 7, 2020, at 11:28 AM, Mimi Zohar <zohar@...ux.ibm.com> wrote:
> >>> 
> >>> On Fri, 2020-02-07 at 10:49 -0700, Eric Snowberg wrote:
> >>>> 
> >>>>> On Feb 7, 2020, at 10:40 AM, Mimi Zohar <zohar@...ux.ibm.com> wrote:
> >>>>> 
> >>>>>> $ insmod ./foo.ko
> >>>>>> insmod: ERROR: could not insert module ./foo.ko: Permission denied
> >>>>>> 
> >>>>>> last entry from audit log:
> >>>>>> type=INTEGRITY_DATA msg=audit(1581089373.076:83): pid=2874 uid=0
> >>>>>> auid=0 ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-
> >>>>>> s0:c0.c1023 op=appraise_data cause=invalid-signature comm="insmod"
> >>>>>> name="/root/keys/modules/foo.ko" dev="dm-0" ino=10918365
> >>>>>> res=0^]UID="root" AUID=“root"
> >>>>>> 
> >>>>>> This is because modsig_verify() will be called from within
> >>>>>> ima_appraise_measurement(), 
> >>>>>> since try_modsig is true.  Then modsig_verify() will return
> >>>>>> INTEGRITY_FAIL.
> >>>>> 
> >>>>> Why is it an "invalid signature"?  For that you need to look at the
> >>>>> kernel messages.  Most likely it can't find the public key on the .ima
> >>>>> keyring to verify the signature.
> >>>> 
> >>>> It is invalid because the module has not been ima signed. 
> >>> 
> >>> With the IMA policy rule "appraise func=MODULE_CHECK
> >>> appraise_type=imasig|modsig", IMA first tries to verify the IMA
> >>> signature stored as an xattr and on failure then attempts to verify
> >>> the appended signatures.
> >>> 
> >>> The audit message above indicates that there was a signature, but the
> >>> signature validation failed.
> >>> 
> >> 
> >> I do have  CONFIG_IMA_APPRAISE_MODSIG enabled.  I believe the audit message above 
> >> is coming from modsig_verify in security/integrity/ima/ima_appraise.c.
> > 
> > Right, and it's calling:
> > 
> > 	rc = integrity_modsig_verify(INTEGRITY_KEYRING_IMA, modsig);
> > 
> > It's failing because it is trying to find the public key on the .ima
> > keyring.  Make sure that the public needed to validate the kernel
> > module is on the IMA keyring (eg. keyctl show %keyring:.ima).
> > 
> 
> I know that will validate the module properly, but that is not what I’m 
> trying to solve here. I thought the point of adding “|modsig” to the
> ima policy was to tell ima it can either validate against an ima keyring OR 
> default back to the kernel keyring.  This is what happens with the compressed
> module.  There isn’t anything in the ima keyring to validate the compressed
> modules and it loads when I add “|modsig”.

"modsig" has nothing to do with keyrings.  The term "modsig" is
juxtaposed to "imasig".  "modsig" refers to kernel module appended
signature. 

> 
> The use case I’m trying to solve is when someone boots with ima_policy=secure_boot.

As the secure_boot policy rules are replaced once a custom policy is
loaded, the "secure_boot" policy should probably be deprecated.  I
highly recommend using the more recent build time and architecture
specific run time policy rules, which persist after loading a custom
policy. 

> If their initramfs contains compressed modules with appended signatures the
> system boots.  If they use the same ima policy with an initramfs that contains
> uncompressed modules, it doesn't boot.  I thought the point of adding “|modsig”
> was to help with the initramfs problem, since it is difficult to ima sign
> things within it.

There have been a number of attempts to address the CPIO problem of
not being able to include security extended attributes in the
initramfs.  If you're interested in solving that problem, then review
and comment on Roberto Sassu's patches[1].

Mimi

[1] https://lkml.org/lkml/2019/5/23/415

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ