Bug in Artio's Docman 2 component Print E-mail
Thursday, 13 August 2009 20:00

I was a little surprised this morning when I received a mail from a visitor of my website. The reason of my astonishment could have been that someone actually visited my website of course. Rather than that, what caught my attention was when he announced humbly that he had been granted super administrator access and could modify all my articles without even registering! This was the sign of a bad debugging day…

The problem arises when a guest or user gets a list of documents displayed by Artio’s Docman 2 component. I haven’t checked whether the problem is present in earlier versions functioning on Joomla! 1.0.x, but it seems unlikely that something so dangerous would have slipped through that long. After a lot of coffee and “exit();” commands introduction across Docman’s code, I could nail the problem down to a seemingly very innocent function call in DOCMAN_user.class.php. Lines 811-2 read as follows:


811   $users [$id] = &JFactory::getUser();

812   $users [$id]->load ( $id );


In short, a user object is built by calling the JFactory::getUser function without specifying the user id which is specifically loaded on the next line. As far as I can judge, this seems like a pretty standard harmless piece of code. Unless you give a look to the JFactory::getUser function:


Function &getUser($id = null)

{

    jimport('joomla.user.user');

 

    if(is_null($id))

    {

        $session  =& JFactory::getSession();

        $instance =& $session->get('user');

        if (!is_a($instance, 'JUser')) {

            $instance =& JUser::getInstance();

        }

    }

    else

    {

        $instance =& JUser::getInstance($id);

    }

 

    return $instance;

}


I’m not 100% sure that I fully understand what happens here, but it seems that, should no user id be specified, the function will return by reference the session’s user. This apparently has the consequence that when Docman loads the id in the object that is returned this modifies the user of the session. In my case, all documents were created as super administrator on the backend, so when Docman loaded the user object corresponding to the creator of any document for display it inadvertently also modified the session as being a super administrator one.

A possible correction    

I am not sure where this should be corrected… A possible correction of lines 811-2 in DOCMAN_user.class.php could be:


811   $users [$id] = &JFactory::getUser($id);

812   //$users [$id]->load ( $id );


This correction prevents the modification of the session and returns the desired user informations.

However, the JFactory::getUser function seems a little fishy to me in that it has two purposes, returning any user object specified by id or to point to the session user. I have no idea of the implications, so please be indulgent in your comments, but I would guess that these two purposes should be separated in distinct functions for improved security…

Comments
Search
artio  - Bug fixed     |2009-10-06 16:17:07
Hi all, this bug has been already fixed in the stable releases since 2.0.0. No need to worry anymore.
molgyk   |2009-10-06 17:32:52
Hi,
Thanks for the comment. Actually, I am using Docman 2.0.0 stable... Are you 100% sure this has been fixed?
jessie1989   |2010-04-19 07:39:45
hello,we are sale christian louboutin shoes,if you want Christian Louboutin Pumps and Christian Louboutin Sandals,you can contact us,and the Christian Louboutin Slingbacksis every cheap,Christian Louboutin Boots store on sale,thanks.
jessie1989   |2010-04-19 07:39:18
hello,if you want to buy christian louboutin,it is cheap christian louboutin shoes store,christian louboutin shoes sale can help you,christian louboutin sale and buy christian louboutin shoes,thanks,Replica christian louboutin shoes you can see,discount christian louboutin shoes and christian louboutin white shoes and christian louboutin shoes ukchristian louboutin shoes sakschristian louboutin red sole shoeschristian louboutin feathered shoes
cheap christian louboutin shoes peep toe size 42andchristian louboutin emily shoes,
Christian Louboutin Pumps,
Wholesale Christian Louboutin Pumps
lightverdict   |2010-07-13 04:46:47

We'r ed hardy outlet one of the most profession
of the coolest and latest ed hardy apparel, such as
ed hardy tee ,ed hardy bags,
ed hardy bathing suits, ed hardy shoes,
ed hardy board shorts ed hardy watches women,ed hardy jeans for womened hardy for men,
ed hardy for women
ed hardy swimwearand more,
ed hardy clothing. We offers a wide selection of fashion
cheap ed hardyproducts. Welcome to our shop or just enjoy browsing through our stunning collection available wholesale ed hardy in our shop.


our goal is to delight you with our distinctive collection of mindful ed hardy products while providing value and excellent service. Our goal is 100% customer satisfaction and we offer only 100% satisfacted service and ed hardy products. Please feel free to contact us at any time; we are committed to your 100% customer satisfaction. If you're looking for the best service and best selection, stay right where you are and continue shopping at here is your best online ch...
Only registered users can write comments!

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."

Last Updated on Friday, 14 August 2009 11:52