@@ -98,3 +98,31 @@ token before using the same information. As checking HMAC signature is inexpensi
98
98
it does not slow down the request processing. A malicious user trying to fudge the
99
99
request will not be able to generate the same signature (due to missing signing
100
100
key).
101
+
102
+ Before you think that the above token can be brute forced, consider that someone
103
+ was able to generate a concatenated token that passes the sigining key check. But
104
+ the same brute forced string also representing a valid JSON in the first part, and
105
+ containing valid user details is too high a coincidence.
106
+
107
+ ### Prevent session hijacking
108
+
109
+ Apart from usual security measures like usage of SSL, generating a very-long session
110
+ key, the following are the few key things to prevent session hijacking:
111
+
112
+ * Store the IP of the incoming request when the JSON token is created first. For
113
+ every subsequent request, check that the IP of the next request is the same IP as
114
+ mentioned in the JSON token. However, do note that this may break users accessing
115
+ your service over the [ TOR] ( https://www.torproject.org/ ) network. Also, this may
116
+ not prevent malicious users using the same egress IP or on the same network.
117
+
118
+ * An alternate mechanism to bind the request to the IP, is to bind the request to
119
+ a [ browser fingerprint] ( https://en.wikipedia.org/wiki/Device_fingerprint ) . This
120
+ makes it difficult for a malicious user to have the exact same browser, machine and plugin
121
+ configuration as the host, to have the same browser fingerprint being generated.
122
+
123
+ * Using a [ nonce] ( https://en.wikipedia.org/wiki/Cryptographic_nonce ) token with
124
+ every request and changing that on server side with every subsequent request. This
125
+ ensures that the malicious user has a very small window to align himself with the
126
+ server. This will invalidate the session of the actual user immediately, which would
127
+ force him/her to sign-in again. Thus, effectively invalidating the malicious user
128
+ session.
0 commit comments