Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JWT (JSON Web Token) if someone sniff the token, could send the same Post?

Tags:

json

rest

token

jwt

What happend if someone sniff the network and catch my entire request from my REST with the token? This person could send again the same packet and Impact without any problem right? Of course he's not going to know from which user is that packet, but he could impact anyway right? is this possible? How can lead with this situation?

Thanks! Matt.

like image 915
Matias Micenmacher Avatar asked Jul 18 '16 19:07

Matias Micenmacher


People also ask

Can JWT token be sniffed?

JWT's are often not encrypted so anyone able to perform a man-in-the-middle attack and sniff the JWT now has your authentication credentials. This is made easier because the MITM attack only needs to be completed on the connection between the server and the client.

What if someone gets my JWT token?

For instance, if an attacker gets hold of your JWT, they could start sending requests to the server identifying themselves as you and perform actions like making service changes, user account updates, etc. Once an attacker has your JWT, it's game over.

When dealing with JSON Web Token JWT What is a claim?

Claims constitute the payload part of a JSON web token and represent a set of information exchanged between two parties. The JWT standard distinguishes between reserved claims, public claims, and private claims. In API Gateway context, both public claims and private claims are considered custom claims.

Can JWT token be reused?

there is a system where JWT tokens can be created without invalidating the other, they self-expire after 30 min. So I can get a JWT once, and then make a bunch of requests within 30 min, and if you continue making requests with the same JWT after 30 min, you'll get unauthorized.


2 Answers

What happend if someone sniff the network and catch my entire request from my REST with the token?

The JWT is the authentication token, so he could impersonate the user.

This person could send again the same packet and Impact without any problem right?

The same packet or any other because if has the authentication token. It is the same case as if the user had lost your username / password

Of course he's not going to know from which user is that packet, but he could impact anyway right?

Yes, he can know the user, it could know simply decoding the 'sub' field of the token. This field, as defined in RFC , identifies the principal that is the subject of the JWT. The attacker could use your own api to obtain or modify any information to which it has access

is this possible? How can lead with this situation?

Mainly use HTTPS to avoid man-in-the-middle and keep the tokens private. Set also expiration and renew tokens periodically

like image 192
pedrofb Avatar answered Nov 15 '22 11:11

pedrofb


Of course, the attacker can use the token and get the same access as the victim.

If you want to limit attacker's actions, you need to perform several conditions:

  1. Set expire time of the token as small as possible(5 min, 30 min, nor months neither years).
  2. Use refresh token to get a new token and update refresh token every time you update old token (and when user is logged in, no doubt)
  3. Use https (oh yes!)
  4. Do not store passwords, credit card numbers and any confidential informations in the token ( I'm shure, you know it :) )
like image 43
Dimitry Ivanov Avatar answered Nov 15 '22 12:11

Dimitry Ivanov