Malformed token error with base64 encoded secret
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, node.js
- Lĩnh vực
- authentication, backend, security
Hướng nghiên cứu
Bắt đầu từ JWT verification API và tái hiện trường hợp HS256 bằng Buffer.from(process.env.JWT_KEY, 'base64') với token và secret được cung cấp. Xác định cách xử lý dự kiến đối với secret đã giải mã, sau đó bổ sung coverage cho việc tái hiện này và xác nhận rằng quá trình xác minh không còn báo malformed token.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Please do not report security vulnerabilities here. The Responsible Disclosure Program details the procedure for disclosing security issues.
Thank you in advance for helping us to improve this library! Please read through the template below and answer all relevant questions. Your additional work here is greatly appreciated and will help us respond as quickly as possible. For general support or usage questions, use the Auth0 Community or Auth0 Support. Finally, to avoid duplicates, please search existing Issues before submitting one here.
By submitting an Issue to this repository, you agree to the terms within the Auth0 Code of Conduct.
Description
Using a
base64encoded secret with an HS256 token generates aMalformed tokenerror. A full output of the error is as follows:
app_1 | Error: Malformed token
app_1 | at /usr/src/app/.build/src/auth/authController.js:54:27
app_1 | at step (/usr/src/app/.build/src/auth/authController.js:33:23)
app_1 | at Object.next (/usr/src/app/.build/src/auth/authController.js:14:53)
app_1 | at /usr/src/app/.build/src/auth/authController.js:8:71
app_1 | at new Promise (<anonymous>)
app_1 | at __awaiter (/usr/src/app/.build/src/auth/authController.js:4:12)
app_1 | at exports.handler (/usr/src/app/.build/src/auth/authController.js:47:45)
app_1 | at InProcessRunner.run (/usr/src/app/node_modules/serverless-offline/dist/lambda/handler-runner/in-process-runner/InProcessRunner.js:190:16)
app_1 | at processTicksAndRejections (internal/process/task_queues.js:97:5)
app_1 | at async LambdaFunction.runHandler (/usr/src/app/node_modules/serverless-offline/dist/lambda/LambdaFunction.js:355:20)
app_1 | at async Object.authenticate (/usr/src/app/node_modules/serverless-offline/dist/events/http/createAuthScheme.js:101:24)
app_1 | at async module.exports.internals.Manager.execute (/usr/src/app/node_modules/@hapi/hapi/lib/toolkit.js:45:28)
app_1 | at async module.exports.internals.Auth._authenticate (/usr/src/app/node_modules/@hapi/hapi/lib/auth.js:256:30)
app_1 | at async Request._lifecycle (/usr/src/app/node_modules/@hapi/hapi/lib/request.js:312:32)
app_1 | at async Request._execute (/usr/src/app/node_modules/@hapi/hapi/lib/request.js:221:9)
app_1 | offline: Authorization function returned an error response: (λ: auth)
Reproduction
- Generate a token and key from here: https://java.jsonwebtoken.io/ or https://jwt.io and set the secret to base64 encoded
- Add the secret key to your project.
- Pass a request with the generated JWT and watch it error out. Code as follows:
const valid = jwt.verify(
token,
Buffer.from(process.env.JWT_KEY, 'base64'),
{ algorithms: ['HS256'] }
)
Environment
Please provide the following:
- Version of this library used: 8.5.1
- Version of the platform or framework used, if applicable:
- Other relevant versions (language, server software, OS, browser): I'm using serverless-offline. This is a Lambda-based API
- Other modules/plugins/libraries that might be involved: While I was able to re-create this using both java.jsonwebtoken.io and jwt.io I was also able to recreate the issue using tokens and keys directly using JJWT in Springboot. Note: the generated secret and token does work from any of these sources when using it within the Springboot API. Also of note is that this is all running in Docker. Also of note if I generate a token from jwt.io w/out base64 encoding the key then this will work fine (w/out
Bufferobviously).
- Ngôn ngữ chính
- JavaScript
- Star
- 18.2k
- Fork
- 1.3k
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của auth0/node-jsonwebtoken
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
auth0/node-jsonwebtoken#1042 · 1 bình luận ·
-
`jwt.sign()` callback is executed twice for "The payload already has an "..." property" errors Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
auth0/node-jsonwebtoken#1000 · 2 bình luận · 1 reaction ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 65/100
auth0/node-jsonwebtoken#1046 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 10/100
auth0/node-jsonwebtoken#1034 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
auth0/node-jsonwebtoken#1032 ·
Tất cả issue của auth0/node-jsonwebtoken
Issue tương tự
-
Update HugeIcons library Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
antfu-collective/icones#398 ·
-
ECmail.com Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
wesbos/burner-email-providers#554 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
radiantearth/stac-browser#1023 ·
-
HMR stops working Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
components-web-app/docs#92 ·