* Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures
[not found] <ZuPDZL_EIoS60L1a@gondor.apana.org.au>
@ 2024-09-13 8:30 ` Roberto Sassu
2024-09-13 9:00 ` Herbert Xu
2024-09-15 7:11 ` Linus Torvalds
0 siblings, 2 replies; 13+ messages in thread
From: Roberto Sassu @ 2024-09-13 8:30 UTC (permalink / raw)
To: Herbert Xu
Cc: dhowells, dwmw2, davem, linux-kernel, keyrings, linux-crypto,
zohar, linux-integrity, torvalds, roberto.sassu,
linux-security-module
On Fri, 2024-09-13 at 12:45 +0800, Herbert Xu wrote:
> Roberto Sassu <roberto.sassu@huaweicloud.com> wrote:
+ linux-security-module
> >
> > For the envisioned use cases, PGP operations cannot be done in user space,
> > since the consumers are in the kernel itself (Integrity Digest Cache and
> > IMA). Also they cannot be done in a trusted initial ram disk, since PGP
> > operations can occur also while the system is running (e.g. after software
> > package installation).
>
> Does this address Linus's objections? If not then we cannot proceed.
I hope to get an answer from him.
> Personally I don't think the argument above holds water. With
> IPsec we had a similar issue of authenticating untrusted peers
> using public key cryptography. In that case we successfully
> delegated the task to user-space and it is still how it works
> to this day.
That makes sense, since it is not the kernel holding secrets on behalf
of user space, it is user space passing the crypto material to the
kernel (if I remember IPSEC correctly). Failure of user space to hold
its secrets or to tamper with the task has only effect in user space.
With my understanding, I'm citing a source enumerating the requirements
of a secure system:
James P. Anderson: Computer Security Technology Planning Study
The first requirement of a component enforcing a security policy on a
Target of Evaluation (TOE), aka the reference monitor, is that it must
be tamperproof [1].
The security policy I want to enforce is: all code that the system
executes has been built by a trusted source (e.g. a Linux
distribution).
I want to leverage the kernel to enforce such security policy, and I
assume that the kernel can be fortified enough (for example through the
lockdown LSM) to be considered tamperproof against the TOE (the user
space processes).
The first problem I see in delegating the public crypto task to user
space is that it is at the same time part of the reference monitor
(since it is used to enforce the security policy) and it is a TOE too.
The second problem is, assuming that the task is verified through other
means other than PGP (but again, we are still relying on the public
crypto functionality to be performed by the kernel, for this to work),
that I didn't get a confirmation that user space can have equivalent
isolation guarantees as the kernel:
https://lore.kernel.org/linux-integrity/eb31920bd00e2c921b0aa6ebed8745cb0130b0e1.camel@huaweicloud.com/
Please, keep in mind that I already proposed what you suggested:
https://lore.kernel.org/linux-kernel/20230317145240.363908-1-roberto.sassu@huaweicloud.com/#r
After discussing with some kernel developers, the outcome was that a
better choice would be to put the code in the kernel, if I want
reasonable tamperproof guarantees.
Thanks
Roberto
[1] https://seclab.cs.ucdavis.edu/projects/history/papers/ande72a.pdf (page 17)
> A user-space daemon dedicated to public key crypto seems equally
> applicable to your scenario.
>
> The original application that brought public key crypto into the
> kernel was module loading. If we really wanted to we could extend
> the user-space verification to modules too and perhaps kick all
> public key crypto out of the kernel.
>
> The complexity and lack of reviewer attention in this area means
> that we're more likely to introduce security holes into the kernel
> with such code.
>
> Cheers,
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures
2024-09-13 8:30 ` [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures Roberto Sassu
@ 2024-09-13 9:00 ` Herbert Xu
2024-09-15 7:11 ` Linus Torvalds
1 sibling, 0 replies; 13+ messages in thread
From: Herbert Xu @ 2024-09-13 9:00 UTC (permalink / raw)
To: Roberto Sassu
Cc: dhowells, dwmw2, davem, linux-kernel, keyrings, linux-crypto,
zohar, linux-integrity, torvalds, roberto.sassu,
linux-security-module
On Fri, Sep 13, 2024 at 10:30:11AM +0200, Roberto Sassu wrote:
>
> The second problem is, assuming that the task is verified through other
> means other than PGP (but again, we are still relying on the public
> crypto functionality to be performed by the kernel, for this to work),
> that I didn't get a confirmation that user space can have equivalent
> isolation guarantees as the kernel:
>
> https://lore.kernel.org/linux-integrity/eb31920bd00e2c921b0aa6ebed8745cb0130b0e1.camel@huaweicloud.com/
>
>
> Please, keep in mind that I already proposed what you suggested:
>
> https://lore.kernel.org/linux-kernel/20230317145240.363908-1-roberto.sassu@huaweicloud.com/#r
>
>
> After discussing with some kernel developers, the outcome was that a
> better choice would be to put the code in the kernel, if I want
> reasonable tamperproof guarantees.
Where is this discussion? I clicked through the two links above
and everyone seems to agree that putting it in user-space is a good
idea.
Thanks,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures
2024-09-13 8:30 ` [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures Roberto Sassu
2024-09-13 9:00 ` Herbert Xu
@ 2024-09-15 7:11 ` Linus Torvalds
2024-09-15 8:07 ` Herbert Xu
2024-09-15 10:51 ` Roberto Sassu
1 sibling, 2 replies; 13+ messages in thread
From: Linus Torvalds @ 2024-09-15 7:11 UTC (permalink / raw)
To: Roberto Sassu
Cc: Herbert Xu, dhowells, dwmw2, davem, linux-kernel, keyrings,
linux-crypto, zohar, linux-integrity, roberto.sassu,
linux-security-module
On Fri, 13 Sept 2024 at 10:30, Roberto Sassu
<roberto.sassu@huaweicloud.com> wrote:
>
> On Fri, 2024-09-13 at 12:45 +0800, Herbert Xu wrote:
> >
> > Does this address Linus's objections? If not then we cannot proceed.
>
> I hope to get an answer from him.
So honestly, just the series adding pgp key verification I have no
objection to. The use case where some firmware uses pgp to validate
allowed keys in EFI variables etc sounds like a "ok, then we need to
parse them".
The objections I had were against the whole "start doing policy in
kernel", with what sounded like actually parsing and unpacking rpm
contents and verifying them with a pgp key. *That* still sounds like a
disaster to me, and is the part that made me go "why isn't that done
in user space together with then generating the fsverifty
information"?
The argument that the kernel is the only part of the system you trust
is bogus. The kernel does nothing on its own (apart from device
enumeration etc of course), so if you have no trustworthy user space,
then you might as well just give up entirely. At a *minimum* you have
initrd, and that can then be the start of a chain of user space trust.
Parsing rpm files in the kernel really sounds horrendous. But that
doesn't mean that I hate *this* series that just adds pgp key handling
in case there are other valid uses for it.
But maybe I misunderstood the original suggestion from Roberto.
Linus
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures
2024-09-15 7:11 ` Linus Torvalds
@ 2024-09-15 8:07 ` Herbert Xu
2024-09-15 8:40 ` Linus Torvalds
2024-09-15 10:51 ` Roberto Sassu
1 sibling, 1 reply; 13+ messages in thread
From: Herbert Xu @ 2024-09-15 8:07 UTC (permalink / raw)
To: Linus Torvalds
Cc: Roberto Sassu, dhowells, dwmw2, davem, linux-kernel, keyrings,
linux-crypto, zohar, linux-integrity, roberto.sassu,
linux-security-module, Ard Biesheuvel
On Sun, Sep 15, 2024 at 09:11:04AM +0200, Linus Torvalds wrote:
>
> So honestly, just the series adding pgp key verification I have no
> objection to. The use case where some firmware uses pgp to validate
> allowed keys in EFI variables etc sounds like a "ok, then we need to
> parse them".
The use-case for EFI variables appears to be invalid:
https://lore.kernel.org/all/CAMj1kXH8nWtAzX+9xc2tLyy5d0w==JNQCMJBAbL=LdcF+XrYkw@mail.gmail.com/
> The objections I had were against the whole "start doing policy in
> kernel", with what sounded like actually parsing and unpacking rpm
> contents and verifying them with a pgp key. *That* still sounds like a
> disaster to me, and is the part that made me go "why isn't that done
> in user space together with then generating the fsverifty
> information"?
If the aformentioned EFI use-case is bogus, then distro package
verification is going to be the only application for PGP keys in
the kernel.
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures
2024-09-15 8:07 ` Herbert Xu
@ 2024-09-15 8:40 ` Linus Torvalds
2024-09-15 9:15 ` Herbert Xu
2024-09-26 9:41 ` Roberto Sassu
0 siblings, 2 replies; 13+ messages in thread
From: Linus Torvalds @ 2024-09-15 8:40 UTC (permalink / raw)
To: Herbert Xu
Cc: Roberto Sassu, dhowells, dwmw2, davem, linux-kernel, keyrings,
linux-crypto, zohar, linux-integrity, roberto.sassu,
linux-security-module, Ard Biesheuvel
On Sun, 15 Sept 2024 at 10:08, Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> If the aformentioned EFI use-case is bogus, then distro package
> verification is going to be the only application for PGP keys in
> the kernel.
So I haven't actually seen _that_ series, but as mentioned it does
smell pretty conceptually broken to me.
But hey, code talks, bullshit walks. People can most certainly try to
convince me.
Linus
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures
2024-09-15 8:40 ` Linus Torvalds
@ 2024-09-15 9:15 ` Herbert Xu
2024-09-15 9:31 ` Herbert Xu
2024-09-26 9:41 ` Roberto Sassu
1 sibling, 1 reply; 13+ messages in thread
From: Herbert Xu @ 2024-09-15 9:15 UTC (permalink / raw)
To: Linus Torvalds
Cc: Roberto Sassu, dhowells, dwmw2, davem, linux-kernel, keyrings,
linux-crypto, zohar, linux-integrity, roberto.sassu,
linux-security-module, Ard Biesheuvel
On Sun, Sep 15, 2024 at 10:40:15AM +0200, Linus Torvalds wrote:
>
> So I haven't actually seen _that_ series, but as mentioned it does
> smell pretty conceptually broken to me.
>
> But hey, code talks, bullshit walks. People can most certainly try to
> convince me.
Roberto, correct me if I'm wrong but your intended use case is
the following patch series, right?
https://lore.kernel.org/linux-integrity/20240905152512.3781098-1-roberto.sassu@huaweicloud.com/
Thanks,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures
2024-09-15 9:15 ` Herbert Xu
@ 2024-09-15 9:31 ` Herbert Xu
2024-09-15 17:52 ` Roberto Sassu
0 siblings, 1 reply; 13+ messages in thread
From: Herbert Xu @ 2024-09-15 9:31 UTC (permalink / raw)
To: Linus Torvalds
Cc: Roberto Sassu, dhowells, dwmw2, davem, linux-kernel, keyrings,
linux-crypto, zohar, linux-integrity, roberto.sassu,
linux-security-module, Ard Biesheuvel
On Sun, Sep 15, 2024 at 05:15:25PM +0800, Herbert Xu wrote:
>
> Roberto, correct me if I'm wrong but your intended use case is
> the following patch series, right?
Actually the meat of the changes is in the following series:
https://lore.kernel.org/linux-integrity/20240905150543.3766895-1-roberto.sassu@huaweicloud.com/
Cheers,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures
2024-09-15 7:11 ` Linus Torvalds
2024-09-15 8:07 ` Herbert Xu
@ 2024-09-15 10:51 ` Roberto Sassu
1 sibling, 0 replies; 13+ messages in thread
From: Roberto Sassu @ 2024-09-15 10:51 UTC (permalink / raw)
To: Linus Torvalds
Cc: Herbert Xu, dhowells, dwmw2, davem, linux-kernel, keyrings,
linux-crypto, zohar, linux-integrity, roberto.sassu,
linux-security-module
On 9/15/2024 9:11 AM, Linus Torvalds wrote:
> On Fri, 13 Sept 2024 at 10:30, Roberto Sassu
[...]
> The objections I had were against the whole "start doing policy in
> kernel", with what sounded like actually parsing and unpacking rpm
> contents and verifying them with a pgp key. *That* still sounds like a
> disaster to me, and is the part that made me go "why isn't that done
> in user space together with then generating the fsverifty
> information"?
In my opinion, trusting root in this situation is not ideal. Trusting
root means trusting all applications that root can run, that they will
verify PGP signatures of fsverity digests with Linux distribution keys.
In order to trust them, we would need to check the integrity of all
those applications, in particular file read and IPC with the rest of the
system.
A safer way to achieve the same goal is to let the kernel verify PGP
signatures, assuming that the kernel is more privileged and cannot be
tampered by root (for example, by using the 'lockdown' LSM). Since the
PGP keys of the Linux distribution would be embedded in the kernel image
(or certified by the embedded ones), trusting the system would require
only to verify the kernel image itself (for example, with the boot loader).
Kernel-based policy enforcement is currently adopted by other LSMs, such
as SELinux. SELinux also parses and enforces a policy sent from user
space in the kernel. This does not mean that the policy itself is in the
kernel, but that the kernel is the only component in the position of
enforcing the policy without trusting all applications that root can run.
Roberto
> The argument that the kernel is the only part of the system you trust
> is bogus. The kernel does nothing on its own (apart from device
> enumeration etc of course), so if you have no trustworthy user space,
> then you might as well just give up entirely. At a *minimum* you have
> initrd, and that can then be the start of a chain of user space trust.
>
> Parsing rpm files in the kernel really sounds horrendous. But that
> doesn't mean that I hate *this* series that just adds pgp key handling
> in case there are other valid uses for it.
>
> But maybe I misunderstood the original suggestion from Roberto.
>
> Linus
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures
2024-09-15 9:31 ` Herbert Xu
@ 2024-09-15 17:52 ` Roberto Sassu
2024-09-17 11:27 ` Dr. Greg
0 siblings, 1 reply; 13+ messages in thread
From: Roberto Sassu @ 2024-09-15 17:52 UTC (permalink / raw)
To: Herbert Xu, Linus Torvalds
Cc: dhowells, dwmw2, davem, linux-kernel, keyrings, linux-crypto,
zohar, linux-integrity, roberto.sassu, linux-security-module,
Ard Biesheuvel
On 9/15/2024 11:31 AM, Herbert Xu wrote:
> On Sun, Sep 15, 2024 at 05:15:25PM +0800, Herbert Xu wrote:
>>
>> Roberto, correct me if I'm wrong but your intended use case is
>> the following patch series, right?
>
> Actually the meat of the changes is in the following series:
>
> https://lore.kernel.org/linux-integrity/20240905150543.3766895-1-roberto.sassu@huaweicloud.com/
Yes, correct. The idea is to verify the authenticity of RPM headers,
extract the file digests from them, and use those file digests as
reference values for integrity checking of files accessed by user space
processes.
If the calculated digest of a file being accessed matches one extracted
from the RPM header, access is granted otherwise it is denied.
Roberto
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures
2024-09-15 17:52 ` Roberto Sassu
@ 2024-09-17 11:27 ` Dr. Greg
0 siblings, 0 replies; 13+ messages in thread
From: Dr. Greg @ 2024-09-17 11:27 UTC (permalink / raw)
To: Roberto Sassu
Cc: Herbert Xu, Linus Torvalds, dhowells, dwmw2, davem, linux-kernel,
keyrings, linux-crypto, zohar, linux-integrity, roberto.sassu,
linux-security-module, Ard Biesheuvel
On Sun, Sep 15, 2024 at 07:52:13PM +0200, Roberto Sassu wrote:
Good morning, I hope the day is starting well for everyone.
> On 9/15/2024 11:31 AM, Herbert Xu wrote:
> >On Sun, Sep 15, 2024 at 05:15:25PM +0800, Herbert Xu wrote:
> >>
> >>Roberto, correct me if I'm wrong but your intended use case is
> >>the following patch series, right?
> >
> >Actually the meat of the changes is in the following series:
> >
> >https://lore.kernel.org/linux-integrity/20240905150543.3766895-1-roberto.sassu@huaweicloud.com/
> Yes, correct. The idea is to verify the authenticity of RPM headers,
> extract the file digests from them, and use those file digests as
> reference values for integrity checking of files accessed by user
> space processes.
>
> If the calculated digest of a file being accessed matches one
> extracted from the RPM header, access is granted otherwise it is
> denied.
Based on the above response and your comment:
"The security policy I want to enforce is: all code that the system
executes has been built by a trusted source (e.g. a Linux
distribution)."
From the following URL:
https://lore.kernel.org/linux-integrity/b4a3e55650a9e9f2302cf093e5cc8e739b4ac98f.camel@huaweicloud.com/#t
What you are advocating for then, with this patch series and the
digest cache series, is a security policy that requires signed code
execution, correct?
Nothing wrong with that, it is a reasonable security desire, but it
seems wrong to conflate that with the implementation of the digest
cache. There is a great deal of utility in a digest cache but it
doesn't require the need to parse RPM header information and/or TLV
sequences in the kernel.
That would only appear to be a requirement if your goal is a signed
executable policy that is implemented through a packaging medium,
correct?
To wit:
If I have security infrastructure that gives me confidence in the
integrity of the files on my media, I can populate a digest cache with
a simple ASCII list of pathnames fed into the kernel at boot time.
If I don't have confidence in the integrity of the files on my media I
could append a known good checksum to each pathname with the last
entry in the list being a PGP signature over the input stream.
I brought the following issue up in the patch series that Herbert
links to above, but will do so here, since I believe it has relevance
to this conversation as well.
If the goal is to have the digest cache be relevant from an integrity
perspective, particularly a signed code policy, you have to physically
read every file that has a digest value in the RPM digest list.
Otherwise the scheme is vulnerable to a Time Of Measurement Time Of
Use (TOMTOU) vulnerability scenario, correct?
This requires that one needs to experience a latency hit at least
once, presumably at boot when you prime the digest cache, correct?
An alternative approach may be to separate the RPM/TLV parsing code
from the digest code and implement RPM/Debian/whatever parsing in a
loadable module that would in turn populate the digest cache.
That may be a more acceptable strategy since it places the potential
security vulnerabilities of a parser into something that an entity
that is interested in a signed code policy would consider to be an
acceptable tradeoff from a security perspective.
> Roberto
Hopefully the above comments and clarifications will be helpful in
furthering additional discussion.
Have a good day.
As always,
Dr. Greg
The Quixote Project - Flailing at the Travails of Cybersecurity
https://github.com/Quixote-Project
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures
2024-09-15 8:40 ` Linus Torvalds
2024-09-15 9:15 ` Herbert Xu
@ 2024-09-26 9:41 ` Roberto Sassu
2024-09-27 1:25 ` Dr. Greg
2024-10-04 10:42 ` Roberto Sassu
1 sibling, 2 replies; 13+ messages in thread
From: Roberto Sassu @ 2024-09-26 9:41 UTC (permalink / raw)
To: Linus Torvalds, Herbert Xu
Cc: dhowells, dwmw2, davem, linux-kernel, keyrings, linux-crypto,
zohar, linux-integrity, roberto.sassu, linux-security-module,
Ard Biesheuvel
On Sun, 2024-09-15 at 10:40 +0200, Linus Torvalds wrote:
> On Sun, 15 Sept 2024 at 10:08, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> >
> > If the aformentioned EFI use-case is bogus, then distro package
> > verification is going to be the only application for PGP keys in
> > the kernel.
>
> So I haven't actually seen _that_ series, but as mentioned it does
> smell pretty conceptually broken to me.
>
> But hey, code talks, bullshit walks. People can most certainly try to
> convince me.
The solution has three parts.
1. The kernel verifies the RPM header with a PGP key embedded in the
kernel, and provided by the Linux distribution vendor.
2. The Integrity Digest Cache parses the verified RPM header in the
kernel and feeds one of the existing LSMs (IMA, IPE and BPF LSM) with
the digests extracted from the RPM header.
3. The LSMs compare the fsverity digest they find in the filesystem
with the authenticated ones from the RPM header, and might deny access
to the file if the digests don't match.
At this point, RPM headers don't contain fsverity digests, only file
content digests, but this is an orthogonal problem.
I had a look at previous threads on similar topics, to find your
position on the matter.
I got that you would not be probably against (1), and maybe not (3).
However, we still need a source telling whether the fsverity digest in
the filesystem is the same of one calculated by Linux distributions
during build. That is what the Integrity Digest Cache provides.
Regarding (2), maybe I'm missing something fundamental, but isn't
parsing the ELF format of kernel modules from the kernel similar?
Cannot really go to user space at this point, since the authenticated
fsverity digests are directly consumed by LSMs. Also, as David pointed
out in this thread [1], there is no obligation for user space to call
any signature verification function before executing a file, this task
must be done by an LSM.
I'm aware that we should not run unnecessary code in the kernel. I
tried to mitigate this issue by striping the parsing functionality to
the minimum (220 LOC), and formally verifying it with the Frama-C
static analyzer. The parser is available here [2].
I'm also aware that this is not the long term solution, but I didn't
find much support on the alternatives, like a trustworthy user mode
driver [3][4] (isolated from other root processes) and signed eBPF
programs [5].
What it would be the right way to proceed, in your opinion?
Thanks
Roberto
[1] https://lore.kernel.org/linux-kernel/32081.1171560770@redhat.com/
[2] https://lore.kernel.org/linux-integrity/20240905150543.3766895-9-roberto.sassu@huaweicloud.com/
[3] https://lore.kernel.org/lkml/20230317145240.363908-1-roberto.sassu@huaweicloud.com/#t
[4] https://lore.kernel.org/linux-integrity/eb31920bd00e2c921b0aa6ebed8745cb0130b0e1.camel@huaweicloud.com/
[5] https://lwn.net/Articles/853489/
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures
2024-09-26 9:41 ` Roberto Sassu
@ 2024-09-27 1:25 ` Dr. Greg
2024-10-04 10:42 ` Roberto Sassu
1 sibling, 0 replies; 13+ messages in thread
From: Dr. Greg @ 2024-09-27 1:25 UTC (permalink / raw)
To: Roberto Sassu
Cc: Linus Torvalds, Herbert Xu, dhowells, dwmw2, davem, linux-kernel,
keyrings, linux-crypto, zohar, linux-integrity, roberto.sassu,
linux-security-module, Ard Biesheuvel
On Thu, Sep 26, 2024 at 11:41:51AM +0200, Roberto Sassu wrote:
Good evening, I hope the week has gone well for everyone.
> On Sun, 2024-09-15 at 10:40 +0200, Linus Torvalds wrote:
> > On Sun, 15 Sept 2024 at 10:08, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> > >
> > > If the aformentioned EFI use-case is bogus, then distro package
> > > verification is going to be the only application for PGP keys in
> > > the kernel.
> >
> > So I haven't actually seen _that_ series, but as mentioned it does
> > smell pretty conceptually broken to me.
> >
> > But hey, code talks, bullshit walks. People can most certainly try to
> > convince me.
> The solution has three parts.
>
> 1. The kernel verifies the RPM header with a PGP key embedded in the
> kernel, and provided by the Linux distribution vendor.
>
> 2. The Integrity Digest Cache parses the verified RPM header in the
> kernel and feeds one of the existing LSMs (IMA, IPE and BPF LSM) with
> the digests extracted from the RPM header.
>
> 3. The LSMs compare the fsverity digest they find in the filesystem
> with the authenticated ones from the RPM header, and might deny access
> to the file if the digests don't match.
>
> At this point, RPM headers don't contain fsverity digests, only file
> content digests, but this is an orthogonal problem.
So from the above, can it be assumed that the RPM parsing code isn't
useful until the RPM packages contain fsverity root hashes?
In addition, and we mentioned this previously in this thread, it seems
that one needs to 'eat' a full read of a file, at least once, in order
to generate an fsverity digest that is consistent with the actual
on-disk contents of the file.
So, once again, the notion of the implementation of a generic digest
cache would seem to be orthogonal to the issue of verifying that the
digest values in the cache are from a 'known good' source.
> I had a look at previous threads on similar topics, to find your
> position on the matter.
>
> I got that you would not be probably against (1), and maybe not (3).
>
> However, we still need a source telling whether the fsverity digest in
> the filesystem is the same of one calculated by Linux distributions
> during build. That is what the Integrity Digest Cache provides.
>
> Regarding (2), maybe I'm missing something fundamental, but isn't
> parsing the ELF format of kernel modules from the kernel similar?
>
> Cannot really go to user space at this point, since the authenticated
> fsverity digests are directly consumed by LSMs. Also, as David pointed
> out in this thread [1], there is no obligation for user space to call
> any signature verification function before executing a file, this task
> must be done by an LSM.
>
> I'm aware that we should not run unnecessary code in the kernel. I
> tried to mitigate this issue by striping the parsing functionality to
> the minimum (220 LOC), and formally verifying it with the Frama-C
> static analyzer. The parser is available here [2].
>
> I'm also aware that this is not the long term solution, but I didn't
> find much support on the alternatives, like a trustworthy user mode
> driver [3][4] (isolated from other root processes) and signed eBPF
> programs [5].
We mentioned this previously in the related threads you cite, our TSEM
LSM implementation allows the kernel to determine whether or not a
userspace process or the entirety of userspace should be 'trusted' at
any point in time.
The security footprint/model of a digest 'priming' workload is going
to be extremely small. If the priming workload is invoked early in
the boot process the kernel can have assurance that neither the
priming workload or the surrounding userspace has commited any actions
that would be considered to make the system untrusted.
> What it would be the right way to proceed, in your opinion?
Alternatively, we had suggested previously that the RPM parsing code
may be a good candidate for implementation with a separate kernel
loadable module. That places the parsing code in the kernel to meet
your security requirement and there is standardized infrastructure for
module signing that would ensure the integrity of the parser.
The module surfaces a pseudo-file through securityfs that userspace
can use to feed the RPM header into the kernel to drive the population
of the digest cache. The parser only needs to be resident and
operative long enough to initialize the digest cache of a trusted
system and a kernel loadable module would seem to be consistent with
that model.
Once again, priming the digest cache with known good digests seems to
be an issue orthogonal to the implementation of the digest cache
itself.
We would be interested in knowing if we are misunderstanding the model
you are trying to achieve.
> Thanks
>
> Roberto
>
> [1] https://lore.kernel.org/linux-kernel/32081.1171560770@redhat.com/
> [2] https://lore.kernel.org/linux-integrity/20240905150543.3766895-9-roberto.sassu@huaweicloud.com/
> [3] https://lore.kernel.org/lkml/20230317145240.363908-1-roberto.sassu@huaweicloud.com/#t
> [4] https://lore.kernel.org/linux-integrity/eb31920bd00e2c921b0aa6ebed8745cb0130b0e1.camel@huaweicloud.com/
> [5] https://lwn.net/Articles/853489/
Have a good weekend.
As always,
Dr. Greg
The Quixote Project - Flailing at the Travails of Cybersecurity
https://github.com/Quixote-Project
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures
2024-09-26 9:41 ` Roberto Sassu
2024-09-27 1:25 ` Dr. Greg
@ 2024-10-04 10:42 ` Roberto Sassu
1 sibling, 0 replies; 13+ messages in thread
From: Roberto Sassu @ 2024-10-04 10:42 UTC (permalink / raw)
To: Linus Torvalds, Herbert Xu
Cc: dhowells, dwmw2, davem, linux-kernel, keyrings, linux-crypto,
zohar, linux-integrity, roberto.sassu, linux-security-module,
Ard Biesheuvel
On 9/26/2024 11:41 AM, Roberto Sassu wrote:
> On Sun, 2024-09-15 at 10:40 +0200, Linus Torvalds wrote:
>> On Sun, 15 Sept 2024 at 10:08, Herbert Xu <herbert@gondor.apana.org.au> wrote:
>>>
>>> If the aformentioned EFI use-case is bogus, then distro package
>>> verification is going to be the only application for PGP keys in
>>> the kernel.
>>
>> So I haven't actually seen _that_ series, but as mentioned it does
>> smell pretty conceptually broken to me.
>>
>> But hey, code talks, bullshit walks. People can most certainly try to
>> convince me.
>
> The solution has three parts.
>
> 1. The kernel verifies the RPM header with a PGP key embedded in the
> kernel, and provided by the Linux distribution vendor.
>
> 2. The Integrity Digest Cache parses the verified RPM header in the
> kernel and feeds one of the existing LSMs (IMA, IPE and BPF LSM) with
> the digests extracted from the RPM header.
>
> 3. The LSMs compare the fsverity digest they find in the filesystem
> with the authenticated ones from the RPM header, and might deny access
> to the file if the digests don't match.
>
> At this point, RPM headers don't contain fsverity digests, only file
> content digests, but this is an orthogonal problem.
>
>
> I had a look at previous threads on similar topics, to find your
> position on the matter.
>
> I got that you would not be probably against (1), and maybe not (3).
>
> However, we still need a source telling whether the fsverity digest in
> the filesystem is the same of one calculated by Linux distributions
> during build. That is what the Integrity Digest Cache provides.
>
> Regarding (2), maybe I'm missing something fundamental, but isn't
> parsing the ELF format of kernel modules from the kernel similar?
>
> Cannot really go to user space at this point, since the authenticated
> fsverity digests are directly consumed by LSMs. Also, as David pointed
> out in this thread [1], there is no obligation for user space to call
> any signature verification function before executing a file, this task
> must be done by an LSM.
>
> I'm aware that we should not run unnecessary code in the kernel. I
> tried to mitigate this issue by striping the parsing functionality to
> the minimum (220 LOC), and formally verifying it with the Frama-C
> static analyzer. The parser is available here [2].
>
> I'm also aware that this is not the long term solution, but I didn't
> find much support on the alternatives, like a trustworthy user mode
> driver [3][4] (isolated from other root processes) and signed eBPF
> programs [5].
>
> What it would be the right way to proceed, in your opinion?
If I remove the parsers completely from the kernel, and attach them
dynamically with eBPF, would you reconsider my patch set?
Thanks
Roberto
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2024-10-04 11:01 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <ZuPDZL_EIoS60L1a@gondor.apana.org.au>
2024-09-13 8:30 ` [PATCH v3 00/14] KEYS: Add support for PGP keys and signatures Roberto Sassu
2024-09-13 9:00 ` Herbert Xu
2024-09-15 7:11 ` Linus Torvalds
2024-09-15 8:07 ` Herbert Xu
2024-09-15 8:40 ` Linus Torvalds
2024-09-15 9:15 ` Herbert Xu
2024-09-15 9:31 ` Herbert Xu
2024-09-15 17:52 ` Roberto Sassu
2024-09-17 11:27 ` Dr. Greg
2024-09-26 9:41 ` Roberto Sassu
2024-09-27 1:25 ` Dr. Greg
2024-10-04 10:42 ` Roberto Sassu
2024-09-15 10:51 ` Roberto Sassu
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).