lundi 19 décembre 2016

How to avoid that a user removes his session

The use case

Currently, I am trying to build a page where users can vote on content (up/downvote, similar to the function on the StackExchange network). But the users shouldn't need to register themselves to vote on content. So it would be a kind of anonymous voting page. It is built with Laravel5 and uses a MySQL database to store the votes. The user sessions are stored in flat-files, but can be also stored in a database table (L5 is quite flexible here).


The problem

How to make it secure?.

I am storing restrictions and already voted contents in the user sessions, e.g. when the user has voted on content XYZ (so the user cannot vote again on the specific content for now). Those restrictions are time-based, mostly 24 to 48h. This works well, as long as the user does not throw away/delete his cookies, which would cause to create a new session and remove the time restrictions, which could lead to easy vote fraud.

So, how to avoid that the user "loses" his session?


Solution attempts

Setting the sessionId of each users session to a combination of IP and User-Agent

I've asked a question about this attempt (linked below), but it'd open up more problems then it'd solve (e.g. easy session spoofing). Also, I couldn't achieve to set the sessionID manually by using Laravel5.


Solutions that doesn't fit

  • Let every user register themself (it's simply too much effort for each user in my use case)

Related



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire