Part of the EllisLab Network
   
1 of 2
1
GLOBAL XSS FILTERING on 2.0.2 and CKEDITOR
Posted: 10 April 2011 12:16 PM   [ Ignore ]  
Summer Student
Avatar
Total Posts:  2
Joined  12-28-2008

Found this very weird bug today after updating to 2.0.2. If i tried to insert an image into ckeditor and set it’s dimensions via the editor form, the generated inline style would not save to the database after POST.
I do not have any other type of POST filtering other than this option enabled in config.php. After I’ve set it to FALSE, it saved ok.

Bug or not? Where should I report it?

Profile
 
 
Posted: 10 April 2011 01:10 PM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  5399
Joined  06-19-2009

Sounds like the CSRF Protection.

InsiteFX

 Signature 

Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View

Profile
 
 
Posted: 12 April 2011 02:05 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Avatar
Total Posts:  6
Joined  05-13-2010

I’m having problems with global_xss_filtering too.

Before 2.0.2 it worked fine but now it seems to be stripping simple HTML tags (styles, etc.)

Worked before update, doesn’t work after - sure seems like a bug to me.

Profile
 
 
Posted: 10 May 2011 01:45 AM   [ Ignore ]   [ # 3 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  125
Joined  10-14-2010

Same here. Switching off XSS_filter all tags (style) go through well. I think it’s not a problem with my current project because I use Tinymce behind admin area..
And, in 1.7.x were all good.

Profile
 
 
Posted: 12 May 2011 04:49 AM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  29
Joined  02-09-2010

Confirmed. XSS_filtering is the culprit here. I’ve built 7 websites with Tinymce since CI 2.0 release and everything worked well. But the latest project was given CI 2.0.2 and when concocted with Tinymce it filters out image alignment.
I’m not sure I feel comfortable with XSS filtering disabled. Perhaps we could add an exception somewhere? Interestingly properties like “width” are not filtered out. It seems that “style” definition gets removed.

Profile
 
 
Posted: 12 May 2011 07:11 AM   [ Ignore ]   [ # 5 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  125
Joined  10-14-2010
xarazar - 12 May 2011 08:49 AM

Confirmed. XSS_filtering is the culprit here. I’ve built 7 websites with Tinymce since CI 2.0 release and everything worked well. But the latest project was given CI 2.0.2 and when concocted with Tinymce it filters out image alignment.
I’m not sure I feel comfortable with XSS filtering disabled. Perhaps we could add an exception somewhere? Interestingly properties like “width” are not filtered out. It seems that “style” definition gets removed.

Yes only style property filtered out. I set FALSE the global xss filtering, I use it manually, and with variables filled from tinymce textarea I use htmlentities and html_entitiy_decode, dunno it’s reasonable protection or not..

Profile
 
 
Posted: 19 May 2011 01:05 PM   [ Ignore ]   [ # 6 ]  
Summer Student
Avatar
Total Posts:  16
Joined  11-19-2010

yep, same here with CodeIgniter 2.0.2. After turning off global_xss filtering everything works like a charm.
But i still want to use it so i made quick workaround.
In file system/core/security i modified function _remove_evil_attributes (around line 579).

// All javascript event handlers (e.g. onload, onclick, onmouseover), style, and xmlns
        
$allowed = array(your allowed url's without domain like '/admin/edittext/');
        if(in_array($_SERVER['
REQUEST_URI'],$allowed)){
            $evil_attributes = array('
on\w*', 'xmlns');
        }else{
            $evil_attributes = array('
on\w*', 'style', 'xmlns');
        } 
 Signature 

‎“Sometimes you’re gonna get odd error syntax, unexpected T_PAAMAYIM_NEKUDOTAYIM and you’re like, what in the world is that thing i have no idea what went wrong in my code. In english that error means you screwed up the references to an object” Kevin Skoglund

Profile
 
 
Posted: 31 May 2011 02:30 PM   [ Ignore ]   [ # 7 ]  
Summer Student
Total Posts:  30
Joined  03-17-2011

Very strange ....
cannot send html content from POST form… I use ckeditor, and after post, every html tag is cleaning. This in localhost (CI 2.0.2, php 5.3)
BUT… in my host, work fine…................ (CI 2.0.2, php 5.2)
Both use same config.

I try remove ckeditor… but same result.
I did var_dump($_POST), and the content is clean too..

What the problem !?!?

Profile
 
 
Posted: 10 June 2011 08:11 PM   [ Ignore ]   [ # 8 ]  
Summer Student
Total Posts:  10
Joined  05-31-2011

I’ve got the same problem, any fix for this?

Profile
 
 
Posted: 17 June 2011 01:31 PM   [ Ignore ]   [ # 9 ]  
Summer Student
Avatar
Total Posts:  25
Joined  01-31-2007

I just removed the element ‘style’ from that array in the core and it worked again. Why is that even there? What malicious code can someone put in a style tag?

Profile
 
 
Posted: 17 June 2011 01:38 PM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  439
Joined  01-31-2011
style="background-image(http://sucks.com/any.png)" 

and any.png is a malicious controller
could that be harmful?

 Signature 

Lang uri library - Web Coders Blog (coming… not so…. soon)

Profile
 
 
Posted: 07 July 2011 08:03 AM   [ Ignore ]   [ # 11 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  123
Joined  04-23-2011

hey guys i want to implement ckeditor in codeigniter 2.0.2
how can i do that.
please help me.

Profile
 
 
Posted: 22 July 2011 12:14 AM   [ Ignore ]   [ # 12 ]  
Grad Student
Avatar
Rank
Total Posts:  50
Joined  11-25-2008

Is this really a CI 2.02 bug? Just lost a whole hour trying to figure out what’s wrong with the ckeditor aligment.
Disabling global XSS on config worked.
Is there a way to disable global for this specific field? Or any other workaround available?

Btw, Sudhakar@CI, implement ckeditor on CI is a breeze. Have you checked the forum?
http://codeigniter.com/forums/viewthread/127374/
Or even CI wiki?

Can anyone share some toughts on this issue? I need to save html on this project. Disabling styles on POST is the reason why my client clients are goin bananas and disable global XSS is not an option as well.

Thanks.


Just checked another post (http://codeigniter.com/forums/viewthread/191399/#903478) where bubbafoley suggested:

$config['global_xss_filtering'TRUE

and then

$username $this->input->post('username'); // filtered
$password $this->input->post('password'FALSE); // unfiltered 

But this does not work. Anyone?

Profile
 
 
Posted: 22 July 2011 03:39 AM   [ Ignore ]   [ # 13 ]  
Summer Student
Total Posts:  29
Joined  02-09-2010

Hi hyperfire,
Not really a bug but the CI guys decided that the style attribute is “evil”. Perhaps it is, I’m not aware of it causing security issues, but it doesn’t seem like there is a way to remove it from the list of evil attributes other than modifying one of the core functions (outlined above). I simply removed it from the evil attribute lists and everything works. Has to do until a fix is available. Would be nice to a configurable evil attribute list.

Profile
 
 
Posted: 22 July 2011 05:10 AM   [ Ignore ]   [ # 14 ]  
Grad Student
Avatar
Rank
Total Posts:  50
Joined  11-25-2008

Well, as I had to move on, I have decided to disable the global xss filtering (a real PITA because all forms had to be updated, etc) and to implement the html purifier (with a gentle help of the html purifier CI lib http://codeigniter.com/wiki/htmlpurifier/) for the fields with ckeditor enabled. I feel safe now. (sort of, lol)

Profile
 
 
Posted: 28 July 2011 03:29 AM   [ Ignore ]   [ # 15 ]  
Summer Student
Total Posts:  28
Joined  09-06-2008

We turned off the XSS filtering in the config file and extended the Input class. We turned on XSS filtering as default for every function in our MY_Input. So as long as we don’t sent a “FALSE” as second parameter in functions like $this->input->post(), the field is XSS filtered.

We also extended the Securty class with our own MY_Security. When a FALSE is sent to $this->input->post(), the field gets still XSS cleaned, but only then with less options. The style tag for example ain’t filtered.

This way our regular fields are filtered the normal way and our CKEditor fields are filtered, but not as thoroughly as the regular fields. Seems to work quiet okay this way smile

Profile
 
 
   
1 of 2
1