Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid ARC-Seal when email contains existing sets #167

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

abeverley
Copy link

When creating the ARC-Seal, any existing sets in the email must be included in the seal. See https://www.rfc-editor.org/rfc/rfc8617#section-5.1.1

The existing code does not include existing sets and is thus creating invalid signatures in these circumstances. This PR includes them.

@flowerysong
Copy link
Contributor

I'm not sure this is correct, though the code structure's fairly complicated and I don't really have time right now to try to grok it fully.

This should already have been done by arc_canon_runheaders_seal(), I believe. I can certainly verify that my non-milter use of libopenarc has not had a problem generating valid seals when an email contains existing sets, so it feels like it's probably something more subtle than them never being included.

@abeverley
Copy link
Author

Thanks @flowerysong I see what you mean. If I get a chance I will have another look.

@abeverley
Copy link
Author

Yes - the problem is at this line:

if ((msg->arc_mode & ARC_MODE_VERIFY) != 0 &&

It only runs arc_canon_runheaders_seal() when verifying, not signing. Making it run during signing too fixes the problem.

I assume it's as simple as removing the condition for (msg->arc_mode & ARC_MODE_VERIFY) != 0, rather than adding a second condition for (msg->arc_mode & ARC_MODE_SIGN) != 0? (Which would presumably always be true?)

@flowerysong
Copy link
Contributor

Arguably that's a configuration error, and if you're signing messages that might already have ARC chains you should be setting the mode to ARC_MODE_VERIFY | ARC_MODE_SIGN.

I don't really feel like making that argument, though. Having a trap configuration that's maybe slightly more performant when you're purely a message originator but breaks for everyone else doesn't seem like a good idea.

@abeverley
Copy link
Author

Arguably that's a configuration error, and if you're signing messages that might already have ARC chains you should be setting the mode to ARC_MODE_VERIFY | ARC_MODE_SIGN.

I've actually got no mode defined at all in the configuration, so it's just the default value. From the manual: "If neither is specified, the operating mode will be inferred on a per-connection basis based on the entries in the InternalHosts list; connections from internal hosts will be assigned to signing mode, and all others will be assigned to verify mode".

So I guess it's automatically setting the mode to "sign", which then means arc_canon_runheaders_seal() is not executed.

I don't really feel like making that argument, though. Having a trap configuration that's maybe slightly more performant when you're purely a message originator but breaks for everyone else doesn't seem like a good idea.

Agreed - as it is the mode needs to include "verify" in order to properly "sign" ;-)

I'll take a look to see if there is any way to still execute conditionally, but it would seem to make sense to always run that code as it could be needed for verification or signing.

Thanks for your comments.

This fixes a bug whereby existing sets were not being included in a
signature and thus the signature was invalid.

This was only happening when Mode was undefined (default value) or only
signing. This meant that the code to verify existing sets was never
executed.

This commit removes the check for running the previous-set verification
function, to ensure that it is run regardless (if there are no previous
sets then arc_canon_runheaders_seal() is basically a no-op anyway.
@abeverley
Copy link
Author

Based on the above discussion, I have changed this PR to always verify previous ARC sets, regardless of the mode.

flowerysong pushed a commit to flowerysong/OpenARC that referenced this pull request Feb 6, 2024
This fixes a bug whereby existing sets were not being included in a
signature and thus the signature was invalid.

This was only happening when Mode was undefined (default value) or only
signing. This meant that the code to verify existing sets was never
executed.

This commit removes the check for running the previous-set verification
function, to ensure that it is run regardless (if there are no previous
sets then arc_canon_runheaders_seal() is basically a no-op anyway.

trusteddomainproject/OpenARC#167
futatuki added a commit to futatuki/OpenARC that referenced this pull request Sep 16, 2024
…_sets

 Fix invalid ARC-Seal when email contains existing sets

This fixes a bug whereby existing sets were not being included in a
signature and thus the signature was invalid.

This was only happening when Mode was undefined (default value) or only
signing. This meant that the code to verify existing sets was never
executed.

This commit removes the check for running the previous-set verification
function, to ensure that it is run regardless (if there are no previous
sets then arc_canon_runheaders_seal() is basically a no-op anyway.

trusteddomainproject#167
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants