How many security holes

Learn about Security for code and servers. Learn how to secure your site and your code. Learn about hacking prevention, finding and identifying exploits, and recognising vulnerabilities. Plus, Weekly Security tips and Tutorials.
Forum rules
Post questions related to security, analyse and learn about vulnerabilities and exploits within code to protect yourself against hackers.

Re: How many security holes

Postby Erik Frèrejean » 18 Aug 2009, 04:22

WyriHaximus wrote:
Obsidian wrote:That is BEGGING to be hacked. :lol:

Besides that the only serious leak I could find was $PHP_SELF and maybe some minor issues if the data in the $_SESSION varriable isn't properly checked. Aside from that the code is just horrible :banghead:

$_SERVER is user input, never trust user input. Therefore you must validate those variables before using them in a query. I'm not sure whether you can actually inject malicious stuff into $_SERVER['REMOTE_ADDR'] but even so you shouldn't trust any data that is influenced one way or an other by the user.
Image Proud member of the phpBB support team
Image STG Support team member | Image STG Moderator team member
Image
User avatar
Erik Frèrejean    
phpBB Team Member
phpBB Team Member
 
Posts: 1114
Joined: 03 Dec 2007, 00:49
Location: USERS_TABLE
Favorite Team: New Orleans Saints
Gender: Male
phpBB Knowledge: 10




phpBB Academy at StarTrekGuide
Support STG
Using PayPal Donate

Re: How many security holes

Postby WyriHaximus » 18 Aug 2009, 04:37

Erik Frèrejean wrote:
WyriHaximus wrote:
Obsidian wrote:That is BEGGING to be hacked. :lol:

Besides that the only serious leak I could find was $PHP_SELF and maybe some minor issues if the data in the $_SESSION varriable isn't properly checked. Aside from that the code is just horrible :banghead:

$_SERVER is user input, never trust user input. Therefore you must validate those variables before using them in a query. I'm not sure whether you can actually inject malicious stuff into $_SERVER['REMOTE_ADDR'] but even so you shouldn't trust any data that is influenced one way or an other by the user.

Well you could insert something into $_SERVER['REMOTE_ADDR'] if you manage to trick apache to accept some faulty IP. I wouldn't take everything in $_SERVER for granted but $_SERVER['REMOTE_ADDR'] is a pretty safe one. Still it's wise to check and escape it if needed there are several tools/frameworks that already do that for you and for the sake of humanity in doubt always double check to be sure :).
Image
User avatar
WyriHaximus    
MOD Author
MOD Author
 
Posts: 17
Joined: 28 Jul 2009, 04:46
Gender: Male
phpBB Knowledge: 9

Re: How many security holes

Postby Erik Frèrejean » 18 Aug 2009, 04:51

WyriHaximus wrote:if you manage to trick apache to accept some faulty IP.

Or just a bug in the apache version that is running on the server.

WyriHaximus wrote: I wouldn't take everything in $_SERVER for granted

And you shouldn't as its user input.
WyriHaximus wrote:but $_SERVER['REMOTE_ADDR'] is a pretty safe one.

Sure its "pretty" save, but that is an assumption on data that comes from the user.
Image Proud member of the phpBB support team
Image STG Support team member | Image STG Moderator team member
Image
User avatar
Erik Frèrejean    
phpBB Team Member
phpBB Team Member
 
Posts: 1114
Joined: 03 Dec 2007, 00:49
Location: USERS_TABLE
Favorite Team: New Orleans Saints
Gender: Male
phpBB Knowledge: 10

Re: How many security holes

Postby WyriHaximus » 18 Aug 2009, 05:50

Erik Frèrejean wrote:
WyriHaximus wrote:if you manage to trick apache to accept some faulty IP.

Or just a bug in the apache version that is running on the server.

WyriHaximus wrote: I wouldn't take everything in $_SERVER for granted

And you shouldn't as its user input.
WyriHaximus wrote:but $_SERVER['REMOTE_ADDR'] is a pretty safe one.

Sure its "pretty" save, but that is an assumption on data that comes from the user.

Exactly :).
Image
User avatar
WyriHaximus    
MOD Author
MOD Author
 
Posts: 17
Joined: 28 Jul 2009, 04:46
Gender: Male
phpBB Knowledge: 9

Re: How many security holes

Postby zaphod » 01 Nov 2009, 07:13

Actually, I would be prone to trust $_SERVER['REMOTE_ADDR'] , as if that is incorrect, the server will not know where to send the response (as in a spoofed IP). I have yet to have a problem with that.

The function you should be wary of, is $_SERVER["REMOTE_HOST"] . If there has been some DNS poisoning going on, this will steer you wrong, and even gethostbyaddr($detected_ip) can't be perfectly trusted. However, once they started hopping DNS ports, this is alot more sure. Of course, if global variables are on, all bets are off.

But other than that, the lack of variable sanitization before playing with SQL, is atrocious in the example script. :this: Skiddies dream of stuff like that being exposed.

Zap :)
Get protected, stay protected...
SpambotSecurity.com the home of ZB Block
User avatar
zaphod    
Crewman
Crewman
 
Posts: 7
Joined: 01 Nov 2009, 05:26
Location: Casper, WY
Favorite Team: none
Gender: Male
phpBB Knowledge: 8

Re: How many security holes

Postby Erik Frèrejean » 02 Nov 2009, 06:49

zaphod wrote:Actually, I would be prone to trust $_SERVER['REMOTE_ADDR'] , as if that is incorrect, the server will not know where to send the response (as in a spoofed IP). I have yet to have a problem with that.

Sure it is unlikely to be exploited though the $_SERVER array is user input and you can not trust user input. Besides that why take the risk cause if someone finds a way around it you'll smack yourself in the face. This is simply a case of good coding practice, data that somehow *could* be changed by the user should be sanitised before you can use it.
Image Proud member of the phpBB support team
Image STG Support team member | Image STG Moderator team member
Image
User avatar
Erik Frèrejean    
phpBB Team Member
phpBB Team Member
 
Posts: 1114
Joined: 03 Dec 2007, 00:49
Location: USERS_TABLE
Favorite Team: New Orleans Saints
Gender: Male
phpBB Knowledge: 10

Re: How many security holes

Postby zaphod » 02 Nov 2009, 13:22

Erik Frèrejean wrote:Sure it is unlikely to be exploited though the $_SERVER array is user input

I disagree, while the $_SERVER array is global in SCOPE, it is not registered to where user input is accepted. Please see http://www.php.net/manual/en/reserved.v ... server.php , and http://www.php.net/manual/en/language.v ... lobals.php , where it is said...
php.net wrote:Several predefined variables in PHP are "superglobals", which means they are available in all scopes throughout a script. There is no need to do global $variable; to access them within functions or methods.
I do not see where [REMOTE_ADDR] can have false information injected by the user. It seems to be a variable directly set by the server software, which detects IP from the TCP/IP stack of the server. Elsewise, I see no other way to derive IP safely within the script.

Can you please give me an example, of how this variable can be tampered with? I really need to know this as it would affect ZB Block to it's core.

Zap :blink:
Get protected, stay protected...
SpambotSecurity.com the home of ZB Block
User avatar
zaphod    
Crewman
Crewman
 
Posts: 7
Joined: 01 Nov 2009, 05:26
Location: Casper, WY
Favorite Team: none
Gender: Male
phpBB Knowledge: 8

Re: How many security holes

Postby zaphod » 02 Nov 2009, 20:01

zaphod in haste wrote:I disagree, while the $_SERVER array is global in SCOPE, it is not registered to where user input is accepted.
Should have read...
zaphod wanted to say wrote:I disagree, while the $_SERVER array is global in SCOPE, it is not registered to where user input is accepted, where it is not looked for.


Hope that makes it clearer. :D

Zap :)
Get protected, stay protected...
SpambotSecurity.com the home of ZB Block
User avatar
zaphod    
Crewman
Crewman
 
Posts: 7
Joined: 01 Nov 2009, 05:26
Location: Casper, WY
Favorite Team: none
Gender: Male
phpBB Knowledge: 8

Re: How many security holes

Postby Aureax » 17 Dec 2009, 04:42

I counted 18 SQL injects, 1 way to hack. :D
Aureax
Crewman
Crewman
 
Posts: 3
Joined: 17 Dec 2009, 04:31
Gender: Male
phpBB Knowledge: 4

Previous

Return to Security Class

Who is online

Users browsing this forum: No registered users and 4 guests

cron