Closed (fixed)
Project:
Fivestar
Version:
5.x-1.8
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Oct 2007 at 13:57 UTC
Updated:
12 Nov 2007 at 22:42 UTC
When the user is behind a proxy and votes as anonymous the module allows multiple votes. Such users use this hole to cheat and valuably increase rating.
This defect was found in the _fivestar_cast_vote($type, $cid, $value) function.
Here is a piece of code where you assign $_SERVER['HTTP_X_FORWARDED_FOR'] to $hostname variable.
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$hostname = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else {
$hostname = $_SERVER['REMOTE_ADDR'];
}
And here is how votingapi.module saves such IPs (it concatenates REMOTE_ADDR and HTTP_X_FORWARDED_FOR:
$vobj->hostname = $_SERVER['REMOTE_ADDR'];
// Append internal IP if it exists.
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$vobj->hostname .= '-'. $_SERVER['HTTP_X_FORWARDED_FOR'];
}
I propose you to change your code to this one:
$hostname = $_SERVER['REMOTE_ADDR'];
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$hostname .= '-'. $_SERVER['HTTP_X_FORWARDED_FOR'];
}
Thanks.
Comments
Comment #1
quicksketchAwesome, looks like Eaton made the same fix for voting API in http://drupal.org/node/108592. Thanks for the fix!
Comment #2
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.