question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

improve session hashing when detecting modified sessions

See original GitHub issue

There 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:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
dougwilsoncommented, Oct 4, 2018

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!

1reaction
skarbovskiycommented, Nov 4, 2019

no, only for cases when session data use the same structure as object-hash internally (that is very unlikely)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found