Several PHP vulnerabilities to be aware of _ PHP Tutorial

Source: Internet
Author: User
Several summary of PHP vulnerabilities that need attention. Several important PHP vulnerabilities that need attention. ini options: RegisterGlobalsphp4.2.0, php. the default value of the register_globals option of ini is set to Off. when register_globals is set to On, several PHP vulnerabilities need to be noted.
Several important php. ini options
Register Globals
Php> = 4.2.0, php. the default value of the register_globals option of ini is Off. when register_globals is set to On, the program can receive various environment variables from the server, including the variables submitted by the form, in addition, PHP does not need to initialize the variable value in advance, which leads to great security risks.
Example 1:

The code is as follows:


// Check_admin () is used to check the permissions of the current user. if the $ is_admin variable is set to true in admin, the following checks whether the variable is true and then performs some management operations.
// Ex1.php
  
If (check_admin ())
{
$ Is_admin = true;
}
If ($ is_admin)
{
Do_something ();
}
?>


This code section does not initialize $ is_admin to Flase in advance. if register_globals is On, then we directly submit the http://www.sectop.com/ex1.php? If is_admin = true, the check_admin () verification can be bypassed.
Example 2:

The code is as follows:


// Ex2.php
  
If (isset ($ _ SESSION ["username"])
{
Do_something ();
}
Else
{
Echo "you have not logged on! ";
}
?>


The code is as follows:


// Ex1.php
  
$ Dir = $ _ GET ["dir"];
If (isset ($ dir ))
{
Echo "";
System ("ls-al". $ dir );
Echo "";
}
?>



Mixed eval (string code_str) // eval injection generally occurs when attackers can control input strings.
// Ex2.php

The code is as follows:

  
$ Var = "var ";
If (isset ($ _ GET ["arg"])
{
$ Arg = $ _ GET ["arg"];
Eval ("$ var = $ arg ;");
Echo "$ var =". $ var;
}
?>


Register several important php. ini options: Register Globals php = 4.2.0. the default value of the register_globals option of php. ini is set to Off. when register_globals is set to On, the process...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.