<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Some reminiscences, some memories &#187; 漏洞</title>
	<atom:link href="http://www.mikespook.com/index.php/tag/%e6%bc%8f%e6%b4%9e/feed" rel="self" type="application/rss+xml" />
	<link>http://www.mikespook.com</link>
	<description>Just another boring day</description>
	<lastBuildDate>Wed, 08 Feb 2012 09:28:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>关于昨日爆出的 Nginx + PHP CGI 漏洞的一点点补充</title>
		<link>http://www.mikespook.com/2010/05/%e5%85%b3%e4%ba%8e%e6%98%a8%e6%97%a5%e7%88%86%e5%87%ba%e7%9a%84-nginx-php-cgi-%e6%bc%8f%e6%b4%9e%e7%9a%84%e4%b8%80%e7%82%b9%e7%82%b9%e8%a1%a5%e5%85%85/</link>
		<comments>http://www.mikespook.com/2010/05/%e5%85%b3%e4%ba%8e%e6%98%a8%e6%97%a5%e7%88%86%e5%87%ba%e7%9a%84-nginx-php-cgi-%e6%bc%8f%e6%b4%9e%e7%9a%84%e4%b8%80%e7%82%b9%e7%82%b9%e8%a1%a5%e5%85%85/#comments</comments>
		<pubDate>Fri, 21 May 2010 06:14:52 +0000</pubDate>
		<dc:creator>mikespook</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[cgi]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[漏洞]]></category>

		<guid isPermaLink="false">http://www.mikespook.com/?p=575</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
	float:left;
	position: fixed;
	top: 60%;
	left: 70px;
}
#leftcontainerBox .buttons {
	float:left;
	clear:both;
	margin:4px 4px 4px 4px;
	padding-bottom:2px;
}
#bottomcontainerBox {
	width: 50%;
	padding-top: 1px;
}
#bottomcontainerBox .buttons {
	float: left;
	margin: 4px 4px 4px 4px;
}
</style>
我第一次看到这个漏洞是在 Laruence 的博客。看完之后，我赶紧评估了一下我们正在开发的产品出现这个漏洞的可能性。还不错，在我们当前架构下，这个漏洞被成功利用的可能性为 0 ……

结果，今天在大嘴巴 cnbeta 看到了这篇很标题党的新闻《80后发现nginx 0day漏洞，上传图片可入侵100万服务器》。然后引用的出处是这里。

好了，我认为我提供的背景资料足够详细了。现在说说为什么我们的产品不会出现这个被利用的可能吧。

<span class="readmore"><a href="http://www.mikespook.com/2010/05/%e5%85%b3%e4%ba%8e%e6%98%a8%e6%97%a5%e7%88%86%e5%87%ba%e7%9a%84-nginx-php-cgi-%e6%bc%8f%e6%b4%9e%e7%9a%84%e4%b8%80%e7%82%b9%e7%82%b9%e8%a1%a5%e5%85%85/" title="关于昨日爆出的 Nginx + PHP CGI 漏洞的一点点补充">阅读全文——共484字</a></span>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
	float:left;
	position: fixed;
	top: 60%;
	left: 70px;
}
#leftcontainerBox .buttons {
	float:left;
	clear:both;
	margin:4px 4px 4px 4px;
	padding-bottom:2px;
}
#bottomcontainerBox {
	width: 50%;
	padding-top: 1px;
}
#bottomcontainerBox .buttons {
	float: left;
	margin: 4px 4px 4px 4px;
}
</style>
<p>我第一次看到这个漏洞是在 <a href="http://www.laruence.com/2010/05/20/1495.html" target="_blank">Laruence 的博客</a>。看完之后，我赶紧评估了一下我们正在开发的产品出现这个漏洞的可能性。还不错，在我们当前架构下，这个漏洞被成功利用的可能性为 0 ……</p>
<p>结果，今天在大嘴巴 cnbeta 看到了这篇很标题党的新闻<a href="http://www.cnbeta.com/articles/111711.htm" target="_blank">《80后发现nginx 0day漏洞，上传图片可入侵100万服务器》</a>。然后引用的出处是<a href="http://www.80sec.com/nginx-securit.html" target="_blank">这里</a>。</p>
<p>好了，我认为我提供的背景资料足够详细了。现在说说为什么我们的产品不会出现这个被利用的可能吧。</p>
<p>其实很简单，将资源文件和 php 脚本文件放在不同的域名下面。然后将资源文件（含产品自身的和用户贡献的）的访问限于只作文件传输，不作任何的脚本解析。</p>
<p>例如 PHP 脚本执行的主机名是 www.mikespook.com。而上传文件和图像、js、css 等放在 static.mikespook.com 主机名下。</p>
<p>其实，就是这么简单的一个隔离措施，就避免了出现这种上传并解析的漏洞。</p>
<p>即使想用同一个域名，通过对 nginx 的配置禁止资源文件目录下的文件被当作脚本解析也是很容易的。</p>
<p>这个故事教育我们：细节是基石，架构是王道！！！</p>
<p>另，根据来自高春辉的可靠消息，手机之家也不存在此问题……</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikespook.com/2010/05/%e5%85%b3%e4%ba%8e%e6%98%a8%e6%97%a5%e7%88%86%e5%87%ba%e7%9a%84-nginx-php-cgi-%e6%bc%8f%e6%b4%9e%e7%9a%84%e4%b8%80%e7%82%b9%e7%82%b9%e8%a1%a5%e5%85%85/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mb_ereg(i)_replace() 执行任意代码的漏洞</title>
		<link>http://www.mikespook.com/2009/05/mb_eregi_replace-%e6%89%a7%e8%a1%8c%e4%bb%bb%e6%84%8f%e4%bb%a3%e7%a0%81%e7%9a%84%e6%bc%8f%e6%b4%9e/</link>
		<comments>http://www.mikespook.com/2009/05/mb_eregi_replace-%e6%89%a7%e8%a1%8c%e4%bb%bb%e6%84%8f%e4%bb%a3%e7%a0%81%e7%9a%84%e6%bc%8f%e6%b4%9e/#comments</comments>
		<pubDate>Fri, 08 May 2009 14:24:13 +0000</pubDate>
		<dc:creator>mikespook</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[漏洞]]></category>

		<guid isPermaLink="false">http://www.mikespook.com/?p=309</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
	float:left;
	position: fixed;
	top: 60%;
	left: 70px;
}
#leftcontainerBox .buttons {
	float:left;
	clear:both;
	margin:4px 4px 4px 4px;
	padding-bottom:2px;
}
#bottomcontainerBox {
	width: 50%;
	padding-top: 1px;
}
#bottomcontainerBox .buttons {
	float: left;
	margin: 4px 4px 4px 4px;
}
</style>
这个漏洞说大也大，说小也小。大是因为真得可以通过注入的方式让漏洞代码执行任意代码。小是因为产生漏洞的环境还是比较苛刻的。

来源于此：http://milw0rm.com/exploits/8641

当最后一个参数设置为“e”，也就是将替换的内容作为 PHP 代码执行的时候，漏洞就产生了。

<span class="readmore"><a href="http://www.mikespook.com/2009/05/mb_eregi_replace-%e6%89%a7%e8%a1%8c%e4%bb%bb%e6%84%8f%e4%bb%a3%e7%a0%81%e7%9a%84%e6%bc%8f%e6%b4%9e/" title="mb_ereg(i)_replace() 执行任意代码的漏洞">阅读全文——共432字</a></span>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
	float:left;
	position: fixed;
	top: 60%;
	left: 70px;
}
#leftcontainerBox .buttons {
	float:left;
	clear:both;
	margin:4px 4px 4px 4px;
	padding-bottom:2px;
}
#bottomcontainerBox {
	width: 50%;
	padding-top: 1px;
}
#bottomcontainerBox .buttons {
	float: left;
	margin: 4px 4px 4px 4px;
}
</style>
<p>这个漏洞说大也大，说小也小。大是因为真得可以通过注入的方式让漏洞代码执行任意代码。小是因为产生漏洞的环境还是比较苛刻的。</p>
<p>来源于此：<a href="http://milw0rm.com/exploits/8641" target="_blank">http://milw0rm.com/exploits/8641</a></p>
<p>当最后一个参数设置为“e”，也就是将替换的内容作为 PHP 代码执行的时候，漏洞就产生了。<br />
例如：</p>
<pre lang="PHP">function hi80vul() {}

$str = '\', phpinfo(), \'';
mb_ereg_replace('^(.*)$', 'hi80vul(\'\1\')', $str, 'e');</pre>
<p>又例如：</p>
<pre lang="PHP">function hi80vul() {}

$str = '\', var_dump(get_loaded_extensions()), \'';
mb_ereg_replace('^(.*)$', 'hi80vul(\'\1\')', $str, 'e');</pre>
<p>如果有在代码中使用过 mb_ereg_replace 和 mb_eregi_replace，以及参数“e”，那就赶紧检查一下是否有这样的安全隐患吧。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikespook.com/2009/05/mb_eregi_replace-%e6%89%a7%e8%a1%8c%e4%bb%bb%e6%84%8f%e4%bb%a3%e7%a0%81%e7%9a%84%e6%bc%8f%e6%b4%9e/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

