4images Forum & Community

4images Help / Hilfe => Bug Fixes & Patches => Topic started by: kai on October 27, 2010, 12:10:43 PM

Title: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: kai on October 27, 2010, 12:10:43 PM
A cross-site request forgery (http://en.wikipedia.org/wiki/Cross-site_request_forgery) vulnerability in 4images 1.7 - 1.7.8 has been found.

To fix this please follow these 4 steps:

1.
Download the attached (http://www.4homepages.de/forum/index.php?action=dlattach;topic=28168.0;attach=5901) file csrf_utils.php file and copy it into includes/ folder of your 4images installation.


2.
Open global.php and search for the following line:

@include(ROOT_PATH.'config.php');

and insert the following code ABOVE this line:

// Initialize CSRF protection configuration
$csrf_protection_enable      = 1;
$csrf_protection_frontend    = 1;
$csrf_protection_backend     = 1;
$csrf_protection_expires     = 7200;
$csrf_protection_name        = '__csrf';
$csrf_protection_xhtml       = 1;

In the same file, search for the line:

include_once(ROOT_PATH.'includes/captcha_utils.php');

and insert the following code BELOW this line:

//-----------------------------------------------------
//--- CSRF protection ---------------------------------
//-----------------------------------------------------
include_once(ROOT_PATH.'includes/csrf_utils.php');


3.
Open includes/page_header.php and search for the following line (at the end for the file):

?>

and insert the following code ABOVE this line:

if ($csrf_protection_enable && $csrf_protection_frontend) {
  csrf_start(true);
}


4.
Open admin/admin_global.php and search for the following line:

include_once(ROOT_PATH.'admin/admin_functions.php');

and insert the following code BELOW this line:

if ($csrf_protection_enable && $csrf_protection_backend) {
  csrf_start();
}



Thanks to Russ McRee (http://holisticinfosec.org/) for finding and reporting this vulnerability!
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Jan-Lukas on October 27, 2010, 05:43:19 PM
seit ich das eingebaut habe, klappt die Suche nicht mehr von außerhalb der Galerie.
bekomme dann die Fehlermeldung

CSRF check failed.

Zur Erklärung, habe auf einer anderen Seite eine Suchbox installiert, die zu 4images führt, und bis zu diesem update auch geklappt hat.
http://www.ue-ei-portal.de

Die Suche auf 4images klappt natürlich weiterhin

LG
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Rembrandt on October 27, 2010, 06:40:55 PM
Seit dem Update bekomme ich beim Aufruf folgende Fehlermeldung (wenn keine &sessionid=*** vorhanden ist):
...
Wie kann ich die Fehlermeldung wieder abstellen?
im moment funktioniert deine seite...

ich pers. habe heute bei 4 galerien das "fix" eingebaut und nirgends gab es probleme..
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Hagen-Roderich on October 27, 2010, 06:47:08 PM
Ja, Seite funktioniert wieder  :D

Ich habe mir mal die Fehlermeldung durchgelesen und dann die Zeile 249 in der "csrf_utils.php" angeschaut.
Da waren bei mir zwei Leerzeilen hinter "?>".

Danke das Du dir die Zeit dafür genommen hast.
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Jan-Lukas on October 27, 2010, 06:48:31 PM
das Problem kann ich auch nicht bestätigen, und Session ID's werden bei mir auch nicht angezeigt.
Kannst Du denn mal eine externe suche testen ?
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Jan-Lukas on October 27, 2010, 10:34:11 PM
Diese auch nicht, gehe davon aus das keine funktionieren

Image Group
Data Backup
Rebuild Thumbnails
Shoutbox Admin
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Rembrandt on October 27, 2010, 10:36:32 PM
...
Image Group
...
meinst du meine mod?
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Jan-Lukas on October 27, 2010, 10:37:57 PM
jep
wenn ich im Admin die ID aufrufe, kommt die Meldung
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Rembrandt on October 27, 2010, 10:44:33 PM
ahjo.. so ein schmorn...
ich habe in der global.php das mal auf "0" gesetzt:
Code: [Select]
$csrf_protection_backend     = 0;
aber es wird sicher noch eine lösung dafür geben...

mfg Andi
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Jan-Lukas on October 27, 2010, 10:52:36 PM
damit klappen die internen, bei externen (meine suche)
habe ich noch $csrf_protection_frontend    = 0; auf null gestellt.
Hoffe das kai was findet
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: x23piracy on October 27, 2010, 10:57:01 PM
ahjo.. so ein schmorn...
ich habe in der global.php das mal auf "0" gesetzt:
Code: [Select]
$csrf_protection_backend     = 0;
aber es wird sicher noch eine lösung dafür geben...

mfg Andi

Hi Andi,

schaltet das den ganzen Schutz ab?


Gruß Jens
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Jan-Lukas on October 27, 2010, 11:21:21 PM
nein, wenn du das auf 0 stellst, ist alles aus

$csrf_protection_enable      = 1;
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Jan on October 28, 2010, 10:02:23 AM
Ich habe die csrf_utils.php im Hauptpost aktualisiert. Bitte ersetzt die aktuelle mit dieser, dann sollten auch die Plugins wieder funktionieren.

Zu den Konfigurationsvariablen:

Code: [Select]
$csrf_protection_enable      = 1;
Dies auf 0 gesetzt, schaltet den Schutz komplett aus (für Frontend und Backend).

Code: [Select]
$csrf_protection_frontend    = 1;
Dies auf 0 gesetzt, schaltet den Schutz komplett für das Frontend aus.

Code: [Select]
$csrf_protection_backend     = 1;
Dies auf 0 gesetzt, schaltet den Schutz komplett für das Backend aus.

Meine Empfehlung:

$csrf_protection_enable und $csrf_protection_backend sollten in jedem Fall auf 1 gesetzt sein. Falls es Probleme gibt, bitte hier melden. Im Falle von Problemen kann man $csrf_protection_backend temporär auf 0 setzen um benötigte Änderungen durchzuführen. Danach wieder auf 1 setzen.

$csrf_protection_frontend sollte man natürlich am besten auf 1 belassen. Falls es Probleme gibt, kann man hier aber vorrübergehend 0 setzen um die Galerie am Laufen zu halten.
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Rembrandt on October 28, 2010, 11:15:26 AM
Ich habe die csrf_utils.php im Hauptpost aktualisiert. Bitte ersetzt die aktuelle mit dieser, dann sollten auch die Plugins wieder funktionieren.
...
funktioniert tatsächlich  :mrgreen: danke!

mfg Andi
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Jan-Lukas on October 28, 2010, 04:42:04 PM

Meine Empfehlung:

$csrf_protection_frontend sollte man natürlich am besten auf 1 belassen. Falls es Probleme gibt, kann man hier aber vorrübergehend 0 setzen um die Galerie am Laufen zu halten.


Die Suche von außerhalb klappt aber immer noch nicht
würde ungerne drauf verzichten

LG Harald
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Jan on October 28, 2010, 05:13:32 PM
Du musst in dem Suchformular lediglich das method-Attribut auf "get" ändern:

Code: [Select]
<form target="_blank" action="http://www.online-fremdfigurenkatalog.de/search.php" method="get">
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Jan-Lukas on October 28, 2010, 05:40:46 PM
perfekt  :thumbup:
LG
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Jan on October 29, 2010, 11:08:30 AM
Ja, sorry. Ich hatte Kais Post geändert und vergessen den Link im Text anzupassen. Link stimmt jetzt.
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Sunny C. on October 29, 2010, 12:29:15 PM
Das finde ich sehr interessant :D
Quote
Scriptversion: 1.7.9 
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Jan-Lukas on October 29, 2010, 04:34:06 PM
hmm, was sollte sonst nach 1.7.8 kommen  :wink:
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: Sunny C. on October 29, 2010, 07:12:28 PM
Damit meinte ich, dass es wohl nicht mehr so lange dauern wird.
Mal sehen ob da mal richtig viel verändert wurde :D
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: surferboy on November 03, 2010, 08:55:25 AM
This is but then is not off topic.

Error message received: "CSRF check failed"

using v1.7.7, with the CSRF security fix obviously installed, on 30 Oct, after the files were updated ...

Action to cause the error message:

performing multiupload of images using V@no's mutliupload form; max setting for file upload is 18000 kb

so I set the number of images to upload at 7, which all told came to about 13 mb.  hitting upload caused the error.

I eventually determined that I needed to change the max upload setting in my php.ini file setting but ....

the looming question:

will all error messages now read as " CSRF check failed?"

Thanks,

Brian

was experiencing a similar issue last week before the csrf security fix when I tried to upload any more than three images at a time.

Tried using V@no's multi upload and Budduke's multiupload that he created for the user category.
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: X444X TEAM on November 08, 2010, 10:41:53 PM
Hi

In file admin/admin_global.php

When added

if ($csrf_protection_enable && $csrf_protection_backend) {
  csrf_start();
}

Can not be approval for the images at waiting list

I got page 404 Upon approval

Is there another solution
Title: Re: [1.7 - 1.7.8] Security fix for CSRF vulnerability
Post by: ulrich on December 05, 2010, 11:21:29 AM
I am using version 1.7 and had to deviate from these instructions in two cases since I couldn't find those lines:

global.php

In the same file, search for the line:

include_once(ROOT_PATH.'includes/captcha_utils.php');

and insert the following code BELOW this line:

//-----------------------------------------------------
//--- CSRF protection ---------------------------------
//-----------------------------------------------------
include_once(ROOT_PATH.'includes/csrf_utils.php');


Instead I did this:
Search for include(ROOT_PATH.'includes/functions.php'); and then insert the above code.

admin/admin_global.php

Open admin/admin_global.php and search for the following line:

include_once(ROOT_PATH.'admin/admin_functions.php');

and insert the following code BELOW this line:

if ($csrf_protection_enable && $csrf_protection_backend) {
  csrf_start();
}


Instead I did this:
Search for include(ROOT_PATH.'admin/admin_functions.php'); and then insert the above code.

I hope this doesn't break anything or stop this fix from working.