Kleopatra: do not create a S/MIME signed file when signing and encrypting folders (S/MIME or mixed)
Testing, HighPublic

Assigned To
Authored By
ebo
Fri, Jul 3, 12:16 PM

Description

sign + encrypt with S/MIME works as expected for a single file (output encrypted file .p7m and detached signature .p7s) but for multiple files or folders the output is two files of ~same size: one encrypted file and one which is only signed. This is an accident waiting to happen and needs to be changed.

Could we make a detached signature in this cases, too, like for the single files?
Otherwise we would need to disable choosing sign + encrypt for S/MIME and mixed sign/encrypt.
We want to disable S/MIME signing for folders and multiple files.
If encryption is used then one should never get an opaque-signed unencrypted file as one of the result files.
If encryption is not used then it should still be possible to create an opaque-signed archive. In this case the user is warned that the result is probably not what they expect.

Notes for testing:

  • Check S/MIME and mixed encryption with S/MIME as well as with OpenPGP signature.
  • This is what was implemented:
    • Disallow signing of archives in combination with S/MIME-only encryption because this would result in a signed but unencrypted archive (and a separate encrypted archive) and some people might share the signed archive assuming that it's also encrypted or that it's a detached signature (as in the case of a single file that's S/MIME signed and encrypted).
    • For the same reason also disallow S/MIME-signing of archives combined with any kind of encryption.

This was reported via the forum, see external link.

Edited according to the decision from 2026-07-13.
Edited to match the implementation because it's not sufficient to just disable S/MIME signing of archives.

Event Timeline

ebo created this object with edit policy "Contributor (Project)".

Could we make a detached signature in this cases, too, like for the single files?

No. The detached signature would sign an ephemeral archive. The signature could never be verified because the data that was signed doesn't exist as a file.

Combined sign & encrypt is not implemented for S/MIME:

  • For single files the files are encrypted as *.p7m files and detached signatures for the unencrypted files are created as *.p7s files.
  • For folders or multiple files an archive is created and this archive is encrypted as *.p7m file and and this archive is signed opaquely as *.p7s file.

I agree that the only sensible course of action is to disallow sign & encrypt for S/MIME because currently it doesn't do want one sensibly expects it to do.

Alternatively, we could make it more obvious that for S/MIME two (!) separate results are created.

Instead of disabling something (which gets complicated --see the notepad-- and the users will not understand why the button is disabled) I suggest to show a confirmation dialog that explains what is going to happen.

Nevertheless we should think about disallowing it eventually then. I can't see a usecase right now, where this combination would make enough sense for a general mode (as this still can be done with two operations). What would be the issue with first encrypting the tarball and then sign that resulting tar.gz.p7m to create a tar.gz.p7m.p7s?

What would be the issue with first encrypting the tarball and then sign that resulting tar.gz.p7m to create a tar.gz.p7m.p7s?

The main reason speaking against this is that this would be the opposite of what is done for OpenPGP where the data is first signed and then encrypted. And the reason for this is that you don't want to leak any information by adding a not encrypted signature.

The easiest fix is to enable the "exclusive" mode that we use for the notepad (and the clipboard) also for the Sign/Encrypt Files/Folder dialog. This will disable mixing of OpenPGP and S/MIME recipients (which is anyway misleading because in case of encryption the result is two separate encrypted files with mutually exclusive recipients). Moreover, for S/MIME, it will disable "combined" sign and encrypt.

The only downside is that some people might be confused that they don't find some certificates in the list of recipients because they are looking for an S/MIME certificate (without knowing that they are looking for S/MIME) while the dialog is in OpenPGP mode (and vice-versa).

Moreover, for S/MIME, it will disable "combined" sign and encrypt.

But also for single files, not only for archives?
I'd like to keep the capability for single files, which does work, if possible.

I don't know what you understand as "does work". For single files two completely separate things are done:

  1. A detached S/MIME signature for the unencrypted file is created.
  2. The unencrypted file is S/MIME encrypted.

There's nothing "combined" here. You get exactly the same result if you first S/MIME sign a file and then S/MIME encrypt a file (or vice versa).

This is radically different from how OpenPGP works where the file is first signed and then encrypted and the result is a single signed+encrypted file. In my opinion, it does not work at all for S/MIME (at least not how somebody knowing about OpenPGP sign+encrypt would expect it to work).

ebo set External Link to https://forum.gnupg.org/t/sicherheitsrisiko-bei-verwendung-von-signieren-und-verschlusseln-mit-s-mime-zertifikaten/7377.

Well at least the reporter was of the opinion that it worked. Depends on what one expects.

ebo mentioned this in Unknown Object (Maniphest Task).Mon, Jul 13, 9:13 AM

We discussed it and decided that we want to keep the sign+encrypt option for S/MIME and single files. But for folders (and multiple files) we want to disable S/MIME signing. If people need to sign an archive, they have to create it before signing (or signing+encrypting).

Reason for the decision: gpgsm does - in contrast to gpg - not allow combined sign+encrypt, which makes the process to complex when adding archiving on top.

ikloecker moved this task from Backlog to WIP on the gpd5x board.
ebo updated the task description. (Show Details)
ebo renamed this task from Kleopatra: do not create a signed file when signing and encrypting folders (S/MIME or mixed) to Kleopatra: do not create a S/MIME signed file when signing and encrypting folders (S/MIME or mixed).Mon, Jul 13, 11:51 AM
ebo assigned this task to ikloecker.
ebo updated the task description. (Show Details)

Instead of disallowing the creation of S/MIME signed archives Kleopatra disallows problematic combinations of the creation of signed and encrypted archives. Reasoning: If one tries to create an OpenPGP-signed and S/MIME-only encrypted archive then one also ends up with an opaquely signed unencrypted archive.

ikloecker changed the task status from Open to Testing.Wed, Jul 15, 1:55 PM
ikloecker mentioned this in Unknown Object (Maniphest Task).Mon, Jul 20, 9:22 AM

With Gpg4win-5.1.0-beta666 S/MIME signatures are only allowed without encryption enabled for archives, regardless of the encryption protocol. When signing with OpenPGP, only OpenPGP encryption is selectable, choosing an S/MIME key for encryption will disable signing. For sign only with S/MIME there is a warning message as intended, but twice, see T8350.
Combined *encryption* for different protocols still works.
Combined singing and encryption of *single* files still works.

So the result is as intended, but UX is not good in case of archives. This will need to be addressed in another ticket.