Create New Fingerprint Programmatically

45 views
Skip to first unread message

David S Taylor

unread,
Apr 19, 2016, 3:16:56 PM4/19/16
to actionHero.js
Is there a way to create a new fingerprint programmatically and have it store in the sessionID cookie? I saw where two users had the same fingerprint in the redis session. To ensure this never happens, I was thinking I could just set a new fingerprint id in the cookie  every time a user logs in...

Evan Tahler

unread,
Apr 20, 2016, 10:31:37 AM4/20/16
to actionHero.js
That's frightening!  Can you be sure that it wasn't a user who coppied his cookie over?

The fingerprint logic comes from this package: https://github.com/evantahler/browser_fingerprint

Can you create a reproducible test case where 2 separate browsers can get the same fingerprint?  You can see how we try to generate a unique hash for each request, which includes:
- client headers
- client IP
- random numbers
- process hostname
- process pid
- Date/Time
and then we sha1 the whole thing to generate the fingerprint

Rather than have options to change the fingerprint, I would like to *ensure* that it is unique.  One option might be to replace Math.random() with a true UUID generator...

David S Taylor

unread,
Apr 20, 2016, 10:45:44 AM4/20/16
to actionHero.js
Can you create a reproducible test case where 2 separate browsers can get the same fingerprint?  

I could not reproduce it. I talked to the users, and they swear they never used the same machine. I can reproduce a similar problem in my app by one user being logged in, and then the second user navigating to the login dialog and logging in before the other user logs out (both users on the same machine). Thus, I thought I'd solve this by simply recreating the cookie on login.

I'd like to regenerate the fingerprint and store the sessionID cookie upon login. Is that possible?
 

Clay Himmelberger

unread,
Apr 21, 2016, 9:25:13 AM4/21/16
to actionHero.js
Is your example that you reproduce locally on the same browser session? To actionhero, I think that would share the fingerprint. Perhaps you can clear the __browserFingerprint cookie when a user logs out (or when you navigate to the login screen)? That should regenerate on the server side. 

Will keep following this thread, it's an interesting one! Keep us posted what you find out : )

Evan Tahler

unread,
Apr 21, 2016, 11:03:08 AM4/21/16
to actionHero.js
Well, cookies clobber each-other in the same browser.  If you have 2 tabs open in say Chrome, and you login twice, the second cookie will clobber the first, and you'll end up logged in as the same user at the same time in both tabs (potentially after reloading).   Assuming you do your test in different browser, we should be accounting for that by checking the remote connections' outgoing port, which must be unique even though they are both accessing port 80/443.  

David S Taylor

unread,
Apr 21, 2016, 7:21:45 PM4/21/16
to actionHero.js


On Thursday, April 21, 2016 at 6:25:13 AM UTC-7, Clay Himmelberger wrote:
Is your example that you reproduce locally on the same browser session?

Yes. That was easy to reproduce. I can't explain how the two users, on two different machines, got the same fingerprint. That is a mystery to me.
 
To actionhero, I think that would share the fingerprint. Perhaps you can clear the __browserFingerprint cookie when a user logs out (or when you navigate to the login screen)? That should regenerate on the server side. 

Yes, thats what I am planning on doing, and disabling the login button if the user is already logged in. Seems that in this office where the problem occurred, its not uncommon for people to share computers, or for computers to be assigned to different users. So I need to improve on the long lasting cookie approach I've taken.
 

Will keep following this thread, it's an interesting one! Keep us posted what you find out : )

Will do. Hope to have some time to test this out soon....

David S Taylor

unread,
Apr 22, 2016, 2:18:05 PM4/22/16
to actionHero.js
Well Im hacking about here, but I can't seem to find a way to set a cookie from an action. I was thinking maybe adding a header with

data.connection.rawConnection.responseHeaders

or setting the sessionID cookie here

data.connection.rawConnection.cookies

but I can't seem to make that work either way. Is there a way to set the sessionID cookie from an action with expiration? (I want it to expire immediately)

Evan Tahler

unread,
Apr 22, 2016, 4:44:27 PM4/22/16
to actionHero.js
you are on the right track with `data.connection.rawConnection.responseHeaders`.  I would suggest setting the expiration date to be in the past, which is how you "Delete" a cookie, then on the next request (even just an AJAX API call) will get & set a new cookie.

David S Taylor

unread,
Apr 22, 2016, 5:08:02 PM4/22/16
to actionHero.js
That worked perfectly. Thanks!
Reply all
Reply to author
Forward
0 new messages