Repository navigation
Question : does find_key() compare kty against "ocy" instead of "oct" for kid-less HS256..? #1753
Unanswered
AdeshDeshmukh
asked this question in
Q&A
Replies: 1 comment
|
I checked this against current master and it reads exactly as you describe. Line 1623 of Since you already have a harness that shows a kid-less HS256 token against a JWKS failing before the fix and passing after, it's probably worth sending this as a PR with the one-character change, plus a test in |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi @michaelrsweet,
I've been tracing the 2.5 JWT/OAuth path — specifically how cupsOAuthGetTokens() (cups/oauth.c:1397) validates id_token via cupsJWTHasValidSignature() → find_key().
In find_key() (cups/jwt.c:1623), the kid-less branch reads :
if (((!curkty || !strcmp(curkty, "ocy")) && alg >= CUPS_JWA_HS256 ...
The generator in the same file (cupsJWTMakePrivateKey(), cups/jwt.c:1043) writes kty = "oct", the fixture in cups/testjwt.c:41 uses "kty":"oct", and RFC 7518 §6.4 registers "oct" — so a real JWKS like {"keys":[{"kty":"oct","k":"..."}]} with a kid-less HS256 JWT never matches here. find_key falls through with the set object, make_signature() (:2105) looks for "k" on the set, gets NULL, and the valid token is rejected. I confirmed this with a small local harness wrapping cupsJWTMakePrivateKey(HS256) in a {"keys":[...]} set — HasValidSignature returns false before the one-char fix, true after; wrong-type set (RSA key + HS256) still correctly fails.
Existing testjwt misses it because single-key objects bypass the set branch at :1588. I checked for overlap — grep -rn '"ocy"' shows only this line, and neither the #1680 HMAC work nor #1232/#1385/#1556/#1609 mention it.
Fix I'd propose is just s/"ocy"/"oct"/ on that line, keeping the !curkty fallback and leaving RSA/EC arms untouched, plus a testjwt case for kid-less oct set (pass) and wrong-type set (fail).
want me to file this with the patch + test..?
All reactions