I want to create a polling website. A client requests to answer the poll using POST, and the server responds with the candidates. The client then sends a POST with the candidate information and the winner to the server, which then stores in the information. I want to prevent a client from manipulating results by repeatedly sending their vote to the server. One way I thought was:Client requests to vote in the poll.Server sends a list of candidates, timestamp, and a salted hash created using the candidates and timestamp. The server then stores the hash.Client picks a candidate, and sends the winner back with the list of candidates, timestamp, and salted hash.Server computes the hash with the same salt, and checks to see if the hash is a valid hash as stored in the database. If the hash is valid, it honors the vote. If not, then it either silently fails to avoid alerting the attacker or responds with an error.I want to find a more elegant way to do this though. First, I'm having trouble thinking of a salt which is not static. I don't want the user to be restricted by IP address, so that can't be included in the salt. After that I can't think of a good way of salting my hash.Second, I want to find a way to not have to store information on the server. If I could create a validation method that can be computed quickly instead of stored that would be better (unless storage is definitively better than computing because it might be faster?).Third, should I silently fail or explicitly inform the client of an error?
How do I prevent attackers from duplicating submissions?
server;validation