Skip to content

Ignore unkown algorithm jwks per RFC7517#728

Merged
anakinj merged 2 commits into
jwt:mainfrom
ewindisch:ewindisch/pqc
May 27, 2026
Merged

Ignore unkown algorithm jwks per RFC7517#728
anakinj merged 2 commits into
jwt:mainfrom
ewindisch:ewindisch/pqc

Conversation

@ewindisch
Copy link
Copy Markdown
Contributor

@ewindisch ewindisch commented May 27, 2026

According to RFC7517, unknown algorithms in JWKS should be ignored.

Adherence to this property allow for algorithm upgrade and rotation, and notably is leveraged by existing draft RFC for hybrid PQC. Wherein, a classical algorithm such as RS256 may be used, in addition to the new AKP-type algorithm. All known algorithms must be verified, but all unknown algorithms may be skipped, per RFC7517.

I have tested popular libraries and ruby-jwt is an outlier in its behavior:

Library Language Behavior with unknown kty: "AKP" in JWKS Result
jose v5.10 Node.js Skips unknown key, matches kid to RSA key PASS
PyJWT v2.13 Python PyJWKClient filters unknown keys, proceeds PASS
nimbus-jose-jwt Java (Spring) Silently ignores unsupported keys PASS
go-jose Go Returns ErrUnsupportedKeyType per-key, skips it PASS
ruby-jwt Ruby Throws JWT::JWKError: Key type AKP not supported FAIL

This change causes ruby-jwt to ignore unknown key types, and enables it to verify keys from signers who have adopted PQC type algorithms such as AKP as part of a hybrid scheme.

Description

This Pull Request changes/fixes this thing

Checklist

Before the PR can be merged be sure the following are checked:

  • There are tests for the fix or feature added/changed
  • A description of the changes and a reference to the PR has been added to CHANGELOG.md. More details in the CONTRIBUTING.md

@ewindisch ewindisch force-pushed the ewindisch/pqc branch 2 times, most recently from b4ac8a0 to b4b1fb8 Compare May 27, 2026 13:24
@anakinj
Copy link
Copy Markdown
Member

anakinj commented May 27, 2026

Nice catch and fix. Took a while to find the the reference in the RFC. I guess you are pointing to this statement:

Additional members can be present in the JWK Set; if not understood
by implementations encountering them, they MUST be ignored.

There seems to be some Ruby 2.5 incompatibilities, as it should be trivial to support outdated rubies I still think its valuable to keep the support.

@ewindisch
Copy link
Copy Markdown
Contributor Author

Great. I'll fix the Ruby 2.5 support and update the PR.

Comment thread CHANGELOG.md Outdated
- Fix compatibility with the openssl 4.0 gem [#706](https://github.com/jwt/ruby-jwt/pull/706)
- Test against Ruby 4.0 on CI [#707](https://github.com/jwt/ruby-jwt/pull/707)
- Fix type error when header is not a JSON object [#715](https://github.com/jwt/ruby-jwt/pull/715) - ([@304](https://github.com/304))
- Fix rejection of unknown algorithms from JWKs for RFC compliance and pquip [#728](https://github.com/jwt/ruby-jwt/pull/728)
Copy link
Copy Markdown
Member

@anakinj anakinj May 27, 2026

Choose a reason for hiding this comment

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

Oh, I've apparently forgot to start the next iteration after the security fix last week. The changelog entry would need to go into that when its there.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is now done and it landed on main. You could move your entry to the next release in the changelog

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. I was confused what to do in regard to editing the CHANGELOG, I appreciate the clarity.

According to RFC7517, unknown algorithms in JWKS should be ignored.

Adherence to this property allow for algorithm upgrade and rotation,
and notably is leveraged by existing draft RFC for hybrid PQC.
Wherein, a classical algorithm such as RS256 may be used, in addition
to the new AKP-type algorithm. All known algorithms must be verified,
but all unknown algorithms may be skipped, per RFC7517.

I have tested popular libraries and ruby-jwt is an outlier in its
behavior:

| Library | Language | Behavior with unknown kty: "AKP" in JWKS | Result |
|---|---|---|---|
| jose v5.10 | Node.js | Skips unknown key, matches kid to RSA key | PASS |
| PyJWT v2.13 | Python | PyJWKClient filters unknown keys, proceeds | PASS |
| nimbus-jose-jwt | Java (Spring) | Silently ignores unsupported keys | PASS |
| go-jose | Go | Returns ErrUnsupportedKeyType per-key, skips it | PASS |
| ruby-jwt | Ruby | Throws JWT::JWKError: Key type AKP not supported | FAIL |

This change causes ruby-jwt to ignore unknown key types, and enables
it to verify keys from signers who have adopted PQC type algorithms such
as [AKP as part of a hybrid
scheme](https://datatracker.ietf.org/wg/pquip/about/).
@anakinj anakinj merged commit 16c9eb1 into jwt:main May 27, 2026
15 checks passed
@ewindisch ewindisch deleted the ewindisch/pqc branch May 27, 2026 19:29
@anakinj
Copy link
Copy Markdown
Member

anakinj commented May 27, 2026

Thank you for noticing and going the extra mile to fix the behavior. 🙌

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