Skip to content

restrict embedding to embeddable signature types - #325

Merged
twiss merged 1 commit into
ProtonMail:mainfrom
knQzx:reject-nested-embedded-sig
Aug 14, 2026
Merged

twiss merged 1 commit into
ProtonMail:mainfrom
knQzx:reject-nested-embedded-sig

Conversation

@knQzx

@knQzx knQzx commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

An embedded signature can itself carry an embedded signature, allowing unbounded recursion during parsing. This rejects nesting beyond one level.

@andrewgdotcom

andrewgdotcom commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

I proposed something with similar effect here: https://datatracker.ietf.org/doc/html/draft-gallagher-openpgp-signatures#name-recursive-embedding-inside-

It differs from this patch by classifying signature types as "embeddable" and "non-embeddable" and then only permits embeddable signature types to be embedded in non-embeddable types, thus preventing infinite recursion without counting nesting.

@knQzx
knQzx force-pushed the reject-nested-embedded-sig branch from f9a6868 to 4a1fbbd Compare August 12, 2026 18:21
@knQzx

knQzx commented Aug 12, 2026

Copy link
Copy Markdown
Contributor Author

good catch, thanks for the link. reworked it to follow that model - an embedded signature must be an embeddable type, and embeddable types can't themselves carry an embedded signature, so the recursion gets rejected while parsing the inner sig without counting depth. pushed an update

@knQzx knQzx changed the title reject nested embedded signatures restrict embedding to embeddable signature types Aug 12, 2026
@twiss

twiss commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Hi 👋 Thanks for the PR! However, this is now somewhat conflating adding (partial) support for the Third-Party Confirmation signature type, and fixing the original issue you pointed out. Since we don't support Third-Party Confirmation signatures for now, we can just check that the embedding signature is not a Primary Key Binding signature and call it a day, IMHO.

@andrewgdotcom

Copy link
Copy Markdown
Contributor

To be fully effective, it needs two checks:

  1. a primary key binding signature cannot contain an embedded signature
  2. an embedded signature must be a primary key binding signature

@twiss

twiss commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Yeah, but the second one we already have:

if sigType := sig.EmbeddedSignature.SigType; sigType != SigTypePrimaryKeyBinding {
return nil, errors.StructuralError("cross-signature has unexpected type " + strconv.Itoa(int(sigType)))
}

@andrewgdotcom

Copy link
Copy Markdown
Contributor

Aha, I didn't understand what you meant by "embedding signature". Yes, agreed. 🫣

@knQzx

knQzx commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

hmm, makes sense. give me a few minutes, i'll try cutting it down to just that check

@knQzx

knQzx commented Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

pushed. just the primary key binding check now, dropped the third-party confirmation bits and left the existing embedded-type check alone

@knQzx
knQzx force-pushed the reject-nested-embedded-sig branch from 4a1fbbd to 9398663 Compare August 13, 2026 18:37

@twiss twiss left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@twiss
twiss force-pushed the reject-nested-embedded-sig branch from 9398663 to 8fe6e4b Compare August 14, 2026 15:06
@twiss
twiss merged commit d697e70 into ProtonMail:main Aug 14, 2026
9 checks passed
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.

3 participants