简体   繁体   English

用户可以更改PHP中的$ _SERVER变量吗? 如果可以,怎么办?

[英]Can $_SERVER variables in PHP be changed by the user? If so how?

I need to use $_SERVER variables like SCRIPT_FILENAME for a mvc framework I'm writing. 我需要为我正在编写的mvc框架使用$ _SERVER变量,例如SCRIPT_FILENAME。 I'm wondering if a user can change things like that. 我想知道用户是否可以更改类似的内容。 Say the user requests index.php, can they fake the SCRIPT_FILENAME variable and rename it to something else that is being sent over? 假设用户请求index.php,他们可以伪造SCRIPT_FILENAME变量并将其重命名为正在发送的其他内容吗?

Some $_SERVER values are safe, others are not. 一些$_SERVER值是安全的,而其他则不是。 The unsafe ones mostly start with HTTP_ and are the HTTP headers sent by the user's browser. 不安全的大多数以HTTP_开头,并且是用户浏览器发送的HTTP标头。

Yes, it is possible. 对的,这是可能的。

See this post: How to bypass the REFERER security check . 请参阅这篇文章:如何绕过REFERER安全检查

Assuming that the user doesn't have access to some way that re-directs the execution of the script through another script, or access to the server, I'd say no. 假设用户没有某种方式可以通过另一个脚本来重定向脚本的执行,也无法访问服务器,那么我不会。 Also, if you're really worried about that, you can use __FILE__ which doesn't depend on user data. 另外,如果您真的很担心,可以使用不依赖用户数据的__FILE__

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 可以更改 php 会话变量吗,如果可以,如何更改? - Can php session variable be changed, and if so how? 我的PHP脚本如何判断suhosin是否更改了请求变量? - How can my php script tell if suhosin changed request variables? 在PHP类中,如何使变量成为特定类型? - In a PHP class, how can I make it so that the variables are a specific type? 如何从类php保存更改的变量 - How to save changed variables from class php PHP-如何将更改的变量设置为新数组 - PHP - How to set changed variables to new array 将用户自制的SVG(raphael.js)发送到服务器(php),以便通过电子邮件发送 - Send user-made SVG (raphael.js) to server (php) so it can be sent by email 如何保存附加到变量然后将它们转换为php,以便将它们保存在数据库中? - How you can save appends to variables an then convert them to php so you can save them in a database? 如何访问php变量,以便可以使用javascript / jquery处理值? - how do i access php variables so that i can work with the values using javascript/ jquery? 如何在php变量中获取sql查询的int值? 所以我以后可以用php变量来计算 - How can i get a int value of a sql query in a php variable ? So i can later use it calculate with php variables 如何更改用户所有者,以便可以通过FTP编辑和/或删除使用PHP脚本创建的文件夹? - How can I change the user owner so a folder created with a PHP script can be edited and/or deleted through FTP?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM