J2Store

Security update, January 2015

Summary

A security issue was found in one of the ajax requests made from the Administrator backend to load zones. The country id was not checked for its type (integer).

We have released a security update - J2Store 2.8.4. All users are advised to update to the latest version.

 

Affected versions

J2Store 2.5. to 2.8.3

Corrective Action

We have released a new version - J2Store 2.8.4 - which fixes the issue. Please update to the latest version.

In case, you have customised J2Store and is not able to update it, you can implement the following fix.

Open /administrator/components/com_j2store/controllers/geozone.php

Around line 58, you will find the following code

function getZone()
    {
        $app=JFactory::getApplication();
        $data = $app->input->post->get('jform',array(),'array');
        $country_id =isset($data['country_id'])?$data['country_id']:$app->input->getInt('country_id', '0');
        //$country_id = isset($data['country_id'])?$data['country_id']:0;
        $zone_id = isset($data['zone_id'])?$data['zone_id']:$app->input->getInt('zone_id');
        $z_fname =isset($data['field_name'])?$data['field_name']:$app->input->getString('field_name');
        $z_id = isset($data['field_id'])?$data['field_id']:$app->input->getString('field_id');
        /*$z_fname=$data['field_name'];
        $z_id=$data['field_id'];*/
        // based on the country id, get zones and generate a select box
        if(!empty($country_id))
        {
            $db = JFactory::getDBO();
            $query = $db->getQuery(true);
            $query->select('zone_id,zone_name');
            $query->from('#__j2store_zones');
            $query->where('country_id='.$country_id);
            $db->setQuery((string)$query);
            $zoneList = $db->loadObjectList();
            $options = array();
            $options[] = JHtml::_('select.option', 0,JTEXT::_('J2STORE_ALL_ZONES'));
            if ($zoneList)
            {
                foreach($zoneList as $zone)
                {
                    // this is only to generate the
 

Replace the above with :

function getZone()
    {
        $app=JFactory::getApplication();
        $data = $app->input->post->get('jform',array(),'array');
        $country_id =isset($data['country_id'])?$data['country_id']:$app->input->getInt('country_id', '0');
        
        if (!is_numeric($country_id)) {            
            // error the country id is not supplied properly
            $app->close();
        }

        $zone_id = isset($data['zone_id'])?$data['zone_id']:$app->input->getInt('zone_id');
        $z_fname =isset($data['field_name'])?$data['field_name']:$app->input->getString('field_name');
        $z_id = isset($data['field_id'])?$data['field_id']:$app->input->getString('field_id');
        $z_id=htmlspecialchars($z_id);
        if(!empty($zone_id)){
            if (!is_numeric($zone_id)) {
                // error the zone id is not supplied properly
                $app->close();
            }
        }
                
        if(!empty($z_fname)){
        $z_fname=htmlspecialchars($z_fname);
            if(!$this->validate_string($z_fname)){
                // invalid field name passed
                $app->close();
                }
        }
        
        if(!empty($z_id)){
            if(!$this->validate_string($z_id)){
                // invalid field id passed
                $app->close();
            }    
        }
      
 
        // based on the country id, get zones and generate a select box
        if(!empty($country_id))
        {
            $db = JFactory::getDBO();
            $query = $db->getQuery(true);
            $query->select('zone_id,zone_name');
            $query->from('#__j2store_zones');
            $query->where('country_id='.$country_id);
            $db->setQuery((string)$query);
            $zoneList = $db->loadObjectList();
            $options = array();
            $options[] = JHtml::_('select.option', 0,JTEXT::_('J2STORE_ALL_ZONES'));
            if ($zoneList)
            {
                foreach($zoneList as $zone)
                {
                    // this is only to generate the

 

Save the file. This will check and allow only numeric values as country id and zone id.

 

Subscribe to get updates from us