Shoutbox

Bug in MsgPluslive.net voting - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: General (/forumdisplay.php?fid=11)
+---- Forum: Forum & Website (/forumdisplay.php?fid=13)
+----- Thread: Bug in MsgPluslive.net voting (/showthread.php?tid=64646)

Bug in MsgPluslive.net voting by leachy08 on 08-08-2006 at 11:40 AM

You have a bug in the voting system...
Email me: leachy_ov_ashton@hotmail.com and will explain in full detail and provide a fix....

http://www.msgpluslive.net/scripts/browse/index.php?act=view&id=80 You may want to delete the last vote on this.


RE: Bug in MsgPluslive.net voting by Menthix on 08-08-2006 at 11:54 AM

Just mailed you, thank you in advance :).


RE: Bug in MsgPluslive.net voting by leachy08 on 08-08-2006 at 02:27 PM

You've got mail


RE: Bug in MsgPluslive.net voting by Menthix on 08-08-2006 at 10:27 PM

Thank you. I saw it, will work on a solution tomorrow. Since people already started exploiting it and there is no real security risk I'll rather work on a good fix tomorrow than a quick fix now.


RE: Bug in MsgPluslive.net voting by leachy08 on 08-09-2006 at 07:50 AM

lol i seen a few then at top of highest votes with 362/5 lol


RE: Bug in MsgPluslive.net voting by John Anderton on 08-09-2006 at 08:33 AM

Is it the one where the cookie stops you from revoting so by deleting you can re-vote then i guess anyone could have figured it out. Ip log per vote per script isnt feasible plus even that is easy to get by :)


quote:
Originally posted by leachy08
lol i seen a few then at top of highest votes with 362/5 lol
O.o!
RE: Bug in MsgPluslive.net voting by leachy08 on 08-09-2006 at 08:52 AM

nope its not. There's an exploit in the actual code of the voting. There is no check on the value that is being passed to the script. Therefore the user can send a vote of 1,000,000 instead of 5 if they wanted to.


RE: Bug in MsgPluslive.net voting by NiteMare on 08-09-2006 at 10:57 AM

ok, so all he has to do is fix the security flaw, then write a mini script to delete any vote thats not between 0 and 5


RE: Bug in MsgPluslive.net voting by Menthix on 08-09-2006 at 11:10 AM

quote:
Originally posted by NiteMare
ok, so all he has to do is fix the security flaw, then write a mini script to delete any vote thats not between 0 and 5
Votes aren't stored that way... There is total rating (which is a sum of all ratings given) and there is a ammount of people who voted. So total rating / ammount of people who voted = rating.
RE: Bug in MsgPluslive.net voting by leachy08 on 08-09-2006 at 12:44 PM

Ahh so you will need to find each vote which is corrupt and clear it. I know id80 need clearing cuz thats mine i tested it on. To fix the flaw is easy though simple if statement...

code:
if ($_POST['vote'] < 0 || $_POST['vote'] > 5) {
     echo "Error with voting";
     die();
}


RE: Bug in MsgPluslive.net voting by Menthix on 08-09-2006 at 01:47 PM

quote:
Originally posted by leachy08
you will need to find each vote which is corrupt and clear it. I know id80 need clearing
I have just reset all votes on all IDs because they were all messed up (somebody was probably bored).

quote:
Originally posted by leachy08
if ($_POST['vote'] < 0 || $_POST['vote'] > 5)
I used that as fix before I saw your post, but found out you could still mess with floating values (like 3.5) that way which somehow messes it up too. It's now fixed so only 1,2,3,4 and 5 are allowed values.
RE: Bug in MsgPluslive.net voting by leachy08 on 08-09-2006 at 02:03 PM

I was going to add that but thought that it may have already been handled.

code:
is_int
if ($_POST['vote'] < 0 || $_POST['vote'] > 5 || !is_int($_POST['vote'])) {
     echo "Error with voting";
     die();
}


RE: Bug in MsgPluslive.net voting by Menthix on 08-09-2006 at 02:19 PM

quote:
Originally posted by leachy08
!is_int($_POST['vote']
Thought about that too, but PHP documentation says:
quote:
Originally posted by PHP Docs
Note:  To test if a variable is a number or a numeric string (such as form input, which is always a string), you must use is_numeric().
and is_numeric() says:
quote:
Originally posted by PHP Docs
Numeric strings consist of optional sign, any number of digits, optional decimal part and optional exponential part.
...So I'm just hard checking for 1,2,3,4 or 5 now. There is probably a prettier solution, but this will do the job :).



I reported it to PHP Arena too BTW: (security) flaw in version 3.5.3 voting code @ paFileDB Forums.
RE: Bug in MsgPluslive.net voting by leachy08 on 08-09-2006 at 02:37 PM

intval

This will work. Simply takes the interger value of the $_POST['vote'] and checks if it is the same as the normal value. If its not then there is a point.

if ($_POST['vote'] < 0 || $_POST['vote'] > 5 || intval($_POST['vote']) != $_POST['vote']) {
     echo "Error with voting";
     die();
}


RE: Bug in MsgPluslive.net voting by Menthix on 08-09-2006 at 07:50 PM

Everything should be fixed now (it was already a few hours ago, but i tweaked it some more).

- Voting anything except 1,2,3,4 or 5 should not be possible
- Bug reported to PHP Arena ( http://www.phparena.net/forums/showthread.php?t=3912 )

And as a bonus...
- If somebody has voted, removes his cookie, and then votes again within a few hours, the vote will not be counted. I know it doesn't really stop people from making multiple votes, but it is at least something.
- Same counts for number of downloads... more than 1 downloads in a few hours from the same IP will be counted as only 1 download.

----

quote:
Originally posted by John Anderton
Is it the one where the cookie stops you from revoting so by deleting you can re-vote then i guess anyone could have figured it out. Ip log per vote per script isnt feasible plus even that is easy to get by
I agree it's easy to get by, but I still added this extra "security", it's at least something :). Because I already saw somebody trying to get his script high in top ratings this way right after I reset votes :(.
RE: Bug in MsgPluslive.net voting by leachy08 on 08-10-2006 at 07:59 AM

You should just store 1 vote as one record in mysql. This will slow things down but shouldnt be that bad. Then this would be near enough impossible to break.

Same with downloads. Therefore it would be harder to replicate and the same ip would not be able to vote again for the download. And as for the download count you could use SELECT DISTINCT statement and count the recordset.


RE: Bug in MsgPluslive.net voting by RaceProUK on 08-10-2006 at 08:50 AM

quote:
Originally posted by leachy08
You should just store 1 vote as one record in mysql. This will slow things down but shouldnt be that bad.
It will be that bad. Imagine, a few months down the line, several thousand votes have been cast. The query will take far longer to run than collecting all votes into a single record per script.
quote:
Originally posted by leachy08
And as for the download count you could use SELECT DISTINCT statement and count the recordset.
SELECT DISTINCT should only be used where necessary, as again it can slow queries down considerably. Again, with several thousand downloads, maybe even tens or hundreds of thousands, the size of the recordset makes SELECT DISTINCT impractical.
RE: Bug in MsgPluslive.net voting by leachy08 on 08-10-2006 at 09:13 AM

I work at Co-Op bank and i run queries with just uner 1 million records at a time and are usually reuturned within in a few seconds on a normal windows nt box. Therefore on a server like this one this will not be a problem.

Or maybe just store the ip address and the id of the script for the vote it made. Therefore you could just be able to

code:
"SELECT COUNT(*) FROM tbllog WHERE ip ='" & ip & "' AND id=" & id
This would be the best option.
RE: Bug in MsgPluslive.net voting by RaceProUK on 08-10-2006 at 09:53 AM

quote:
Originally posted by leachy08
I work at Co-Op bank and i run queries with just under 1 million records at a time and are usually returned within in a few seconds on a normal windows nt box
Ah, but how many concurrent users? That's also important.
RE: Bug in MsgPluslive.net voting by leachy08 on 08-10-2006 at 10:13 AM

just been thinking about what i said. Man i was tired complete nonesense. The recordset is nearly a million but i do not cycle through it and add values in a running total. That would totally screw the server load up :p silly me :P


RE: Bug in MsgPluslive.net voting by Menthix on 08-10-2006 at 11:48 AM

quote:
Originally posted by leachy08
You should just store 1 vote as one record in mysql.
That's exactly what i've done (same for sownloads), I just don't see a good reason to store those records for a long time... What if the IP is dynamic and somebody else gets the IP and wants to vote too? And like RaceProUK says, building up a huge ammount of records will eventually slow things down.