Skip to content

v7 discussion #76

Closed
Closed

Description

@Keats

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

  1. Jake-Shadle commented on Feb 5, 2019

    @Jake-Shadle
    Contributor

    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, ring and untrusted, 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.

  2. briansmith commented on Feb 5, 2019

    @briansmith
    Contributor

    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).

  3. briansmith commented on Feb 5, 2019

    @briansmith
    Contributor

    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.

  4. Keats commented on Feb 5, 2019

    @Keats
    OwnerAuthor

    i recommend instead just have the user use ring's parsing API to construct a key and pass it into jsonwebtoken.

    That would require users having to add ring and untrusted to 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

  5. briansmith commented on Feb 5, 2019

    @briansmith
    Contributor

    That would require users having to add ring and untrusted to their list of direct dependencies, which isn't great in terms of UX.

    In ring, we're gradually phasing out the use of untrusted in 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.

    Also if we somehow decide to have an openssl backend in addition of ring it would make things complicated

    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.

  6. Keats commented on Feb 6, 2019

    @Keats
    OwnerAuthor

    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.

    Right now I need to bump the major version of this crate everytime ring gets a major version. If the symbols versioning PR is merged, I won't need to bump it all the time. However if ring is exposed, I would have to bump on every breaking change even after that.

  7. manifest commented on Feb 15, 2019

    @manifest

    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.

    @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.

  8. manifest commented on Mar 9, 2019

    @manifest

    @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.

  9. Keats commented on Mar 9, 2019

    @Keats
    OwnerAuthor

    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?

  10. manifest commented on Mar 9, 2019

    @manifest

    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.

  11. manifest commented on Mar 9, 2019

    @manifest

    An intermediate release would have to be a major one sadly

    Maybe, we can have v6 with ES-256 support, and other features in v7? I mean the version is just a number.

  12. Keats commented on Mar 14, 2019

    @Keats
    OwnerAuthor

    Maybe, we can have v6 with ES-256 support, and other features in v7? I mean the version is just a number.Maybe, we can have v6 with ES-256 support, and other features in v7? I mean the version is just a number.

    We could but it is annoying for end users to have frequent breaking changes :/

  13. manifest commented on Mar 14, 2019

    @manifest

    We could but it is annoying for end users to have frequent breaking changes

    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.

  14. 60 remaining items

  15. Dowwie commented on Jan 13, 2020

    @Dowwie
    Contributor

    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.

  16. Keats commented on Jan 13, 2020

    @Keats
    OwnerAuthor

    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:

    • none is not supported
    • it requires at least one algorithm to be set when decoding, if the alg in the header doesn't match one in the Validation struct, it will fail before doing actually anything
  17. rib commented on Jan 13, 2020

    @rib

    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 Validation allowing 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?

  18. Dowwie commented on Jan 13, 2020

    @Dowwie
    Contributor

    @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"

  19. Keats commented on Jan 13, 2020

    @Keats
    OwnerAuthor

    #113 has been updated with encode/decode key type checking wrt the algorithm + base64 secrets

    Anything else missing?

  20. Keats commented on Jan 17, 2020

    @Keats
    OwnerAuthor

    Ok this got merged, anything else missing for downstream users? cc @rib / @JTKBowers

  21. LeviSchuck commented on Jan 17, 2020

    @LeviSchuck
    Contributor

    I am quite excited and happy to have contributed.

  22. Keats commented on Jan 17, 2020

    @Keats
    OwnerAuthor

    @LeviSchuck you did the biggest bits of this release!

  23. Dowwie commented on Jan 21, 2020

    @Dowwie
    Contributor

    @Keats looks good to me. can you cut another alpha release? I want to run against tests..

  24. Keats commented on Jan 21, 2020

    @Keats
    OwnerAuthor

    I've just pushed beta.1 to crates.io

  25. Keats commented on Jan 25, 2020

    @Keats
    OwnerAuthor

    I'll release it on Monday if nothing else comes up

  26. Dowwie commented on Jan 27, 2020

    @Dowwie
    Contributor

    looks good from here, so far..

  27. Keats commented on Jan 28, 2020

    @Keats
    OwnerAuthor

    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.

  28. Keats commented on Jan 29, 2020

    @Keats
    OwnerAuthor

    It's on crates.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions