Перейти к публикации
View in the app

A better way to browse. Learn more.

Дизайн и модификация Invision Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

XSS инъекция через прикрепляемые файлы

Опубликовано:

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

 

Скачать измененный файл для версий 2.1.x: http://forums.invisionpower.com/index.php?...st&id=11582

Скачать измененный файл для версий 2.2.x: http://forums.invisionpower.com/index.php?...st&id=11583

 

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

 

Исправление 2.1.7:

Открыть файл ./ips_kernel/class_upload.php, найти:

 

		if ( $this->make_script_safe )
	{
		if ( preg_match( "/\.(cgi|pl|js|asp|php|html|htm|jsp|jar)$/i", $FILE_NAME ) )
		{

			$FILE_TYPE				 = 'text/plain';
			$this->file_extension	  = 'txt';
		}
	}

 

Заменить на:

 

		$renamed = 0;

		if ( $this->make_script_safe )
		{
			if ( preg_match( "/\.(cgi|pl|js|asp|php|html|htm|jsp|jar)/", $FILE_NAME ) )
			{
				$FILE_TYPE				 = 'text/plain';
				$this->file_extension	  = 'txt';

			$renamed = 1;
			}
		}

 

Найти:

 

 	if ( ! @move_uploaded_file( $_FILES[ $this->upload_form_field ]['tmp_name'], $this->saved_upload_name) )
	{
		$this->error_no = 4;
		return;
	}
	else
	{
		@chmod( $this->saved_upload_name, 0777 );
	}

 

Добавить после:

 

		if( !$renamed )
	{
		$this->check_xss_infile();

		if( $this->error_no )
		{
			return;
		}
	}

 

Найти:

 

	/*-------------------------------------------------------------------------*/
// INTERNAL: Get file extension
/*-------------------------------------------------------------------------*/

/**
* Returns the file extension of the current filename
*
* @param string Filename
*/

function _get_file_extension($file)
{
	return strtolower( str_replace( ".", "", substr( $file, strrpos( $file, '.' ) ) ) );
}

 

Добавить перед:

 

	/*-------------------------------------------------------------------------*/
// INTERNAL: Check for XSS inside file
/*-------------------------------------------------------------------------*/

/**
* Checks for XSS inside file.  If found, sets error_no to 5 and returns
*
* @param void
*/

function check_xss_infile()
{
	// HTML added inside an inline file is not good in IE...

	$fh = fopen( $this->saved_upload_name, 'rb' );

	$file_check = fread( $fh, 512 );

	fclose( $fh );

	if( !$file_check )
	{
		@unlink( $this->saved_upload_name );
		$this->error_no = 5;
		return;
	}

	# Thanks to Nicolas Grekas from comments at www.splitbrain.org for helping to identify all vulnerable HTML tags

	else if( preg_match( "#<script|<html|<head|<title|<body|<pre|<table|<a\s+href|<img|<plaintext#si", $file_check ) )
	{
		@unlink( $this->saved_upload_name );
		$this->error_no = 5;
		return;
	}
}

 

Исправление 2.2.2:

Открыть файл ./ips_kernel/class_upload.php, найти:

 

		if ( $this->make_script_safe )
	{
		if ( preg_match( "/\.(cgi|pl|js|asp|php|html|htm|jsp|jar)$/i", $FILE_NAME ) )
		{
			$FILE_TYPE				 = 'text/plain';
			$this->file_extension	  = 'txt';
		}
	}

 

Заменить на:

 

		$renamed = 0;

		if ( $this->make_script_safe )
		{
			if ( preg_match( "/\.(cgi|pl|js|asp|php|html|htm|jsp|jar)/", $FILE_NAME ) )
			{
				$FILE_TYPE				 = 'text/plain';
				$this->file_extension	  = 'txt';
			$this->parsed_file_name	   = preg_replace( "/\.(cgi|pl|js|asp|php|html|htm|jsp|jar)(\.|$)/i", "$2", $this->parsed_file_name );

			$renamed = 1;
			}
		}

 

Найти:

 

 	if ( ! @move_uploaded_file( $_FILES[ $this->upload_form_field ]['tmp_name'], $this->saved_upload_name) )
	{
		$this->error_no = 4;
		return;
	}
	else
	{
		@chmod( $this->saved_upload_name, 0777 );
	}

 

Добавить после:

 

		if( !$renamed )
	{
		$this->check_xss_infile();

		if( $this->error_no )
		{
			return;
		}
	}

 

Найти:

 

	/*-------------------------------------------------------------------------*/
// INTERNAL: Get file extension
/*-------------------------------------------------------------------------*/

/**
* Returns the file extension of the current filename
*
* @param string Filename
*/

function _get_file_extension($file)
{
	return strtolower( str_replace( ".", "", substr( $file, strrpos( $file, '.' ) ) ) );
}

 

Добавить перед:

 

	/*-------------------------------------------------------------------------*/
// INTERNAL: Check for XSS inside file
/*-------------------------------------------------------------------------*/

/**
* Checks for XSS inside file.  If found, sets error_no to 5 and returns
*
* @param void
*/

function check_xss_infile()
{
	// HTML added inside an inline file is not good in IE...

	$fh = fopen( $this->saved_upload_name, 'rb' );

	$file_check = fread( $fh, 512 );

	fclose( $fh );

	if( !$file_check )
	{
		@unlink( $this->saved_upload_name );
		$this->error_no = 5;
		return;
	}

	# Thanks to Nicolas Grekas from comments at www.splitbrain.org for helping to identify all vulnerable HTML tags

	else if( preg_match( "#<script|<html|<head|<title|<body|<pre|<table|<a\s+href|<img|<plaintext#si", $file_check ) )
	{
		@unlink( $this->saved_upload_name );
		$this->error_no = 5;
		return;
	}
}

Рекомендованные сообщения

No posts to show
Гость
Эта тема закрыта для дальнейших сообщений.

Сейчас на странице 0

  • Нет пользователей, просматривающих эту страницу.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.