improve session hashing when detecting modified sessions
See original GitHub issueThere is an issue in hash function
https://github.com/expressjs/session/blob/master/index.js#L582
simple JSON.stringify
is not safe to use as when session contains an object with multiple properties inside (user
for example with id
, name
, position
properties). JSON.stringify can return different string (id, name, position
or position, id, name
). We need to do safe object keys sorting before serializing or use some kind of safe object hashing (e.g. https://github.com/puleos/object-hash)
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Session Management - OWASP Cheat Sheet Series
Web applications can create sessions to keep track of anonymous users after the very first user request. An example would be maintaining the...
Read more >Session Identification Hashing - How to make it more Secure ...
I am using getFingerPrint() to generate a session hash using user agent + salt + ip address, and _isSuspicious() to check the fingerprint ......
Read more >Cookie for a Thought - How to Manage HTTP Sessions
It's a common technique to create a session ID by hashing strings, including time of authentication, remote user IP, etc.
Read more >Store password hash in session. Good Idea? - Stack Overflow
Store the password hash (as it is in the DB) in the session upon login and validate it against the DB hash on...
Read more >Everything You Ever Wanted to Know About Session ...
In this article, you will learn what sessions are, how to manage them in Node.js, and some details that should help you minimize...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yea, currently the implementation does give false positives. This idea here is that it’s better to just save again on accident than to accidentally not save when there was a change (i.e. false positives are ok vs false negatives are really bad). Ideally it would have no false anything, though. Efforts along those lines are welcome!
no, only for cases when session data use the same structure as object-hash internally (that is very unlikely)