# JWT authentication bypass via unverified signature

## Description

This lab uses a JWT-based mechanism for handling sessions. Due to implementation flaws, the server doesn't verify the signature of any JWTs that it receives.

To solve the lab, modify your session token to gain access to the admin panel at `/admin`, then delete the user `carlos`.

You can log in to your own account using the following credentials: `wiener:peter`

## Solution

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FUSiZqiG9tcQmIgKlwJ1E%2Fimage.png?alt=media&#x26;token=8da26317-859a-4443-9034-c68eb293acc1" alt=""><figcaption></figcaption></figure>

Go to login page and access as wiener user.

JWT extension reveal that there's a JWT token, obviously related to wiener user account

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FShLy9ujFey8fJbyoxrTJ%2Fimage.png?alt=media&#x26;token=ee2d567c-1c80-4767-ada5-77a053038f82" alt=""><figcaption></figcaption></figure>

```json
{"iss":"portswigger","exp":1742668339,"sub":"wiener"}
```

Send it to repeater and select JSON web Token tab to deep dive to it

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FHOw0s2mveVy2ok1bOX1j%2Fimage.png?alt=media&#x26;token=17a4a644-f87c-46b1-ae17-28d15ff3e67f" alt=""><figcaption></figcaption></figure>

Modify the sub field inserting: "administrator" (if the key field isn't compiled, is necessary to add it clicking to Sign button)

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2F37LdvxqQzJBCKgWU8iC4%2Fimage.png?alt=media&#x26;token=1ba6fbc4-c4d0-4ccd-a8be-4a760153df7b" alt=""><figcaption></figcaption></figure>

and click first on the **Send** button and then on **Following redirection** button

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2F7uAZucHSDXGuMWL9njJ0%2Fimage.png?alt=media&#x26;token=b3fff0c8-aa04-46c5-941d-7865e408de72" alt=""><figcaption></figcaption></figure>

authenticating us as administrator

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2F23S4urAm25NwcrsUCRnD%2Fimage.png?alt=media&#x26;token=ca63e421-d592-480f-82ad-662f0019089f" alt=""><figcaption></figcaption></figure>

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2F98S6hg7FxxFQFutAOLls%2Fimage.png?alt=media&#x26;token=be88e57f-67db-453d-921a-9e65f39e71fc" alt=""><figcaption></figcaption></figure>

Checking the response the admin panel's path is: `/admin`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FTAegFAsYBljFXVD96nZo%2Fimage.png?alt=media&#x26;token=f448bc12-9c9a-4bfa-8bef-6ed72bf6280e" alt=""><figcaption></figcaption></figure>

so we can move there via a GET request: `GET /admin HTTP/2`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2Fd7LALNgSchDBoarTwu79%2Fimage.png?alt=media&#x26;token=30776012-830c-4883-b62a-2d3e7f70ba1a" alt=""><figcaption></figcaption></figure>

analyzing the response, we see that the request to delete the user Carlos is the following: `GET /admin/delete?username=carlos HTTP/2`

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2F5RkvZQehnF42mqHhzE5R%2Fimage.png?alt=media&#x26;token=b756046a-28cc-4ae3-b45c-e3fd99a83e6c" alt=""><figcaption></figcaption></figure>

So, Send and click to Following redirection to delete it and complete the lab.

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FBw8Vk2nfArDV0oGS3qJR%2Fimage.png?alt=media&#x26;token=f1f876b3-c81f-45e4-b1b4-d6ec7a4474e9" alt=""><figcaption></figcaption></figure>

<figure><img src="https://677614291-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrRWtuMw6xkkeDjZfkcWC%2Fuploads%2FBPLqZ4QIinVovNs3S29n%2Fimage.png?alt=media&#x26;token=8c607c8a-6fbd-4f29-bf0d-c2a3657a8c3d" alt=""><figcaption></figcaption></figure>
