From: Mimi Zohar <zohar@linux.ibm.com>
To: "Jérémy Jean" <Jeremy.Jean@oss.cyber.gouv.fr>,
"Roberto Sassu" <roberto.sassu@huawei.com>,
"Dmitry Kasatkin" <dmitry.kasatkin@gmail.com>
Cc: linux-integrity@vger.kernel.org,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ima: reject modsig if detached data cannot be supplied
Date: Fri, 16 Oct 2026 15:53:13 -0400 [thread overview]
Message-ID: <3d3fc94b377125df87c02b6a73ef664b35fa37c1.camel@linux.ibm.com> (raw)
In-Reply-To: <0aed6bb22776b2bf9e9e11edd18dd559f71e5186.camel@linux.ibm.com>
On Mon, 2026-08-24 at 12:00 -0400, Mimi Zohar wrote:
> On Sat, 2026-08-22 at 08:24 +0000, Jérémy Jean wrote:
> > ima_collect_modsig() binds the file being appraised to the parsed PKCS#7
> > message with pkcs7_supply_detached_data(). If the message already contains
> > embedded data, the helper returns -EINVAL. However, ima_collect_modsig()
> > silently returns because its return type is void.
> >
> > ima_modsig_verify() subsequently calls verify_pkcs7_message_sig() with a
> > NULL data pointer. That verifies the embedded PKCS#7 data instead of the
> > file being appraised. An attacker can therefore take a valid
> > detached signature, insert the original signed bytes as embedded content
> > without the private key, and append the resulting message to an unrelated
> > file. IMA accepts the unrelated file.
> >
> > This bypasses the module authenticity boundary when an IMA modsig appraisal
> > rule is enforced while CONFIG_MODULE_SIG is disabled.
> >
> > Return detached-data binding errors and stop measurement collection when
> > binding fails. Keep digest extraction optional because algorithms such as
> > ML-DSA can verify the message directly. Appraisal then rejects the file
> > rather than reaching verification with embedded content active.
> >
> > Fixes: 15588227e086 ("ima: Collect modsig")
> > Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
> > Assisted-by: Codex:gpt-5
> > ---
[...]
> > static inline int ima_get_modsig_digest(const struct modsig *modsig,
> > diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
> > index 122d127e108d..e2b167f24778 100644
> > --- a/security/integrity/ima/ima_api.c
> > +++ b/security/integrity/ima/ima_api.c
> > @@ -262,8 +262,11 @@ int ima_collect_measurement(struct ima_iint_cache *iint, struct file *file,
> > * the file digest without collecting the modsig in a previous
> > * measurement rule.
> > */
> > - if (modsig)
> > - ima_collect_modsig(modsig, buf, size);
> > + if (modsig) {
> > + result = ima_collect_modsig(modsig, buf, size);
> > + if (result)
> > + goto out;
> > +
>
> The normal processing of getting the xattr needs to continue even if the
> appended signatures doesn't exist. Exiting here is too early. Consider saving
> the result as a different variable and returning an error later, if needed.
By going to "out", the file will not be properly measured, nor would the file be
appraised based on security.ima xattr. A better solution would be to free
modsig and continue as if there wasn't an appended signature.
thanks,
Mimi
prev parent reply other threads:[~2026-10-16 19:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-22 8:24 Jérémy Jean
2026-08-24 16:00 ` Mimi Zohar
2026-10-16 19:53 ` Mimi Zohar [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=3d3fc94b377125df87c02b6a73ef664b35fa37c1.camel@linux.ibm.com \
--to=zohar@linux.ibm.com \
--cc=Jeremy.Jean@oss.cyber.gouv.fr \
--cc=dmitry.kasatkin@gmail.com \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=roberto.sassu@huawei.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®