Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In
Continue with Google
Continue with Facebook
or use


Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here
Continue with Google
Continue with Facebook
or use


Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.


Have an account? Sign In Now

Sorry, you do not have a permission to ask a question, You must login to ask question.

Continue with Google
Continue with Facebook
or use


Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Stack Ask

Stack Ask Logo Stack Ask Logo

Stack Ask Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 5665
In Process
Nguyễn Thái Sơn
  • 0
Nguyễn Thái SơnProfessional
Asked: April 30, 20222022-04-30T03:31:35+00:00 2022-04-30T03:31:35+00:00In: Networking

Dùng JWT cảm thấy k an toàn

  • 0

Anh ơi, em dùng JWT nhưng cảm thấy k an toàn lắm, giả sử hacker chôm được token, dùng JWT thực hiện request chuyển tiền, đương nhiên JWT chưa hết expired time, liệu có cách nào bảo mật tốt hơn JWT người ta đang dùng k ạ

  • 5 5 Answers
  • 55 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

5 Answers

  • Voted
  • Oldest
  • Recent
  1. tvd12 Enlightened
    2022-04-30T14:47:22+00:00Added an answer on April 30, 2022 at 2:47 pm

    Hiện tại thì anh đang dùng sha256 token, token này sẽ được lưu vào db, trong trường hợp user phát hiện ra mình bị hack có thể logout toàn bộ account, tương đương với việc xoá token khỏi cơ sở dữ liệu, điều này sẽ làm token bị vô hiệu hoá. Tuy nhiên cái giá phải trả là hiệu năng sẽ bị giảm vì mỗi lần request là 1 lần gọi vào db để lấy thông tin token.

    • 2
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
    • Toàn Phạm Văn Beginner
      2022-06-07T04:15:52+00:00Replied to answer on June 7, 2022 at 4:15 am

      Hi A Dũng, nếu mình dùng token để lưu vào db thì sẽ tương tự như cách lưu sessionId ở phía DB đúng ko ạ? Trong t/h mình lưu token vào db thì a có hướng giải quyết nào cải thiện hiệu năng của việc check valid token ko ạ? E cảm ơn a đã chia sẻ ạ.

      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report
      • tvd12 Enlightened
        2022-06-07T13:14:26+00:00Replied to answer on June 7, 2022 at 1:14 pm

        1. Anh không rõ sessionId của em là gì nhưng nếu theo ý hiểu sessionId là 1 dạng token dành cho 1 phiên trong 1 khoảng thời gian thì anh đang thấy là có thể giống hoặc khác nhau. Giống ở chỗ là đều có thể dùng để xác thực được, còn khác là từ token em có thể tạo ra được sessionId và sessionId có thời gian tồn tại ngắn hơn và có thể cho 1 thiết bị.
        2. Cách tăng hiệu năng đơn giản nhất là dùng redis hoặc các memory cache engine để lưu token map với userId em ạ.

        • 1
        • Share
          Share
          • Share on Facebook
          • Share on Twitter
          • Share on LinkedIn
          • Share on WhatsApp
          • Report
        • Toàn Phạm Văn Beginner
          2022-06-08T10:23:32+00:00Replied to answer on June 8, 2022 at 10:23 am

          Em cảm ơn a đã chia sẻ.

          • 0
          • Share
            Share
            • Share on Facebook
            • Share on Twitter
            • Share on LinkedIn
            • Share on WhatsApp
            • Report
  2. Thành Lê Văn Beginner
    2022-05-03T16:23:36+00:00Added an answer on May 3, 2022 at 4:23 pm

    Nếu nói đến bị hacker lấy được JWT rồi thì khó lắm.  Vì nếu dùng JWT hoặc token thì hacker lấy được thì vẫn bị lỗi bảo mật thôi.

    Về mặt an toàn thì người phân tích nghiệp vụ, dev…. phải luôn luôn nói với mình rằng dữ liệu lưu ở trên client không bao giờ là an toàn, nó hoàn toàn có thể bị ăn cắp bởi hacker.. (Đến dữ liệu lưu trên server nhiều khi còn bị lộ nữa cơ mà)

    Còn cách thức phòng, giảm rủi do thì có nhiều cách.

    • Xác định một JWT cho một IP, nếu JWT được sử dụng bởi 1 IP khác thì sẽ không được chấp nhận.
    • Trên web thì đặt token lưu trữ ở cookies để tự động gửi lên bởi trình duyệt. Đặt cookie đó require https và sẽ nó là secure để không được đọc bởi js.
    • Trên điện thoại thì chặn root hoặc tạo VM ảo, tự xây dựng ngôn ngữ. để lữu trữ, mã hóa token này.
    • Tạo một token phụ mapping với JWT. Token phụ này lưu trữ trên server. Token này sẽ xác định vù JWT chưa hết hạn nhưng nó còn có thể được sử dụng hay không. Tùy logic sẽ kiểm tra thêm token phụ này nữa (Nên nhớ là tùy logic nghiệp vụ và độ bảo mật nhé, vì kiểm tra nhiều sẽ tốn tài nguyên call lên DB)
      • Ví dụ với API đọc thì kiểm tra JWT thôi, nhưng nếu là API viết thì kiểm tra token mapping JWT để xem còn được sử dụng hay không.

    Đây là 1 số cách xưa mình phát triển service authen mình đã triển khai.

    • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

You must login to add an answer.

Continue with Google
Continue with Facebook
or use


Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 581
  • Answers 1k
  • Best Answers 63
  • Users 299
  • Popular
  • Answers
  • monkey

    [Deep Learning] Làm thế nào để xác định được cái ...

    • 16 Answers
  • Tú Trần Anh

    [Ezyfox Server] Unity game client không gửi được command khi ...

    • 12 Answers
  • monkey

    [Go] khi nào go func được gọi?

    • 10 Answers
  • Nguyễn Thái Sơn
    Nguyễn Thái Sơn added an answer em cảm ơn, vậy mỗi câu truy vấn luôn có… June 24, 2022 at 4:31 pm
  • tvd12
    tvd12 added an answer Việc chuyển này cũng có nhiều khó khăn là nó… June 24, 2022 at 3:08 pm
  • tvd12
    tvd12 added an answer 1. Vì socket là giữ kết nối nên em sẽ… June 24, 2022 at 3:02 pm

Related Questions

  • Nguyễn Thái Sơn

    chọn giao thức mạng

    • 1 Answer
  • Nguyễn Thái Sơn

    vì sao ít dự án dùng SSL

    • 1 Answer
  • Nguyễn Thái Sơn

    socket với fire-forget

    • 1 Answer

Top Members

tvd12

tvd12

  • 65 Questions
  • 1k Points
Enlightened
monkey

monkey

  • 91 Questions
  • 620 Points
Enlightened
Nguyễn Thái Sơn

Nguyễn Thái Sơn

  • 148 Questions
  • 229 Points
Professional

Trending Tags

.net core abstract class analytics android ansible anti-flooding apache poi api async asyncawait atomicboolean backend backend nestjs bash script batch bean big project binding bitcoin blockchain blog boot-nodes branch british buffered build bundle c# cache caching callback career career path cast centos chat cloud cloud reliability commit company content-disposition contract cors cosmos css database datasource datastructure decentralized exchange deep learning design-pattern devops dex distraction programing docker download draw.io du học dữ liệu lớn eclip editor employee english erc20 erc721 eth ethereum ethereum login extensions exyfox ezyfox ezyfox-boot ezyfox-server ezyfoxserver ezyhttp facebook fe flutter freetank french front-end frontend fullstack fulltextsearch future game game-box game-room game-server get git go golang google grapql grpc guide hazelcast hibernate hibernateconfig html http https index indexing integration-test intellij interface interview io ipfs isolate issue it java javacore java core javascript java spring javaw java web job jpa js json jsp & servlet jvm jwt kafka keep promise kerberos keycloak kotlin language languague library load-balancing log log4j log4j-core login lưu trữ machine learning macos math maven merge messaging metamask microservice model mongo msgpack multiple tenant multithread multithreading mysql n naming naming convention netcore netty nft nft game nio nodejs non-blocking io opensource optimize orm pagination pancakeswap panic pgpool phỏng vấn pointer postgresql pre programming promise push message android python python unicode question queue rabbitmq reactive reactjs reactjs download recyclerview redis request resource rest roadmap ropssten ropsten rust rxjava schedule search security server shift jis singleton sjis slack smart contract socket soft delete sosanh spring spring-boot-test spring-jpa spring aop spring boot springboot spring data jpa spring redis spring security springsecurity springwebflux mysql sql sql server sse stackask storage stream structure trong spring boot system environment variables thread threadjava thymeleaf totp tracking location unit test unity upload file vector view volatile vue vue cli web3 web3 client webpack websocket windows 11 winforms work zookeeper

Footer

Stack Ask

Stack Ask is where Developers Ask & Answers. It will help you resolve any questions and connect you with other people.

About Us

  • Meet The Team
  • About Us
  • Contact Us

Legal Stuff

  • Terms of Service
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2021 Stack Ask. All Rights Reserved
Powered by youngmonkeys.org