Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: auth bypass#5

Closed
shreemaan-abhishek wants to merge 1 commit into
api7:masterfrom
shreemaan-abhishek:fix/auth-bypass
Closed

fix: auth bypass#5
shreemaan-abhishek wants to merge 1 commit into
api7:masterfrom
shreemaan-abhishek:fix/auth-bypass

Conversation

@shreemaan-abhishek

Copy link
Copy Markdown
Contributor

This PR fixes the authentication bypass issue in cdbattags/lua-resty-jwt#61.

Comment thread lib/resty/jwt.lua
local iv = _M:jwt_decode(encoded_iv)
local signature_or_tag = _M:jwt_decode(encoded_auth_tag)
local basic_jwe = {
typ = str_const.JWE,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you add this, seems meanless

Comment thread lib/resty/jwt.lua
Comment on lines +835 to +838
if alg == nil then
jwt_obj[str_const.reason] = "No algorithm supplied"
return jwt_obj
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not check like this, there is already corresponding judgement logic below

  else
    jwt_obj[str_const.reason] = "Unsupported algorithm " .. alg
  end

We just fix the bug when alg == nil

  else
    jwt_obj[str_const.reason] = "Unsupported algorithm " .. (alg or "nil")
  end

Comment thread lib/resty/jwt.lua
Comment on lines +554 to 556
if jwt_obj.typ == str_const.JWE or (jwt_obj.typ == nil and (typ == str_const.JWE or jwt_obj.header.enc)) then
return sign_jwe(self, secret_key, jwt_obj)
end

@juststillthinking juststillthinking Jul 13, 2023

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way to check if the obj is jwe is not correct. The jwe obj has five dot in the body, i think checking this is more appropriate

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the function sign_jwe is not correct too, you should refactor the function

Comment thread lib/resty/jwt.lua
end

local basic_jwt = {
typ = str_const.JWT,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@Sn0rt Sn0rt closed this Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants