Hello, i have problem with Htmlpurifier settings. If my input is for example (its URL for logging out):
<img src="http://www.example.com/app/public/user/login/logout">
Htmlpurifier is not able to purify this input. Only add "ALT" but the code is processed and user is logged out. Is any possibility to handle this?
My htmlpurifier settings is:
require_once('htmlpurifier/library/HTMLPurifier.auto.php');
$config = HTMLPurifier_Config::createDefault();
$config->set('Core.Encoding', 'UTF-8');
$config->set('HTML.Doctype', 'HTML 4.01 Transitional');
$config->set('Core.RemoveInvalidImg',true);
$purifier = new HTMLPurifier($config);
$clean = $purifier->purify($dirty);
Thanks for any advice
|
Re: IMG SRC February 12, 2012 08:58PM |
Admin Registered: 6 years ago Posts: 2,632 |
|
Re: IMG SRC February 17, 2012 04:31AM |
Registered: 3 years ago Posts: 61 |
Htmlpurifier is not able to purify this input. Only add "ALT" but the code is processed and user is logged out. Is any possibility to handle this?
There's no (sane) way to handle this, because HTML Purifier doesn't know what a link may or may not cause. HTML Purifier is not your problem here, though, you generally have a CSRF vulnerability you need to take care of - so what you're looking for are solutions to prevent cross-site request forgery, e.g. securing your logout with a CSRF token.
If all you want to do is prevent a website to have the word 'logout' in them, you can write an attribute transformation that strips 'href' if its value contains 'logout'.
(Edit: Fixed formatting after an HTML escaping issue ravaged the forum.)
Edited 1 time(s). Last edit at 07/30/2012 01:57PM by pinkgothic.
|
Pankaj Garg
Re: IMG SRCFebruary 06, 2013 07:41AM |
Hi,
Below is the code for Image,
<img src="cid:ii_13caf061fab44f94" alt="Inline image 1">
HTML Purifier removes this image's src, I have tried HTML.Allowed as img[alt|src] and also set Core.RemoveInvalidImg to false.
but still not receiving the src as it is.
Please assist. Thanks in anticipation.
Regards Pankaj Garg
|
Re: IMG SRC February 06, 2013 09:14AM |
Registered: 5 years ago Posts: 204 |
Hello, i have problem with Htmlpurifier settings. If my input is for example (its URL for logging out):
<img src="http://www.example.com/app/public/user/login/logout">Htmlpurifier is not able to purify this input. Only add "ALT" but the code is processed and user is logged out. Is any possibility to handle this?
My htmlpurifier settings is:
require_once('htmlpurifier/library/HTMLPurifier.auto.php'); $config = HTMLPurifier_Config::createDefault(); $config->set('Core.Encoding', 'UTF-8'); $config->set('HTML.Doctype', 'HTML 4.01 Transitional'); $config->set('Core.RemoveInvalidImg',true); $purifier = new HTMLPurifier($config); $clean = $purifier->purify($dirty);Thanks for any advice
I'm pretty sure that the link in the img src is not a valid image file. it should be pointing to a gif, jpg, png file etc. which is why purifier is removing it.
|
Re: IMG SRC February 06, 2013 04:54PM |
Registered: 3 years ago Posts: 61 |
@Pankaj Garg: cid is not a supported URL 'schema'. You should use the HTML Purifier after cid references have been changed to URL references. :) If that's not possible, you may have to look into providing a URL schema handling class. (Note: You can use the HTML Purifier to pretransform the img-src to change cid into img-src, I've done this before in a project I used to work in. I think Edward may even have some code from me on that subject... dunno if he's still considering making it a feature, though. :) )
@vaughan: The reported problem is that HTML Purifier isn't removing it, though. And that is its expected/designed behaviour, too - it can't guess what a link is going to do and if the HTML is going to exploit an issue on the src-named server, it can only prevent exploits it knows about (those that would strike client-side, basically, or those that would strike the Purifier itself (e.g. by trying to get the parser to tie itself into a knot), not those of external applications... and this is a vulnerability in the external application, it's a CSRF issue).
|
Re: IMG SRC February 06, 2013 06:29PM |
Admin Registered: 6 years ago Posts: 2,632 |
Whooops it looks like I never got around to actually reviewing the CID patch (two years late, rawr!) -_- Probably should go look at that now...
HTML Purifier, Standards-Compliant HTML Filtering
|
Re: IMG SRC February 07, 2013 06:02PM |
Registered: 3 years ago Posts: 61 |
|
Re: IMG SRC February 17, 2013 07:00PM |
Admin Registered: 6 years ago Posts: 2,632 |
OK, it looks like there are some changes that need to be made:
I think those are the biggies.
HTML Purifier, Standards-Compliant HTML Filtering