origranot / reduced.to

Free Modern URL Reducer. Make sure to share love by giving it a star.🌟 Have a great day!
https://reduced.to
MIT License
663 stars 279 forks source link

Security Vulnerability: Lack of Access Token Signature Verification #687

Open GuillemPM opened 7 months ago

GuillemPM commented 7 months ago

Description

Overview

Upon user login to the Reduced.to platform, an access_token is generated and stored as an HttpOnly cookie. However, the access_token lacks signature verification, enabling an attacker to manipulate the JWT token's payload. Exploiting this vulnerability allows unauthorized users to elevate their privileges by modifying the access_token cookie, granting them access to protected features, such as those restricted to ADMIN roles.

Steps to Reproduce

  1. Log in to Reduced.to.
  2. Obtain the access_token cookie.
  3. Decode the access_token payload.
  4. Modify the payload, specifically changing the role from USER to ADMIN.
  5. Update the access_token cookie with the manipulated payload.

Expected Behavior

Access tokens should be securely signed to prevent tampering. Any attempt to modify the token payload should result in invalidation of the token.

Actual Behavior

The access_token lacks signature verification, allowing an attacker to modify the payload and update the access_token cookie, thereby gaining unauthorized access to elevated roles and protected features.

Proposed Solution

Implement JWT signature verification for access/refresh tokens on server side to ensure their integrity and prevent tampering.

Screenshots

security1 security2 security3 security4

Additional information

No response

origranot commented 7 months ago

Hey @GuillemPM, I am so happy to hear from you!

You are right, there is no jwt signature check on the Qwik server. Although we are using the backend (nest) as our API and for database access, we do check the jwt over there.

image

You are right, visually you have an "admin" access but you can't do nothing with it. I think we can solve it using an internal shared library that handle authentication and JWT operation for both Qwik server and backend.

What do you think, do you want to work on that issue?

ymoukhli commented 7 months ago

Hello @origranot,

i can work on this issue if no one wants it.

origranot commented 7 months ago

Hello @origranot,

i can work on this issue if no one wants it.

@ymoukhli, Hey, That's sounds good, I assigned you to this issue 💯

GuillemPM commented 7 months ago

@origranot I've reviewed PR #698 and identified an issue with the frontend relying on the JWT payload to determine which menus are loaded. Here are two suggestions to address this:

I can help to extend more the idea of the preferred solution if needed.