How to Check Authenticity of an AJAX Request

后端 未结 15 874
悲&欢浪女
悲&欢浪女 2021-01-31 08:47

I am designing a web site in which users solve puzzles as quickly as they can. JavaScript is used to time each puzzle, and the number of milliseconds is sent to the server via A

15条回答
  •  抹茶落季
    2021-01-31 09:11

    I do not think there is a perfect solution. Here is an alternative that makes it harder for cheater but at the same time an unlucky honest solver may lose out.

    Get many samples of roundtrip time measurements from each specific devices/location/other combination apriori for each user based on their other interaction with your site. You will also have these measurements for the entire population. You could also be very subtle get the timestamps for when a particular DNS lookup happened from their ISP's resolver (random hostname and you host the authoritative DNS server for that domain).

    Once you have this, perform all measurements on the server side (puzzle returned to user, solution received) and subtract out the network time based on previous observations.

    Note that even in other solutions you have server load, client load (slow processor, etc.), etc that affect timing.

    Make sure you have XSRF protection on puzzle submission page :)

提交回复
热议问题