Repository navigation
Description
There are quite a few changes happening in the PRs: more input format for RSA (#69, #74), ECDSA signing & verification (#73) as well as some Validation changes.
I have already removed the iat check in the next branch since it isn't something that should be checked.
Right now, Validation::algorithms is a vec. I don't remember why but it shouldn't be the case, it should be an algorithm: Algorithm instead, I will accept a PR for that or do it myself later.
#69 also adds a standalone verify_rsa fn, which I'm wondering if we can somehow streamline it with the rest of the crate.
Since Rust doesn't have default parameters, we always have to pass a Validation struct currently. Maybe we can put the decoding onto this struct instead so you get something like:
// currently
let token = decode::<Claims>(&token, "secret".as_ref(), &Validation::default())?;
// possible
// `JwtDecoder` has the same fields as the current `Validation`
let token = JwtDecoder::default().decode_hs256::<Claims>(&token, "secret".as_ref())?;This way we don't have a single function where we are trying to fit all arguments inside and the user has to select explicitely which decode fn to use. This solves the vec of algorithms at the same time and allows having better documentation for each. The downside is duplication of those functions/docs for the various digest values (decode_hs256, decode_hs384, decode_hs512 for each algo).
Any other ideas/criticisms/things missing?
ccing the people involved in various issues/PRs recently
@AaronFriel @jbg @Jake-Shadle @matthew-nichols-westtel @greglearns
Activity
Jake-Shadle commentedon Feb 5, 2019
I only became aware of this lib yesterday because of the bug I was tracking down, and while #74 works, it's not what I would call clean.
So my one thought looking at this code only briefly was that it might be nice to be able to expose some helpers for deserializing the RSA key based on the user knowledge and passing that key down to the API rather than the current method of just trying both. The reason I say helpers would be nice instead of just passing the key directly is that would require the user adding 2 new dependencies,
ringanduntrusted, though another option would of course to be to expose the types and functions needed from those crates as part of the public API of this lib.briansmith commentedon Feb 5, 2019
In my future plans for ring, I expect the user will be able to create keys in ways other than reading them from byte arrays (files). For example, some users may want to generate a private key in memory and never serialize it. Or, we may support importing keys from the operating system where we never have the raw bytes of the key. And, I think once we have that functionality, people will want to use it with a library like this. So IMO it would be better to delegate all the key object creation to ring other than PEM parsing (since ring doesn't do PEM).
briansmith commentedon Feb 5, 2019
In other words, rather than having a PKCS#8 parsing API in jsonwebtoken, and a "raw DER" parsing API here, i recommend instead just have the user use ring's parsing API to construct a key and pass it into jsonwebtoken.
Keats commentedon Feb 5, 2019
That would require users having to add
ringanduntrustedto their list of direct dependencies, which isn't great in terms of UX.Also if we somehow decide to have an openssl backend in addition of ring it would make things complicated
briansmith commentedon Feb 5, 2019
In ring, we're gradually phasing out the use of
untrustedin the API. Maybe that will be done in ring 0.15. I don't think it's problematic for people who want to use ring to use use ring's API to construct the key used. That seems much better to me than having this crate (and every crate that uses ring) duplicate ring's API to hide the fact that ring is used.I personally think that would hurt the value proposition of the crate and would be a lot of work, so I wouldn't do it. But obviously I'm biased.
Keats commentedon Feb 6, 2019
Right now I need to bump the major version of this crate everytime
ringgets a major version. If the symbols versioning PR is merged, I won't need to bump it all the time. However ifringis exposed, I would have to bump on every breaking change even after that.manifest commentedon Feb 15, 2019
@briansmith In our case we have web services written in Rust, Erlang, Ruby and Go. They need to use a same key to verify access tokens in incoming requests. If I generate keys using Ring, I'll get a keypair in pkcs8 DER format instead of just a private key that is, for instance, is used by Erlang crypto library. I will need to parse the keypair in the applications and that seems to me as not a good idea. Sadly there is currently no way to use the same pkcs8 DER key for all the applications, that's why we currently use openssl to generate PEM keys to consume by Erlang apps and pcks8 DER (from the PEM keys) for Rust apps.
Ideally, I would like to have a command line tool (because it just makes things easier for devops engineers) that allow to generate keys in a common format. Maybe at some day such a command line tool will be based on Ring project if we make it possible.
manifest commentedon Mar 9, 2019
@Keats it seems that it'll take some time to implement all described features for
v6. Can we have an intermediate release with ES256 support before that? Working with the branch creates a bunch of dependencies-related issues.Keats commentedon Mar 9, 2019
An intermediate release would have to be a major one sadly. However I can probably merge that PR in the v6 branch and you shouldn't have dependencies issues at that point no?
manifest commentedon Mar 9, 2019
Merging into master without bumping a new version of crate won't make a difference. Dependencies issues I'm talking about exist because of some other crates are using the current version of jsonwebtoken crate.
manifest commentedon Mar 9, 2019
Maybe, we can have v6 with ES-256 support, and other features in v7? I mean the version is just a number.
Keats commentedon Mar 14, 2019
We could but it is annoying for end users to have frequent breaking changes :/
manifest commentedon Mar 14, 2019
It always better to have releases available as soon as possible in my opinion. You always can stay on a previous major release, If you don't care about new features. It also shouldn't cause any problem if you're using simversion properly.
60 remaining items
Dowwie commentedon Jan 13, 2020
The None-attack mentioned in that article is addressed by resolving to one of Algorithm's supported variants. None is not one of the supported variants. A supported algorithm must be used. Agreed?
As for the "algorithm misdirection" scenario, this requires analysis and literally stepping through much of the flow of
jsonwebtoken. I don't think that the Auth0 author's claim is true here but the only way to know for sure is to verify.. verification.Keats commentedon Jan 13, 2020
I think the multiple alg is there when you know the alg family but not sure which one. Ie you might put [RSA256, RSA384, RSA512], so in general a single family. BUT someone could put [RSA256, EC256] and then the key check would fail if we check all members. Which is probably fine.
This crate is not vulnerable to the issue in the article:
noneis not supportedValidationstruct, it will fail before doing actually anythingrib commentedon Jan 13, 2020
yeah, I was mainly pointing to the article just to support the idea of erring on the side of caution and avoiding unnecessary flexibility with regards to letting multiple algorithms to get accepted within one verification pass.
I suppose if someone created a
Validationallowing HMAC and RSA (or EC) they could open themselves up to this vulnerability. I'm not sure why you would do that, but the api does seem to allow you to shoot yourself in the foot and maybe it would be better if it just wasn't possible to even make that mistake?Dowwie commentedon Jan 13, 2020
@rib here's plausible scenario as to why a programmer would do that: a monolith server that for internal communication among servers uses RS512 where as web clients receive HS256
As Keats confirmed, a server that supports both algorithms still is not exposed to the "algorithm misdirection"
Keats commentedon Jan 13, 2020
#113 has been updated with encode/decode key type checking wrt the algorithm + base64 secrets
Anything else missing?
Keats commentedon Jan 17, 2020
Ok this got merged, anything else missing for downstream users? cc @rib / @JTKBowers
LeviSchuck commentedon Jan 17, 2020
I am quite excited and happy to have contributed.
Keats commentedon Jan 17, 2020
@LeviSchuck you did the biggest bits of this release!
Dowwie commentedon Jan 21, 2020
@Keats looks good to me. can you cut another alpha release? I want to run against tests..
Keats commentedon Jan 21, 2020
I've just pushed beta.1 to crates.io
Keats commentedon Jan 25, 2020
I'll release it on Monday if nothing else comes up
Dowwie commentedon Jan 27, 2020
looks good from here, so far..
Keats commentedon Jan 28, 2020
I didn't forget about it, I got a new laptop yesterday and I was getting some weird rustc crash which might be resolved now.
Keats commentedon Jan 29, 2020
It's on crates.io