Pagina 1 van 1

Belangrijke Bugfix in phpBB

Geplaatst: 10 sep 2003, 20:52
door Aeolus
Onlangs zijn wij op de hoogte gebracht van een beveiligingslek wat zich in phpBB 2.0.6. zit (tevens 2.0.5 en 2.0.4.). De fix staat hieronder beschreven.

In phpBB 2.0.4. is er een verandering gemaakt op de manier waarop de bbcode URL internetadressen matched. Dit is gedaan omdat er meerdere klachten waren over de vorige manier waarop dit altijd werkte. Nu blijkt dat de verandering van teveel restricties, naar te weinig restricties gegaan is, en dat er mogelijkheden zijn om via de URL tag op sommige manieren dingen te veroorzaken die niet geheel de bedoeling zijn ;)

We adviseren al onze users dan ook bij deze, om de hieronder beschreven fix zo spoedig mogelijk uit te voeren.

Code: Selecteer alles

# 
#-----[ OPEN ]------------------------------------------ 
#
includes/bbcode.php

# 
#-----[ ZOEK ]------------------------------------------ 
#

$bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']); 
   $bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\5', $bbcode_tpl['url4']);

# 
#-----[ VERVANG DOOR ]------------------------------------------ 
#

$bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']); 
   $bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url4']);

# 
#-----[ ZOEK ]------------------------------------------ 
#

// matches a [url]xxxx://www.phpbb.com[/url] code.. 
   $patterns[] = "#\[url\]([\w]+?://.*?[^ \"\n\r\t<]*?)\[/url\]#is"; 
   $replacements[] = $bbcode_tpl['url1']; 

   // [url]www.phpbb.com[/url] code.. (no xxxx:// prefix). 
   $patterns[] = "#\[url\]((www|ftp)\.([\w\-]+\.)*?[\w\-]+\.[a-z]{2,4}(:?[0-9]*?/[^ \"\n\r\t<]*)?)\[/url\]#is"; 
   $replacements[] = $bbcode_tpl['url2']; 

   // [url=xxxx://www.phpbb.com]phpBB[/url] code.. 
   $patterns[] = "#\[url=([\w]+?://.*?[^ \"\n\r\t<]*?)\](.*?)\[/url\]#is"; 
   $replacements[] = $bbcode_tpl['url3']; 

   // [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix). 
   $patterns[] = "#\[url=((www|ftp)\.([\w\-]+\.)*?[\w\-]+\.[a-z]{2,4}(:?[0-9]*?/[^ \"\n\r\t<]*)?)\](.*?)\[/url\]#is"; 
   $replacements[] = $bbcode_tpl['url4'];

# 
#-----[ VERVANG DOOR ]------------------------------------------ 
#

// matches a [url]xxxx://www.phpbb.com[/url] code.. 
   $patterns[] = "#\[url\]([\w]+?://[^ \"\n\r\t<]*?)\[/url\]#is"; 
   $replacements[] = $bbcode_tpl['url1']; 

   // [url]www.phpbb.com[/url] code.. (no xxxx:// prefix). 
   $patterns[] = "#\[url\]((www|ftp)\.[^ \"\n\r\t<]*?)\[/url\]#is"; 
   $replacements[] = $bbcode_tpl['url2']; 

   // [url=xxxx://www.phpbb.com]phpBB[/url] code.. 
   $patterns[] = "#\[url=([\w]+?://[^ \"\n\r\t<]*?)\](.*?)\[/url\]#is"; 
   $replacements[] = $bbcode_tpl['url3']; 

   // [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix). 
   $patterns[] = "#\[url=((www|ftp)\.[^ \"\n\r\t<]*?)\](.*?)\[/url\]#is"; 
   $replacements[] = $bbcode_tpl['url4']; 

# 
#-----[ ZOEK ]------------------------------------------ 
#

// matches an "xxxx://yyyy" URL at the start of a line, or after a space. 
   // xxxx can only be alpha characters. 
   // yyyy is anything up to the first space, newline, comma, double quote or < 
   $ret = preg_replace("#(^|[\n ])([\w]+?://.*?[^ \"\n\r\t<]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret); 

   // matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing 
   // Must contain at least 2 dots. xxxx contains either alphanum, or "-" 
   // zzzz is optional.. will contain everything up to the first space, newline, 
   // comma, double quote or <. 
   $ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\-]+\.[\w\-.\~]+(?:/[^ \"\t\n\r<]*)?)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);


# 
#-----[ VERVANG DOOR ]------------------------------------------ 
#

//matches an "xxxx://yyyy" URL at the start of a line, or after a space. 
   // xxxx can only be alpha characters. 
   // yyyy is anything up to the first space, newline, comma, double quote or < 
   $ret = preg_replace("#(^|[\n ])([\w]+?://[^ \"\n\r\t<]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret); 

   // matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing 
   // Must contain at least 2 dots. xxxx contains either alphanum, or "-" 
   // zzzz is optional.. will contain everything up to the first space, newline, 
   // comma, double quote or <. 
   $ret = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);

# 
#-----[ SLUIT EN UPLOAD ]------------------------------------------ 
#
Dit lost hoogstwaarschijnlijk het lek op. Mocht je van mening zijn nog steeds last te hebben van deze bug, laat het ons dan via pm weten, op een zo gedetailleerd mogelijke manier over wat er misgaat.


Dit is een verkort vertaalde versie van het verhaal zoals het op phpBB.com te lezen is.
http://www.phpbb.com/phpBB/viewtopic.php?t=135116 voor het complete verhaal, in het engels.

Geplaatst: 10 sep 2003, 22:26
door Spikey
Bij de downloads staat een premodded versie van includes/bbcode.php voor phpBB 2.06 gemaakt door Carlo:

Let op: als je in het bestaande bestand wijzigingen/mods hebt aangebracht zullen deze met het uploaden van dit bestand overschreven worden en niet meer werken.

http://www.phpbb.nl/dload.php?action=file&id=25