Mapme 1.3 Exploit Code Fix

e107 CMS » Forums » e107 Code » Code Modification / Plugin / Announcement and Releases << Previous thread | Next thread >>
VR6Pete
May 25 2011, 05:25AM
Registered Member #2353
Joined: Jul 28 2003, 11:21AM
Location: Stoke-on-Trent
Posts: 1246
Hello,

I've received a response from the developer of mapme 1.3 in regards to the recently identified exploit.

in mapmejs.php

Change:

$uid = $_GET['u'];


to

$uid = settype($_GET['u'], 'integer');
 if(!is_int($uid)) die("//invalid user id");


You can add this change immediately.

Please let me know if any comments.

Regards,
Ajay Bhargav


Hope this is of some use to folk, maybe worth including in the Bad Plugin List plugin as a note..

Cheers

Pete
Go to top
Website
C6Dave
May 25 2011, 05:34AM
  • e107 Site administrator
  • e107 Support Team Leader
Registered Member #9506
Joined: Jul 31 2004, 12:57AM
Location: North East UK
Posts: 12342
Why not simply make the fix and upload it to plugins.e107 with a new version number?

That way everyone can grab a copy without having to edit files which most aren't confident of doing.

EDIT: I made the changes and made it available here: [-link-]

It's not tested though..........................
[ Edited May 25 2011, 10:30AM ]
Go to top
Website
VR6Pete
May 25 2011, 05:36AM
Registered Member #2353
Joined: Jul 28 2003, 11:21AM
Location: Stoke-on-Trent
Posts: 1246
I've asked him to do that as the insecure version would have been removed.

This is intended for people who are confident, and wish to simply fix the version they have running at the moment.
Go to top
Website
VR6Pete
May 25 2011, 06:17AM
Registered Member #2353
Joined: Jul 28 2003, 11:21AM
Location: Stoke-on-Trent
Posts: 1246
C6Dave wrote ...


EDIT: I made the changes and made it available here: [-link-]


Good stuff - It would be good if others could contact plugin developers to get the security holes closed, it's a shame to see good plugins being abandoned, when it can literally be a simple task of informing the developer of the exploit used so it can be closed.

Pete
Go to top
Website
C6Dave
May 25 2011, 06:38AM
  • e107 Site administrator
  • e107 Support Team Leader
Registered Member #9506
Joined: Jul 31 2004, 12:57AM
Location: North East UK
Posts: 12342
Pete I have admin rights at plugins.e107 and pm's were sent to most (not all) plugin makers when they were withdrawn and few responded with fixes I'm afraid.
Go to top
Website
guk
May 25 2011, 09:17AM
Registered Member #54588
Joined: Jan 26 2010, 03:59PM
Posts: 6
First I replaced the old version folder with the new version, and the map doesn't load anymore, so then I decided to apply this fix manually to mapmejs.php, but I have the same problem, the map doesn't load up on users profiles with this change in place.

e107 Version 0.7.22
Go to top
Moc
May 25 2011, 10:07AM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #44563
Joined: Apr 12 2008, 03:01AM
Location: The Netherlands
Posts: 3523
Guk, please update to the most recent version being 0.7.25. Using older versions makes your website vulnerable to exploits and other security issues.
Go to top
swata4
May 28 2011, 03:16PM
Registered Member #30637
Joined: Sep 17 2006, 11:49AM
Posts: 132
1.4 still doesn't work for me. I see the map when you click on the map page, but it doesnt even show in the profiles page.
Go to top
guk
Jun 06 2011, 04:23AM
Registered Member #54588
Joined: Jan 26 2010, 03:59PM
Posts: 6
Is the developer aware that 1.4 is not working for people, will there be a fix or should I uninstall it all together?
Go to top
septor
Jun 06 2011, 01:49PM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #37
Joined: Aug 11 2002, 03:20AM
Location: United States
Posts: 2659
The developer didn't issue 1.4. 1.4 fixes an explot that exists in 1.3. Nothing was changed between 1.3 and 1.4 that would have broken it.

In fact, the only thing that was changed is what you see in the first post of this thread.
Go to top
Website
guk
Jun 06 2011, 02:20PM
Registered Member #54588
Joined: Jan 26 2010, 03:59PM
Posts: 6
septor wrote ...

Nothing was changed between 1.3 and 1.4 that would have broken it.


I can report that changing:

$_GET['u'];


to:

1.$uid = settype($_GET['u'], 'integer');

2. if(!is_int($uid)) die("//invalid user id"); 


Does break mapme on my website in the user profile page.

Without the change, the map is displayed on each users profile, and with that change in place, the area where the map should be is blank. swata4 confirmed the same thing in this thread.
Go to top
septor
Jun 06 2011, 05:39PM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #37
Joined: Aug 11 2002, 03:20AM
Location: United States
Posts: 2659
Revert those changes.

Change the following line:

$sql->mySQLresult = @mysql_query("SELECT ".MPREFIX."gmarkers.loc, ".MPREFIX."gmarkers.lat, ".MPREFIX."gmarkers.lng, ".MPREFIX."user.user_name, ".MPREFIX."user.user_image FROM `".MPREFIX."gmarkers`, ".MPREFIX."user where ".MPREFIX."gmarkers.user_id = ".$uid." and ".MPREFIX."gmarkers.user_id = ".MPREFIX."user.user_id");


To:

$sql->mySQLresult = @mysql_query("SELECT ".MPREFIX."gmarkers.loc, ".MPREFIX."gmarkers.lat, ".MPREFIX."gmarkers.lng, ".MPREFIX."user.user_name, ".MPREFIX."user.user_image FROM `".MPREFIX."gmarkers`, ".MPREFIX."user where ".MPREFIX."gmarkers.user_id = ".intval($uid)." and ".MPREFIX."gmarkers.user_id = ".MPREFIX."user.user_id");


See if that works.


OR

You can revert those changes mention in the OP and change:

$uid = $_GET['u'];


To:

$uid = intval($_GET['u']); 


This is probably easier.
[ Edited Jun 06 2011, 05:43PM ]
Go to top
Website
guk
Jun 07 2011, 03:34AM
Registered Member #54588
Joined: Jan 26 2010, 03:59PM
Posts: 6
Thank you, I tried both of those methods and they both work. The map is back in the user profile page.
Go to top
swata4
Jun 07 2011, 08:00AM
Registered Member #30637
Joined: Sep 17 2006, 11:49AM
Posts: 132
Thanks. My maps disappeared from the profile page, and stopped showing the users on the main map too.

This fix put the map back in the profiles page, but the main map for the site doesnt show any people on it, even though I have my target set.
[ Edited Jun 07 2011, 08:15AM ]
Go to top
WayneM
Jun 09 2011, 11:36AM
Registered Member #4707
Joined: Dec 04 2003, 07:19AM
Posts: 79
septor wrote ...

Revert those changes.

Change the following line:

$sql->mySQLresult = @mysql_query("SELECT ".MPREFIX."gmarkers.loc, ".MPREFIX."gmarkers.lat, ".MPREFIX."gmarkers.lng, ".MPREFIX."user.user_name, ".MPREFIX."user.user_image FROM `".MPREFIX."gmarkers`, ".MPREFIX."user where ".MPREFIX."gmarkers.user_id = ".$uid." and ".MPREFIX."gmarkers.user_id = ".MPREFIX."user.user_id");


To:

$sql->mySQLresult = @mysql_query("SELECT ".MPREFIX."gmarkers.loc, ".MPREFIX."gmarkers.lat, ".MPREFIX."gmarkers.lng, ".MPREFIX."user.user_name, ".MPREFIX."user.user_image FROM `".MPREFIX."gmarkers`, ".MPREFIX."user where ".MPREFIX."gmarkers.user_id = ".intval($uid)." and ".MPREFIX."gmarkers.user_id = ".MPREFIX."user.user_id");


See if that works.


OR

You can revert those changes mention in the OP and change:

$uid = $_GET['u'];


To:

$uid = intval($_GET['u']); 


This is probably easier.



I see you have an OR between these two methods.

Is there any reason not to do both?

I did and things seems to be working fine.
Go to top
Moc
Jun 09 2011, 11:57AM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #44563
Joined: Apr 12 2008, 03:01AM
Location: The Netherlands
Posts: 3523
@WayneM;

Cause when you do both you'll 'over do' it. I'll try to explain it as clear as I can.

Start by looking at the second method.

$uid = $_GET['u']; to $uid = intval($_GET['u']); activates an inbuilt protection from e107 It makes sure the input (the GET variable) is not malicious and it prepares it for safe usage.
It takes the GET variable, it checks its validity, and it stores the safe value in the $uid variable. Once done, the $uid variable is considered as safe.


Now look at the first method.
Instead of making sure the $uid variable is safe before even starting to build up a query (= request to mysql - the database where everything is stored), it does so in the query itself.
You see: "gmarkers.user_id = ".$uid." and " is changed in "gmarkers.user_id = ".intval($uid)." and"

If you'd apply both methods at the same time; you'd get something like this:
gmarkers.user_id = ".intval(intval($_GET['u']); )."

Its double

Hope that clears it up, just ask if you want more info
[ Edited Jun 09 2011, 02:11PM ]
Go to top
WayneM
Jun 09 2011, 12:10PM
Registered Member #4707
Joined: Dec 04 2003, 07:19AM
Posts: 79
Thanks for that!
Makes sense.

Is one of these methods preferred, or more elegant?

Thanks.
Go to top
Moc
Jun 09 2011, 02:10PM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #44563
Joined: Apr 12 2008, 03:01AM
Location: The Netherlands
Posts: 3523
I would prefer the second method as you can then use the variable safely elsewhere in the code without creating vulnerabilities if you happen to forget to add the security using method one.

You're welcome
Go to top
septor
Jun 09 2011, 02:30PM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #37
Joined: Aug 11 2002, 03:20AM
Location: United States
Posts: 2659
As Moc said, they both do the same thing. The second method just, as Moc said, allows you to safely use $uid in other queries.

I added it at the last minute because it will be easier for people who don't understand coding that well to implement without causing errors by missing something.
Go to top
Website
WayneM
Jun 10 2011, 05:03AM
Registered Member #4707
Joined: Dec 04 2003, 07:19AM
Posts: 79
Thanks!
Go to top
 

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System