Skip to content

Commit

Permalink
[20151214] - Core - Remote Code Execution Vulnerability
Browse files Browse the repository at this point in the history
  • Loading branch information
Kubik-Rubik committed Dec 14, 2015
1 parent 9d33c05 commit 95741d8
Showing 1 changed file with 25 additions and 37 deletions.
62 changes: 25 additions & 37 deletions libraries/joomla/session/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -658,19 +658,19 @@ function _setOptions( &$options )
}

/**
* Do some checks for security reason
*
* - timeout check (expire)
* - ip-fixiation
* - browser-fixiation
*
* If one check failed, session data has to be cleaned.
*
* @access protected
* @param boolean $restart reactivate session
* @return boolean $result true on success
* @see http://shiflett.org/articles/the-truth-about-sessions
*/
* Do some checks for security reason
*
* - timeout check (expire)
* - ip-fixiation
* - browser-fixiation
*
* If one check failed, session data has to be cleaned.
*
* @access protected
* @param boolean $restart reactivate session
* @return boolean $result true on success
* @see http://shiflett.org/articles/the-truth-about-sessions
*/
function _validate( $restart = false )
{
// allow to restart a session
Expand All @@ -697,39 +697,27 @@ function _validate( $restart = false )
}
}

// record proxy forwarded for in the session in case we need it later
if( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
$this->set( 'session.client.forwarded', $_SERVER['HTTP_X_FORWARDED_FOR']);
}

// check for client adress
if( in_array( 'fix_adress', $this->_security ) && isset( $_SERVER['REMOTE_ADDR'] ) )
// Check for client address
if(in_array('fix_adress', $this->_security) && isset($_SERVER['REMOTE_ADDR']) && filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP) !== false)
{
$ip = $this->get( 'session.client.address' );
$ip = $this->get('session.client.address');

if( $ip === null ) {
$this->set( 'session.client.address', $_SERVER['REMOTE_ADDR'] );
if($ip === null)
{
$this->set('session.client.address', $_SERVER['REMOTE_ADDR']);
}
else if( $_SERVER['REMOTE_ADDR'] !== $ip )
elseif($_SERVER['REMOTE_ADDR'] !== $ip)
{
$this->_state = 'error';
$this->_state = 'error';

return false;
}
}

// check for clients browser
if( in_array( 'fix_browser', $this->_security ) && isset( $_SERVER['HTTP_USER_AGENT'] ) )
// Record proxy forwarded for in the session in case we need it later
if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && filter_var($_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP) !== false)
{
$browser = $this->get( 'session.client.browser' );

if( $browser === null ) {
$this->set( 'session.client.browser', $_SERVER['HTTP_USER_AGENT']);
}
else if( $_SERVER['HTTP_USER_AGENT'] !== $browser )
{
// $this->_state = 'error';
// return false;
}
$this->set('session.client.forwarded', $_SERVER['HTTP_X_FORWARDED_FOR']);
}

return true;
Expand Down

5 comments on commit 95741d8

@pepperstreet
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, is this patch newer than the ZIPed file over here:
https://docs.joomla.org/Security_hotfixes_for_Joomla_EOL_versions
As soon as I use that linked file called SessionFix15v2.zip I get a total blank/white screen. I could not get any error reports either. Can anyone confirm this issue? Is it the wrong file?

@dryabov
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pepperstreet I've downloaded SessionFix15v1.zip yesterday, but it was a copy of UploadFix15v3.zip, so most likely they just released a correct patch as SessionFix15v2.zip.

Both patches (95741d8 and SessionFix15v2.zip) are identical.

@Poil
Copy link

@Poil Poil commented on 95741d8 Dec 15, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filter_var : php >= 5.2.0, Joomla 1.5 require php >= 5.0.10
Some ppl will not be able to use this patch (yeah it's bad to have php <= 5.5)

@dryabov
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, it's better to use preg_match('/^(?:(?:\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])$/', $_SERVER[...]) instead.

@dryabov
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request: #3

Please sign in to comment.