I have this code on my page:
header ("Location: $ page");
The $ page is passed the script as a GET variable, do I need any security? (if so)
I was going to just use addlashes (), but that would fill the url ...
I, , , , ( www.yoursite.com?page=badsite.com). , badsite.com , , , .
$urls , :
$urls
$urls = array( 'pageName1' => '/link/to/page/number/1', 'pageNumber2' => '/link/to/page/number/2', 'fancyPageName3' => '/link/to/page/number/3', ); # Now your URL can look like this: # www.yoursite.com?page=pageName1
. , , script - .
- - :
!
, , , . , PHP 4.4.2 5.1.2 , URI , . , ?page=%68%74%74%70%3a%2f%2f%65%76%69%6c%2e%65%78%61%6d%70%6c%65%2e%63%6f%6d%2f, URL- ?page=http://evil.example.com/.
?page=%68%74%74%70%3a%2f%2f%65%76%69%6c%2e%65%78%61%6d%70%6c%65%2e%63%6f%6d%2f
?page=http://evil.example.com/
, . , , , , . , , , , . :
$safe_pages = array('index.php', 'login.php', 'signup.php'); if (in_array($page, $safe_pages)) { header("Location: $page"); } else { echo 'That page is not accessible.'; }
Or at least define a whitelist of allowed URLs and redirect the user only if the URL that they set is in the GET variable is in the list.
Source: https://habr.com/ru/post/1708890/More articles:Python cgi FieldStorage slow alternatives? - pythonIs there a simple text block for Delphi? - xmlRegular expression issues - pythonПодключение Visual С# 2008 Express к выпуску SQL Server 2008 Express - visual-studio-2008"Enforce" redefines in C # - c #Search for matching named spelling errors - variablesColdFusion Reports - coldfusionPassing the address of the variable public - pointersServing a stored procedure - sql-serverSQL: группировка 2 таблиц как 1 с объединением, объединением, а затем? - sqlAll Articles