PDA

Просмотр полной версии : Исправление для IPB 2.1.x


_GaLs_
11.06.2007, 14:07
2 сентября 2005 - уязвимы версии 2.1.0 и ниже
Открыть файл ./sources/lib/post_parser.php
найти: (строчка 520)
if ( is_array( $ibforums->cache['bbcode'] ) and count( $ibforums->cache['bbcode'] ) )
{

Добавить после:
# XSS Clean
$t = preg_replace( "#javascript\:#is", "java script:", $t );
$t = str_replace( "`" , "& #96;" , $t );

Убрать пробел между & и # !

Скачать файл и загрузить его на сервер. Файл

Изменение MIME-типов:
Так же изменить MIME-типы некоторых опасных файлов, которые разрешены на форуме для прикрепления.
Сделать следующее:

1)Войти в Админцентр
2)Воспользоваться группой настроек Прикрепляемые файлы -> Типы прикрепляемых файлов
3)Отредактировать опции для файлов ".htm", ".html", ".txt", ".rtf", выставив в поле "MIME-тип файла" значение "unknown/unknown" (без ковычек)

5 января 2006 - уязвимы версии 2.1.4 и ниже
Открыть файл ./sources/ipsclass.php
найти:
$this->forum_read[$id] = $stamp;

заменить на:
$this->forum_read[ intval($id) ] = intval($stamp);

найти код:
/*-------------------------------------------------------------------------*/
// Makes incoming info "safe"
/*-------------------------------------------------------------------------*/

заменить на:
/*-------------------------------------------------------------------------*/
// Makes topics read or forum read cookie safe
/*-------------------------------------------------------------------------*/
/**
* Makes int based arrays safe
* XSS Fix: Ticket: 243603
* Problem with cookies allowing SQL code in keys
*
* @param array Array
* @return array Array (Cleaned)
* @since 2.1.4(A)
*/
function clean_int_array( $array=array() )
{
$return = array();

if ( is_array( $array ) and count( $array ) )
{
foreach( $array as $k => $v )
{
$return[ intval($k) ] = intval($v);
}
}

return $return;
}

/*-------------------------------------------------------------------------*/
// Makes incoming info "safe"
/*-------------------------------------------------------------------------*/


Открыть файл ./sources/action_public/forums.php
найти код:
$this->read_array = unserialize(stripslashes($read));

заменить на:
$this->read_array = $this->ipsclass->clean_int_array( unserialize(stripslashes($read)) );

Открыть файл ./sources/action_public/search.php
найти код:
$this->read_array = unserialize(stripslashes($read));

заменить на:
$this->read_array = $this->ipsclass->clean_int_array( unserialize(stripslashes($read)) );

Открыть файл ./sources/action_public/topics.php
найти код:
$this->read_array = unserialize(stripslashes($read));

заменить на:
$this->read_array = $this->ipsclass->clean_int_array( unserialize(stripslashes($read)) );

31 Января 2006 - Уязвимы версии 2.1.4 и ниже
Открыть файл ./sources/action_public/usercp.php
найти код:
$topic_array = array_slice( array_keys( $topics ), 0, 5 );

добавить после:
$topic_array = $this->ipsclass->clean_int_array( $topic_array );


Файл /sources/classes/bbcode/class_bbcode.php
найти код:
$txt = preg_replace( "#javascript\:#is", "java script:", $txt );
$txt = str_replace( "`" , "`" , $txt );

заменить на:
$txt = preg_replace( "#javascript\:#is", "java script:", $txt );
$txt = preg_replace( "#vb script:", $txt );
$txt = str_replace( "`" , "`" , $txt );
$txt = preg_replace( "#moz\-binding:#is", "moz binding:", $txt );

25 апреля 2006 - Уязвимы версии 2.1.5 и ниже
Открыть файл ./ips_kernel/class_upload.php
найти код:
else if ( ! $img_attributes[2] )
{
// Unlink the file first
@unlink( $this->saved_upload_name );
$this->error_no = 5;
return;
}

заменить на:
else if ( ! $img_attributes[2] )
{
// Unlink the file first
@unlink( $this->saved_upload_name );
$this->error_no = 5;
return;
}
else if ( $img_attributes[2] == 1 AND ( $this->file_extension == 'jpg' OR $this->file_extension == 'jpeg' ) )
{
// Potential XSS attack with a fake GIF header in a JPEG
@unlink( $this->saved_upload_name );
$this->error_no = 5;
return;
}

Открыть файл ./sources/action_public/search.php

найти код:
$this->output = preg_replace( "#(value=[\"']{$this->ipsclass->input['lastdate']}[\"'])#i", "\\1 selected='selected'", $this->output );

заменить на:
$this->output = preg_replace( "#(value=[\"']".intval($this->ipsclass->input['lastdate'])."[\"'])#i", "\\1 selected='selected'", $this->output );


Открыть файл ./sources/action_public/messenger.php
найти код:
$this->msglib->to_by_id = $this->ipsclass->input['from_contact'];

заменить на:
$this->msglib->to_by_id = intval( $this->ipsclass->input['from_contact'] );


Открыть файл ./sources/lib/func_taskmanager.php

найти код:
$this->cron_key = substr( trim(stripslashes($_REQUEST['ck'])), 0, 32 );

заменить на:
$this->cron_key = addslashes( substr( trim(stripslashes($this->ipsclass->txt_alphanumerical_clean($_REQUEST['ck']))), 0, 32 ) );

16 мая 2006 - Уязвимы версии 2.1.6 и ниже
Открыть файл ./sources/ipsclass.php

найти код
var $acpversion = '21012.60504.u';

заменить на:
var $acpversion = '21012.060516.s';

Открыть файл ./sources/classes/post/class_post.php
найти код:

$html = preg_replace( "/name=[\"']iconid[\"']\s*value=[\"']$post_icon\s?[\"']/", "name='iconid' value='$post_icon' checked", $html );

заменить на:
$html = preg_replace( "/name=[\"']iconid[\"']\s*value=[\"']".intval($post_icon)."\s?[\"']/", "name='iconid' value='$post_icon' checked", $html );


Открыть файл ./sources/action_public/moderate.php
найти код:
$html_forums = preg_replace( "/<option value=\"".$this->ipsclass->input['df']."\"/", "<option value=\"".$this->ipsclass->input['df']."\" selected", $html_forums );

заменить на:

$html_forums = preg_replace( "/<option value=\"".intval($this->ipsclass->input['df'])."\"/", "<option value=\"".$this->ipsclass->input['df']."\" selected", $html_forums );


Открыть файл ./sources/classes/post/class_post_edit.php
найти в нем код:
$this->orig_post = $this->ipsclass->DB->fetch_row();

if (! $this->orig_post['pid'])
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'missing_files') );
}

заменить на:
$this->orig_post = $this->ipsclass->DB->fetch_row();

if (! $this->orig_post['pid'])
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'missing_files') );
}

//-----------------------------------------
// Same topic?
//-----------------------------------------

if ( $this->orig_post['topic_id'] != $this->topic['tid'] )
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'missing_files') );

19 июня 2006 - Уязвимы версии 2.1.6 и ниже
Открыть файл ./sources/classes/bbcode/class_bbcode.php

найти код:
# XSS Clean
if( $this->strip_hex_entity )
{
while( preg_match( "/[&|&amp\;]#x(\w+?);/i", $txt ) )
{
$txt = preg_replace( "/[&|&amp\;]#x(\w+?);/ies" , "\$this->regex_bash_hex( '\\1' )" , $txt );
}
$txt = preg_replace( "#&amp(?!\;)#", "", $txt );
}

заменить на:
# XSS Clean
/*if( $this->strip_hex_entity )
{
while( preg_match( "/[&|&amp\;]#x(\w+?);/i", $txt ) )
{
$txt = preg_replace( "/[&|&amp\;]#x(\w+?);/ies" , "\$this->regex_bash_hex( '\\1' )" , $txt );
}
$txt = preg_replace( "#&amp(?!\;)#", "", $txt );
}*/

Открыть файл ./sources/classes/bbcode/class_bbcode_core.php
найти код:
for ($i=0; $i < count($match[0]); $i++)
{
$tmp = $row['bbcode_replace'];
$tmp = str_replace( '{content}', $match[2][$i], $tmp );
$t = str_replace( $match[0][$i], $tmp, $t );
}

заменить на:
for ($i=0; $i < count($match[0]); $i++)
{
# XSS Check: Bug ID: 980
if ( $row['bbcode_tag'] == 'post' OR $row['bbcode_tag'] == 'topic' )
{
$match[2][$i] = intval( $match[2][$i] );
}

$tmp = $row['bbcode_replace'];
$tmp = str_replace( '{content}', $match[2][$i], $tmp );
$t = str_replace( $match[0][$i], $tmp, $t );

}

Открыть файл ./sources/classes/bbcode/class_bbcode_core.php
найти код:
$url['html'] = str_replace( "&" , "&" , $url['html'] );

заменить на:
$url['html'] = str_replace( "&amp;" , "&" , $url['html'] );


Открыть файл ./sources/classes/bbcode/class_bbcode_core.php
найти код:
$url['show'] = preg_replace( "/&/" , "&" , $url['show'] );
заменить на:
$url['show'] = str_replace( "&amp;" , "&" , $url['show'] );

29 июня 2006 - Уязвимы версии 2.1.6 и ниже

Открыть файл ./sources/ipsclass.php
найти код:
/*-------------------------------------------------------------------------*/
// Convert string between char-sets
/*-------------------------------------------------------------------------*/

Добавить перед:
/*-------------------------------------------------------------------------*/
// XSS Clean: URLs
/*-------------------------------------------------------------------------*/

/**
* Check URL validity
*
* @param string Input String
* @return boolean
* @since 2.1.0
*/

function xss_check_url( $url )
{
$url = trim( urldecode( $url ) );

if ( ! preg_match( "#^https?://(?:[^<>*\"]+|[a-z0-9/\._\- !]+)$#iU", $url ) )
{
return FALSE;
}

return TRUE;
}

Открыть файл ./sources/lib/func_usercp.php
найти код:
if ( preg_match( "/^http:\/\/$/i", $this->ipsclass->input['url_photo'] ) )
{
$this->ipsclass->input['url_photo'] = "";
}

Добавить после:
if ( $this->ipsclass->xss_check_url( $this->ipsclass->input['url_photo'] ) !== TRUE )
{
$this->ipsclass->input['url_photo'] = '';
}

Открыть файл ./sources/lib/func_usercp.php
найти код:
if ( preg_match( "/^http:\/\/$/i", $this->ipsclass->input['url_avatar'] ) )
{
$this->ipsclass->input['url_avatar'] = "";
}


Добавить после :
if ( $this->ipsclass->xss_check_url( $this->ipsclass->input['url_avatar'] ) !== TRUE )
{
$this->ipsclass->input['url_avatar'] = '';
}


Открыть файл ./sources/classes/bbcode/class_bbcode_core.php
найти код:
if ( preg_match( "/java(\s+?)?script(\:|\s)/is", $url ) )

Заменить на:
if ( preg_match( "/javascript\:/is", preg_replace( "#/\s{1,}#s", "", $url ) ) )


Открыть файл ./sources/classes/bbcode/class_bbcode_core.php
найти код:
//-----------------------------------------
// Is the img extension allowed to be posted?
//-----------------------------------------

if ( $this->ipsclass->vars['img_ext'] )
{

Добавить перед :
//-----------------------------------------
// Check...
//-----------------------------------------

if ( $this->ipsclass->xss_check_url( $url ) !== TRUE )
{
return '';
}


Открыть файл ./sources/action_public/moderate.php
найти код:
$this->topic = $this->ipsclass->DB->fetch_row();

if (empty($this->topic['tid']))
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files') );
}

Добавить после :
if ( $this->ipsclass->input['f'] AND ( $this->topic['forum_id'] != $this->ipsclass->input['f'] ) )
{
$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'missing_files') );
}

10 августа 2006 - Уязвимы версии 2.1.7 и ниже
Открыть файл ./sources/lib/func_topic_threaded.php
найти:
//-----------------------------------------
// Are we viewing Posts?
//-----------------------------------------

$post_id = intval($this->ipsclass->input['pid']);

заменить на:
//-----------------------------------------
// Are we viewing Posts?
//-----------------------------------------

$post_id = intval($this->ipsclass->input['pid']);

if($post_id && !in_array($post_id, $this->pids))
{
$this->ipsclass->Error( array( LEVEL => 1, MSG => 'missing_files') );
}



5 октября 2006 - Уязвимы версии 2.1.7 и ниже
Открыть файл ./sources/action_admin/member.php
найти:
//-----------------------------------------
// Avatar?
//-----------------------------------------

if ( $r['avatar_location'] and $r['avatar_type'] )
{
$avatar = $this->ipsclass->get_avatar( $r['avatar_location'], 1, '25x25', $r['avatar_type'] );

if ( ! strstr( $avatar, 'width=' ) )
{
$avatar = str_replace( '<img', "<img width='25' height='25'", $avatar );
}
}
else
{
$avatar = "<img src='{$this->ipsclass->skin_url}/images/memsearch_head.gif' border='0' />";
}

заменить на:
//-----------------------------------------
// Avatar?
//-----------------------------------------

//-----------------------------------------
// SECURITY UPDATE: Removing user avatar
//-----------------------------------------

$avatar = "<img src='{$this->ipsclass->skin_url}/images/memsearch_head.gif' border='0' />";


17 октября 2006 - Уязвимы версии 2.1.7 и ниже
Открыть файл ./sources/classes/bbcode/class_bbcode_core.php
найти: (строка ~ 924)
$default = "".$url."";

Заменить на:

$default = "".str_replace( '[', '&# 091;', $url )."";


Найти:
if ( preg_match( "/[?&;]/", $url) )

Заменить на:
if ( preg_match( "/[?&;\<\[]/", $url) )

найти (строка ~ 486)
preg_match_all( "#(\[$preg_tag\])((?!\[/$preg_tag\]).+?)?(\[/$preg_tag\])#si", $t, $match );

Заменить на:
preg_match_all( "#(\[$preg_tag\])((?!\[/$preg_tag\]).+?)?(\[/$preg_tag\])#si", $t, $match );

if ( $row['bbcode_tag'] == 'snapback' )
{
$match[2][$i] = intval( $match[2][$i] );
}

P.S В принципи можно было прикрипить эту тему.

REDsaratov
12.06.2007, 01:45
жаль что не написано от какой баги заплатки

_GaLs_
12.06.2007, 12:32
жаль что не написано от какой баги заплатки

Ну в большинстве случаях разрабодчики не пишут от чего эти исправление. Но знаю точьно что первая заплатка от XSS, а так встречаются и от SQL инъекций.

nec
13.06.2007, 00:09
да и по коду можно догадаться что за уязвимость.

Solide Snake
13.06.2007, 00:18
_GaLs_
Пасиб:)Свой 2.1.7 зашытил:) Кстати темку реально можно было бы поднять. Только переименовать в Исправления для IPB, и будет гуд:)

_GaLs_
15.06.2007, 20:22
XSS уязвимость IP.Board

Обращено внимание на уязвимость через браузер Internet Explorer 6 и 7 версии XSS (межсайтовое выполнение сценариев). Атака может осуществляться через загруженные изображения и PDF файлы после запуска как HTML браузером конечного пользователя. Следует отметить, что XSS опасность не действует при включенных «HttpOnly(безопасных) cookies», которые были введены в IP.Board 2.2.0. Это означает, что такие cookies будет невозможно будет получить в IP.Board 2.2.0 и последующих версиях, используя этот баг.

Хотя это является существенным недостатком Internet Explorer, была сделана небольшая работы, чтобы устранить баг при просмотре файлов с вредоносным кодом для конечного пользователя. Если файл будет содержать вредоносный код, то в загрузке файла будет отказано.

Для устранения бага в IP.Board скачайте файл ниже, для нужной версии:

Версия 2.1.x: class_upload.php (http://forums.invisionpower.com/index.php?act=attach&type=post&id=11582)

Версия 2.2.x: class_upload.php (http://forums.invisionpower.com/index.php?act=attach&type=post&id=11583)

Загрузите файл class_upload.php в папку форума ips_kernel заменяя существующий файл.

_GaLs_
20.06.2007, 09:31
Обновление безопасности в IPB 2.2.х (30.05.2007)

Уязвимость найдена в расширенном редакторе сообщений Invision Power Board, который позволяет оформлять текст и сразу же видеть результат (WYSIWYG). Появление уязвимости связано с недостаточной обработкой входных данных в некоторых параметрах, передаваемых через тэги редактора. Удаленный пользователь может с помощью специально сформированного запроса выполнить произвольный код сценарий в браузере жертвы в контексте уязвимого сайта.


Пример/Эксплоит: Нет

Исправление:
Открыть файл ./jscripts/folder_rte_files/module_bbcodeloader.php
найти:
var editor_id = <?php print '"'.trim($_REQUEST['editorid']).'";'; ?>
var bbcode_id = <?php print '"'.trim($_REQUEST['id']).'";'; ?>

Заменить на:
var editor_id = <?php print '"'.trim( htmlspecialchars( substr( $_REQUEST['editorid'], 0, 30 ) ) ).'";'; ?>
var bbcode_id = <?php print '"'.trim( htmlspecialchars( substr( $_REQUEST['id'], 0, 30 ) ) ).'";'; ?>

Открыть файл ./jscripts/folder_rte_files/module_div.php
найти:
var editor_id = <?php print '"'.trim($_REQUEST['editorid']).'";'; ?>

Заменить на:
var editor_id = <?php print '"'.trim( htmlspecialchars( substr( $_REQUEST['editorid'], 0, 30 ) ) ).'";'; ?>

Открыть файл ./jscripts/folder_rte_files/module_email.php
найти:
var editor_id = <?php print '"'.trim($_REQUEST['editorid']).'";'; ?>

Заменить на:
var editor_id = <?php print '"'.trim( htmlspecialchars( substr( $_REQUEST['editorid'], 0, 30 ) ) ).'";'; ?>

Открыть файл ./jscripts/folder_rte_files/module_image.php
найти:
var editor_id = <?php print '"'.trim($_REQUEST['editorid']).'";'; ?>

Заменить на:
var editor_id = <?php print '"'.trim( htmlspecialchars( substr( $_REQUEST['editorid'], 0, 30 ) ) ).'";'; ?>

Открыть файл ./jscripts/folder_rte_files/module_link.php
найти:
var editor_id = <?php print '"'.trim($_REQUEST['editorid']).'";'; ?>

Заменить на:
var editor_id = <?php print '"'.trim( htmlspecialchars( substr( $_REQUEST['editorid'], 0, 30 ) ) ).'";'; ?>

Открыть файл ./jscripts/folder_rte_files/module_table.php
найти:
var editor_id = <?php print '"'.trim($_REQUEST['editorid']).'";'; ?>

Заменить на:
var editor_id = <?php print '"'.trim( htmlspecialchars( substr( $_REQUEST['editorid'], 0, 30 ) ) ).'"