Skip to content

Fix signature validation bypass via KeyInfo injection#658

Closed
aashh wants to merge 2 commits intocrewjam:mainfrom
aashh:fix/issue-10
Closed

Fix signature validation bypass via KeyInfo injection#658
aashh wants to merge 2 commits intocrewjam:mainfrom
aashh:fix/issue-10

Conversation

@aashh
Copy link

@aashh aashh commented Feb 9, 2026

Signature validation conditionally stripped KeyInfo from the response signature: only when no X509Certificate was present. This left a bypass where an attacker could inject their own certificate in the signature's KeyInfo element.

Additionally, when an IdP has multiple signing certificates in its metadata, goxmldsig's automatic cert selection only works when there's exactly one root certificate in the store. With multiple certs, validation would fail even for valid signatures.

Fix:

  1. Always strip KeyInfo before validation to prevent attacker-controlled certificates from being used
  2. Try each metadata cert individually by adding them one at a time to the validation store, since goxmldsig can only auto-select when there's one root

Changes:

  • service_provider.go: Unconditionally remove KeyInfo, loop over IdP certs
  • service_provider_test.go: Add KeyInfo injection test and multi-cert IdP test

Testing:

  • KeyInfo injection attack (attacker cert in signature): rejected
  • Multi-cert IdP metadata: valid signature accepted
  • Single-cert IdP (existing behavior): still works
  • All existing tests pass

Fixes aashh#10

Previously KeyInfo was only stripped when X509Certificate was absent,
leaving a bypass if an attacker included a dummy cert. Now KeyInfo is
unconditionally removed and each trusted certificate from IdP metadata
is tried individually, since goxmldsig only auto-selects from the
certificate store when there is exactly one root.
@aashh aashh requested a review from crewjam as a code owner February 9, 2026 19:25
@aashh
Copy link
Author

aashh commented Feb 9, 2026

Closing this PR — the cert loop had a variable scoping bug that broke XSW detection tests. I also overestimated the security impact; goxmldsig already validates KeyInfo certs against the trusted store. Will resubmit with a corrected fix and description later.

@aashh aashh closed this Feb 9, 2026
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.

Signature KeyInfo not always stripped before validation

1 participant