【发布时间】:2017-07-06 12:17:52
【问题描述】:
当 777 权限打开时,我对服务器的安全性有疑问。
这是代码:
<?php
// collect the cookie - save the data
if(!isset($_COOKIE["markertype"])) {
echo "Cookie named markertype is not set!";
} else {
echo "Cookie markertype is set!<br>";
echo "Value is: " . $_COOKIE["markertype"];
$file = 'newfile.txt';
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new person to the file
$current .= $_COOKIE["markertype"];
// Write the contents back to the file
file_put_contents($file, $current);
}
?>
基本上系统允许用户在javascript中做一些事情,然后我在JS中设置一个cookie,其中包含他们放入系统的一些用户信息。然后我通过 cookie 将其发送到 PHP 以将这些信息存储在服务器上。问题是服务器没有写入文件的权限,所以我继续授予对整个目录的完全 777 访问权限。
我认为这让我面临全面的 XSS 攻击等等,我的替代方案是什么,或者我可以以不同的方式保护服务器吗?服务器不是我的,所以我只有一定的访问权限。
【问题讨论】:
标签: javascript php security cookies