Replies: 5 comments 6 replies
-
What are the implications for echo switching to https://github.com/golang-jwt/jwt with the next minor release (e.g. echo v4.5.0)? On the downside I see:
But:
For echo v5 we should consider an agnostic implementation, which is not bound to a specific JWT implementation or move the JWT middleware into it's own repo. |
Beta Was this translation helpful? Give feedback.
-
I think I am the main party pooper here for this change. As a explanation: I really feel that we are forced into breaking change this is not necessarily required. If you do not used that part of Now coming back to fix - even if library is changed I think one conceptional problem is still there. If you have coded if password == "mysecret" || password == "" {
login()
} and this problem is not fixable by any patch or library change on Echo side. anyway - the amount of created issues related to that is increasing and it is easier to change lib and be done with it. Lets wait a little for feedback end then go find . -type f -name "*.go" -print0 | xargs -0 sed -i '' -e 's/dgrijalva\/jwt-go/golang-jwt\/jwt/g' p.s. just a sidenote. there was interesting blogpost (also interesting podcast 4:13 ) about |
Beta Was this translation helpful? Give feedback.
-
for example I have an API /getProduct, i want to put two signkey (admin, user) to middleware JWT, It mean both user and admin can to access the API. HELP ME PLEASE |
Beta Was this translation helpful? Give feedback.
-
Hi, I love the echo framework but some things that took up a lot of my time are the following.
Can you possibly either update these or leave a link? or something? Cause this took up my weekend and I felt like I have had to learn a few libraries already. I just want some simple jwt custom claims middleware. This is starting to feel very javascripty. Now that I have had to spend a really lot of time with this, how about an example with the new library on the echo website like https://play.golang.org/p/09QfbAiL8ub |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
CVE-2020-26160
Because Echo has direct import from
dgrijalva/jwt-go
and we expose that our of our API with public fields/types we can not just replace that library. It would not be backwards compatible. This will change in V5 (or maybe sooner)Some remarks - Echo middleware is not using
aud
field validation and therefore is not directly affected.VerifyAudience
is optional method thatdgrijalva/jwt-go
does not call during ordinary token validation. Unless you have written custom check for it and even then you are affected only when you have made that check optionalIf you have used
VerifyAudience
in code like that you could be affected:Workarounds:
Use replace directive in
go.mod
in your projectreplace github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt v3.2.1
use
JWTConfig.ParseTokenFunc
to implement token parsing with library of your choosing.See https://echo.labstack.com/middleware/jwt/ for example. In that way you use JWT library to extract raw token from request and use
ParseTokenFunc
withgolang-jwt/jwt
to create token (and claims) with implementation that is affected by CVE.jwt.StandardClaims{}
asJWTConfig.Claims
value. Note:StandardClaims
can not marshall slices asaud
value (cast will panic and request will end with an error for client).Example:
Now about that vulnerebility - CVE-2020-26160
Summary from CVE:
dgrijalva/jwt-go
has 2 types of claimsaud
as string.aud
being string means that this struct is NOT affected. Marshalling slice to string will cause panic and request will return an error for clientaud
as interface{} meaning it can be anything (including slice of strings). This struct is affected.Aud checking code for
MapClaims
is:https://github.com/dgrijalva/jwt-go/blob/008eba19055c071829e8317937b39845a9d2019b/map_claims.go#L15
Actual code for
aud
verification part is here. Note if verificatin is made optional and aud is empty this function returnstrue
- meaningaud
claim was considered passed.https://github.com/dgrijalva/jwt-go/blob/008eba19055c071829e8317937b39845a9d2019b/claims.go#L93
If VerifyAudience second argument is to to true - meaning aud value is REQUIRED then method will never give us true when aud is array or empty in token.
Only way to have vulnerebility is to set VerifyAudience to OPTIONAL in code. But why on earth would you set this check to optional. If you try to summarize this to requirement it would be - application should verify token
audience
only when token constainsaud
. If token does not haveaud
claim consider this check passed. This would be similar as writing check for passwordsNote: to fake empty aud values you need to have token signed with valid key - if attacker has valid key why they would need to manipulate aud values?
In reality this is problem when you are using token signing keys for many applications (i.e. one key signs tokens meant for different "sites"/"applications" and attacker takes valid token from one site and uses it to requests resources on another site. where that token should not have this level of access)
anyway - this does not mean that problem does not exist at all and you are definetely better of with switching to https://github.com/golang-jwt/jwt in long run.
Beta Was this translation helpful? Give feedback.
All reactions