-
-
Notifications
You must be signed in to change notification settings - Fork 175
go 1.19 panic
due to missing EC key validation
#840
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
Comments
I made #841 which fixes |
Yeah, I patched jwe.Encrypt as well. Please let me know if this fixes your problems |
Cool. I think you know the drill: I'll merge, but I'm putting off a release until I either get enough stuff or I feel comfortable that nothing else broke or is missing. Thanks for the headsup! |
This was referenced Nov 25, 2022
Closed
Closed
This was referenced Mar 21, 2023
Closed
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.
The following is
ExampleJWX
from the README slightly modified to read an EC key whose x-coord has been moved out of the P-256 curve.go1.19
crypto/elliptic
reacts quite drastically when it finds out it's operating on invalid curve points (see release notes):"Operating on invalid curve points (those for which the IsOnCurve method returns false, and which are never returned by Unmarshal or by a Curve method operating on a valid point) has always been undefined behavior and can lead to key recovery attacks. If an invalid point is supplied to Marshal, MarshalCompressed, Add, Double, or ScalarMult, they will now panic."
In fact, compiling and running the snippet above with go1.19 panics like this:
Note that this same code compiled against 1.18 or earlier versions would just fail verification.
The trouble is this new behaviour makes it trivial to crash/DoS a verification service built on top of jwx.
BCP225 says:
"Some cryptographic operations [...] take inputs that may contain invalid values. This includes points not on the specified elliptic curve or other invalid points (e.g., [Valenta], Section 7.1). The JWS/JWE library itself must validate these inputs before using them, or it must use underlying cryptographic libraries that do so (or both!)."
so it'd seem right for jwx to do the input validation, at
jwk.ParseKey
,jwk.PublicKeyOf
orjwt.Parse
.The text was updated successfully, but these errors were encountered: