phpBB2.de Foren-Übersicht  
[netclusive - internet broadcasting]
 FAQ  •  Suchen  •  Download  •  Lesezeichen  •  Mitgliederliste  •  Benutzergruppen   •  Registrieren  •  Profil  •  Einloggen, um private Nachrichten zu lesen  •  Login
 
        
 
        
 

LinkLift

Nächstes Thema anzeigen
Vorheriges Thema anzeigen

Dieses Forum ist gesperrt, du kannst keine Beiträge editieren, schreiben oder beantworten.Dieses Thema ist gesperrt, du kannst keine Beiträge editieren oder beantworten.
Autor Nachricht
stefan
Administrator
Administrator



Anmeldungsdatum: 02.08.2002
Beiträge: 4735
Wohnort: Aachen

BeitragVerfasst am: Mi 10 Sep, 2003 19:52 Antworten mit ZitatNach oben 

This was posted today at phpbb.com:

We've been notified about a vulnerability in phpBB 2.0.6 (which also affects 2.0.4 and 2.0.5). The fix is noted below but please note the text that follows it.

A change was made to the way bbcode url matching is achieved around phpBB 2.0.4. This was done following complaints that our existing methods, as used in earlier releases of phpBB were too restrictive. Unfortunately the match went from too restrictive to too loose. This allows people to "break out" of the anchor href and insert arbitary markup, particularly event handling parameters. This can result in anything from "nuisance" posts to people exploiting cross-site issues to grab cookie data.

Therefore this exploit is deemed serious ... we advise all our users to deploy the following fix as soon as possible. Updated 2.0.6 packages will be available shortly for new users.

You will need to use any text editor, all operating systems come with some kind of suitable application, e.g. notepad/wordpad on Windows, ed/pico/vi/emacs on Linux/UNIX/*BSD, etc.

Using your text editor open the file: includes/bbcode.php (the extension may of course differ if you've changed it).

Find the following section of code (use your editors search facility or simply scroll through the file):
Code:
$bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
   $bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\5', $bbcode_tpl['url4']);


Replace all of the above with:
Code:
$bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
   $bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url4']);


Find:
Code:
// 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'];


Replace above with:
Code:
// 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'];


Find:
Code:
// 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);


Replace above with:
Code:
//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);


Now save the file and if appropriate upload it replacing the existing includes/bbcode.php.

This appears to fix the issue ... if you find this is not the case please notify us privately with full details of how it fails, your version of PHP and if appropriate a version that works.

_________________
Bye
Stefan

Styles Demo Forum :: Download Database :: phpBB2 Plus 1.5x Demo
phpBB2 Toplist :: International phpBB2 Support

Anwesend - Back in Business
Kein Support per PM - No Support via PM
HiddenBenutzer-Profile anzeigenPrivate Nachricht sendenE-Mail sendenWebsite dieses Benutzers besuchenICQ-Nummer
Google







Verfasst am: Nach oben

vrflyer
phpBB2.de User
phpBB2.de User



Anmeldungsdatum: 24.06.2003
Beiträge: 4

BeitragVerfasst am: Mo 29 Sep, 2003 18:17 Antworten mit ZitatNach oben 

FYI: This "fix" doesn't work well in phpBB v2.0.4 just in case anyone cared >>>

Code below asked to look for:

Code:
      // [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'];


But phpBB 2.0.4 has:

Code:
   // [url]xxxx://www.phpbb.com[/url] code..
   $patterns[] = "#\[url\]([a-z0-9]+?://){1}([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)\[/url\]#is";
   $replacements[] = $bbcode_tpl['url1'];

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

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

   // [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix).
   $patterns[] = "#\[url=(([\w\-]+\.)*?[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)\](.*?)\[/url\]#si";
   $replacements[] = $bbcode_tpl['url4'];


Fix is aking to change this to:

Code:
// [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'];


Also problem with this part of the code:

Code:
// 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);


But phpBB 2.0.4 has:

Code:
// 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("#([\t\r\n ])([a-z0-9]+?){1}://([\w\-]+\.([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)#i", '\1<a href="\2://\3" target="_blank">\2://\3</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("#([\t\r\n ])(www|ftp)\.(([\w\-]+\.)*[\w]+(:[0-9]+)?(/[^ \"\n\r\t<]*)?)#i", '\1<a href="http://\2.\3" target="_blank">\2.\3</a>', $ret);



When changing all of this .. It messes up the BBCode when tagging URL's.... So if an URL does not have a "www" prefix it breaks the BBCode or it doesn't show up at all ....
OfflineBenutzer-Profile anzeigenPrivate Nachricht senden
Beiträge der letzten Zeit anzeigen:      
Dieses Forum ist gesperrt, du kannst keine Beiträge editieren, schreiben oder beantworten.Dieses Thema ist gesperrt, du kannst keine Beiträge editieren oder beantworten.

Nächstes Thema anzeigen
Vorheriges Thema anzeigen
Du kannst keine Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum nicht antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.
Du kannst Dateien in diesem Forum nicht posten
Du kannst Dateien in diesem Forum nicht herunterladen

Ähnliche Beiträge
Thema Autor Forum Antworten Verfasst am
Probleme mit bbcode Parser - Merkwürd... pordox phpBB2.x - Support 2 Fr 27 März, 2009 20:09 Letzten Beitrag anzeigen
BBCODE teilweise deaktivieren Kirsch phpBB2.x - MOD Request 0 Mi 12 Nov, 2008 00:35 Letzten Beitrag anzeigen
Complete Banner MOD - Security Vulner... uk_martin Plus 1.53 Beta Support 2 Mi 16 Jul, 2008 00:51 Letzten Beitrag anzeigen
Beim BBCODE [Code] ein/aufklappen dgroeser phpBB2.x - Support 0 Do 17 Apr, 2008 16:18 Letzten Beitrag anzeigen
bbcode für "Off Topic" jevo phpBB2.x - MOD Request 0 Di 08 Apr, 2008 22:12 Letzten Beitrag anzeigen