|
|
|
|
|
|
IT Security and Insecurity Portal |
|
|
Link in forum |
|
Posted: Sun Jan 13, 2008 9:54 am |
|
|
shmk |
Active user |
|
|
Joined: Jul 22, 2004 |
Posts: 25 |
|
|
|
|
|
|
|
What's the most secure PHP filter that allow users to insert links to sites or images in a forum without flaws in security? (regarding xss and csrf overall) |
|
|
|
|
|
|
|
|
Posted: Sun Jan 13, 2008 12:23 pm |
|
|
waraxe |
Site admin |
|
|
Joined: May 11, 2004 |
Posts: 2407 |
Location: Estonia, Tartu |
|
|
|
|
|
|
It's always possible to fool the security filters. Attacker can first place normal picture to remote server and then post img link to it. This will pass all security tests and posting will be allowed. After that attacker just changes original image on remote server with anything else he wants. Attacker can use Amapche's mod_rewrite, so that (victim) client browser will ask for jpg and will get 301/302 redirect pointing somewhere - classical CSRF case through GET method. I have seen more paranoid solutions, where webserver will check remote image validity within ANY request, and even this will not help, because image hosting server can serve different content based on client IP - so that checking webserver will see this as normal image, but subsequent victim browser will get mailicious CSRF redirection. |
|
|
|
|
|
|
|
|
Posted: Sun Jan 13, 2008 1:42 pm |
|
|
shmk |
Active user |
|
|
Joined: Jul 22, 2004 |
Posts: 25 |
|
|
|
|
|
|
|
waraxe wrote: | It's always possible to fool the security filters. Attacker can first place normal picture to remote server and then post img link to it. This will pass all security tests and posting will be allowed. After that attacker just changes original image on remote server with anything else he wants. Attacker can use Amapche's mod_rewrite, so that (victim) client browser will ask for jpg and will get 301/302 redirect pointing somewhere - classical CSRF case through GET method. I have seen more paranoid solutions, where webserver will check remote image validity within ANY request, and even this will not help, because image hosting server can serve different content based on client IP - so that checking webserver will see this as normal image, but subsequent victim browser will get mailicious CSRF redirection. |
So the only secure system is disable external links?
And a "quite" secure system?
The classical hidden token system could limit the CSRF or it's quite useless? (i saw it mainly in POST form but it could be used in GET too?) |
|
|
|
|
|
|
|
|
Posted: Sun Jan 13, 2008 2:33 pm |
|
|
waraxe |
Site admin |
|
|
Joined: May 11, 2004 |
Posts: 2407 |
Location: Estonia, Tartu |
|
|
|
|
|
|
Anti-CSRF measures with random token or even with CAPTCHA (for critical requests) are very effective by my personal experience. So if you have securely written code with no potential CSRF threats, then linking remote images is not big security risk. But you must be sure about XSS too, because if there is XSS possibilities, then hidden token protection can be bypassed - because attacker can read token values right from html source or even submit POST forms without user interaction. Most secure anti-csrf still is CAPTCHA - critical operations, like new admin account creation, password change, file deletion - these are the situations, where CAPTCHA is useful. |
|
|
|
|
|
|
|
|
Posted: Sun Jan 13, 2008 3:02 pm |
|
|
shmk |
Active user |
|
|
Joined: Jul 22, 2004 |
Posts: 25 |
|
|
|
|
|
|
|
waraxe wrote: | Anti-CSRF measures with random token or even with CAPTCHA (for critical requests) are very effective by my personal experience. So if you have securely written code with no potential CSRF threats, then linking remote images is not big security risk. But you must be sure about XSS too, because if there is XSS possibilities, then hidden token protection can be bypassed - because attacker can read token values right from html source or even submit POST forms without user interaction. Most secure anti-csrf still is CAPTCHA - critical operations, like new admin account creation, password change, file deletion - these are the situations, where CAPTCHA is useful. |
Many thanks, so a token + capthca and maybe a verification email could block CSRF.
Now I need to analyze the BIG XSS problem
At this time I have only a htmlentities(strip_tags(),ENT_QUOTES) |
|
|
|
|
|
|
|
|
Posted: Mon Jan 14, 2008 9:51 pm |
|
|
shmk |
Active user |
|
|
Joined: Jul 22, 2004 |
Posts: 25 |
|
|
|
|
|
|
|
waraxe wrote: | Attacker can first place normal picture to remote server and then post img link to it. This will pass all security tests and posting will be allowed. After that attacker just changes original image on remote server with anything else he wants. |
With this stratagem every forum security could be bypassed? Yours PHPBB too? |
|
|
|
|
Posted: Mon Jan 14, 2008 11:08 pm |
|
|
waraxe |
Site admin |
|
|
Joined: May 11, 2004 |
Posts: 2407 |
Location: Estonia, Tartu |
|
|
|
|
|
|
Yes - in this forum remote images are allowed in postings so that CSRF possibilities are real.
Still - remote image can forge only GET request, and as much as i know and i have looked at phpbb source, most of the operations in user and admin control panel are based on POST method. So potential security impact is low here.
Bottom line - use POST as much as possible in any critical operations. This will cripple image-based CSRF attacks ... |
|
|
|
|
www.waraxe.us Forum Index -> Php
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
All times are GMT
Page 1 of 1
|
|
|
Powered by phpBB © 2001-2008 phpBB Group
|
|
|
|
|