GET requests are confusing [tracked]

old granted and denied feature requests

Moderator: AniDB

Locked
Elberet
Posts: 778
Joined: Sat Jul 19, 2003 8:14 pm

GET requests are confusing [tracked]

Post by Elberet »

I wanted to change a vote on a particular anime, so I went to my votes, opened a second window with the anime, clicked the revoke link for the vote I wished to change, reloaded the other window and made the new vote. Due to stupidity on my end, the dropdown was still set to 1, so I tried to revoke the vote again. To do so, I reloaded the page where I had previously revoked the same vote. What I didn't notice was that by reloading the page, the revoke action had already been performed since the command to do so consists of a parameter in the URI. Being confused, I went back to the window with the anime and reloaded that as well, thereby unknowingly re-casting the wrong vote that I unknowingly revoked a second ago.

This went on at least three times before I noticed the "vote.del=1" and "votea.rate=6" parts in the URI, hence I suggest to either display a notification ("Thank you, your vote has been recorded.", "Your vote for [title] was revoked!"), or better yet, to send a HTTP 302 header after revoking/adding a vote and sending the user back to the page where they revoked/cast the vote but without the appropriate parameter in the URI.
PetriW
AniDB Staff
Posts: 1522
Joined: Sat May 24, 2003 2:34 pm

Post by PetriW »

I have to agree with this as I've seen people post links in irc which would automatically cast votes on reviews which are unrevokable!!! A common handling of this that prevents the issue would be great.
Elberet
Posts: 778
Joined: Sat Jul 19, 2003 8:14 pm

Post by Elberet »

Here's an idea:

Instead of submitting the vote via GET, use POST. Additionally, include two hidden fields in the form that contain a timestamp and a checksum. The checksum is the md5sum of the timestamp + client's IP + secret. Upon handling the vote request, the script regenerates the checksum using the submitted timestamp and client IP. If the timestamp is smaller then the current time minus 1h or the submitted and regenerated checksums don't match, the request is discarded.
PetriW
AniDB Staff
Posts: 1522
Joined: Sat May 24, 2003 2:34 pm

Post by PetriW »

Shouldn't base things on peoples IPs as they might be sitting behind a multi ip proxy...
And fancy solutions often bring more problems than they solve.
exp
Site Admin
Posts: 2438
Joined: Tue Oct 01, 2002 9:42 pm
Location: Nowhere

Post by exp »

I don't see what we would gain by using such secret form fields.
A simple switch from get to post requests and maybe an additional forward to a page without the vote command afterwards should do it IMHO.
I'll look into this, some day :P

BYe!
EXP
Elberet
Posts: 778
Joined: Sat Jul 19, 2003 8:14 pm

Post by Elberet »

I know that I'm paranoid, thank you, but IMO paranoia is a "Good Idea(tm)". :P
exp
Site Admin
Posts: 2438
Joined: Tue Oct 01, 2002 9:42 pm
Location: Nowhere

Post by exp »

Yeah paranoia(TM) is a good thing in deed.
However, i (and I _am_ paranoid) don't see any security gain by implementing those time and ip based hidden form fields.

BYe!
EXP
Elberet
Posts: 778
Joined: Sat Jul 19, 2003 8:14 pm

Post by Elberet »

Well, I'm looking at it this way:
It takes three lines to add a method that generates the hash.
It takes two lines to get the current time, call the hash method and add the two hidden form fields.
It takes another two lines to check the submitted timestamp against the current time and verify the hash.

With roughly seven lines of code, you can make sure that users aren't tricked into casting votes in any way, you don't have to worry about how the form data is handled, and finally, if someone accidently re-posts the form or has an outdated copy of the page cached, the timestamp catches those cases.

But... I guess it doesn't matter after all since either way works. :)
Gambit
AniDB Staff
Posts: 555
Joined: Sun Oct 06, 2002 11:21 am

Post by Gambit »

Good thing to do :) I`ve noticed the problem before as well, just forgot about it again
Locked