<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.4" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: PHP Security: Basic PHP Security</title>
	<link>http://phpit.net/article/php-security-basic/</link>
	<description>PHPit has dozens of PHP articles, codesnippets and FAQ's.</description>
	<pubDate>Sun, 22 Jun 2008 23:36:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.4</generator>

	<item>
		<title>by: Marco</title>
		<link>http://phpit.net/article/php-security-basic/#comment-2615</link>
		<pubDate>Wed, 24 May 2006 10:34:52 +0000</pubDate>
		<guid>http://phpit.net/article/php-security-basic/#comment-2615</guid>
					<description>Italian resource / risorsa italiana sull'argomento: programmazione sicura in PHP:

http://www.scuolaelettrica.it/buratto/php2/PHPSec.htm</description>
		<content:encoded><![CDATA[<p>Italian resource / risorsa italiana sull&#8217;argomento: programmazione sicura in PHP:</p>
<p><a href='http://www.scuolaelettrica.it/buratto/php2/PHPSec.htm' rel='nofollow'>http://www.scuolaelettrica.it/buratto/php2/PHPSec.htm</a>
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: .:: ㊣Inosin℃ -&#62; Blog ::. &#187; 一个非常不错的Email地址验证函数~</title>
		<link>http://phpit.net/article/php-security-basic/#comment-1617</link>
		<pubDate>Mon, 08 May 2006 03:18:16 +0000</pubDate>
		<guid>http://phpit.net/article/php-security-basic/#comment-1617</guid>
					<description>[...] http://phpit.net/article/php-security-basic/1/ [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] <a href='/article/php-security-basic/1/' rel='nofollow'>http://phpit.net/article/php-security-basic/1/</a> [&#8230;]
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Dennis Pallett</title>
		<link>http://phpit.net/article/php-security-basic/#comment-1490</link>
		<pubDate>Tue, 02 May 2006 09:42:53 +0000</pubDate>
		<guid>http://phpit.net/article/php-security-basic/#comment-1490</guid>
					<description>Hi Brian,

You're right, and I've posted it now, at:

http://phpit.net/code/valid-email/

I've also updated the article. Thanks for letting me know.</description>
		<content:encoded><![CDATA[<p>Hi Brian,</p>
<p>You&#8217;re right, and I&#8217;ve posted it now, at:</p>
<p><a href='/code/valid-email/' rel='nofollow'>http://phpit.net/code/valid-email/</a></p>
<p>I&#8217;ve also updated the article. Thanks for letting me know.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Brian</title>
		<link>http://phpit.net/article/php-security-basic/#comment-1471</link>
		<pubDate>Mon, 01 May 2006 19:48:53 +0000</pubDate>
		<guid>http://phpit.net/article/php-security-basic/#comment-1471</guid>
					<description>valid_email() is not available at http://phpit.net/code/

It would have been nice to see.</description>
		<content:encoded><![CDATA[<p>valid_email() is not available at <a href='/code/' rel='nofollow'>http://phpit.net/code/</a></p>
<p>It would have been nice to see.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Piku&#8217;s PHP Blog &#187; PHPit articles</title>
		<link>http://phpit.net/article/php-security-basic/#comment-490</link>
		<pubDate>Mon, 23 Jan 2006 19:53:40 +0000</pubDate>
		<guid>http://phpit.net/article/php-security-basic/#comment-490</guid>
					<description>[...] First one is PHP Security: Basic PHP Security. It treats the basics of securing your PHP applications (Filtering the input and escaping the output). [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] First one is PHP Security: Basic PHP Security. It treats the basics of securing your PHP applications (Filtering the input and escaping the output). [&#8230;]
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Dennis Pallett</title>
		<link>http://phpit.net/article/php-security-basic/#comment-481</link>
		<pubDate>Sun, 22 Jan 2006 20:02:05 +0000</pubDate>
		<guid>http://phpit.net/article/php-security-basic/#comment-481</guid>
					<description>Matthijs: I really like the idea of the clean array, and it does prevent the mistake you describe, which is probably an all too common mistake, especially because a typo is easy to make.

James: I kinda agree with you, although the valid_email() example I have is a good example of real validation.</description>
		<content:encoded><![CDATA[<p>Matthijs: I really like the idea of the clean array, and it does prevent the mistake you describe, which is probably an all too common mistake, especially because a typo is easy to make.</p>
<p>James: I kinda agree with you, although the valid_email() example I have is a good example of real validation.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Charlie</title>
		<link>http://phpit.net/article/php-security-basic/#comment-457</link>
		<pubDate>Thu, 19 Jan 2006 23:23:59 +0000</pubDate>
		<guid>http://phpit.net/article/php-security-basic/#comment-457</guid>
					<description>&#62; Start with declaring an empty $clean array. After that add only data to the $clean array after validation.

Or better yes, use perl -T, and have the language *enforce* separation between validated and unvalidated data.</description>
		<content:encoded><![CDATA[<p>&gt; Start with declaring an empty $clean array. After that add only data to the $clean array after validation.</p>
<p>Or better yes, use perl -T, and have the language *enforce* separation between validated and unvalidated data.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: James</title>
		<link>http://phpit.net/article/php-security-basic/#comment-435</link>
		<pubDate>Tue, 17 Jan 2006 14:11:01 +0000</pubDate>
		<guid>http://phpit.net/article/php-security-basic/#comment-435</guid>
					<description>Hi, Sorry to be really picky, but i wouldn't call this validation.

[code]
// Do validation

$s_Email = mysql_real_escape_string($d_Email);

[/code]

Thats more what i would say is escaping, validation is checking the length and the characters contained within the username/email address. Stripping out HTML tags etc...I suppose you could call it data cleansing.
Sorry to be a picky swine :)</description>
		<content:encoded><![CDATA[<p>Hi, Sorry to be really picky, but i wouldn&#8217;t call this validation.</p>
<p>[code]<br />
// Do validation</p>
<p>$s_Email = mysql_real_escape_string($d_Email);</p>
<p>[/code]</p>
<p>Thats more what i would say is escaping, validation is checking the length and the characters contained within the username/email address. Stripping out HTML tags etc&#8230;I suppose you could call it data cleansing.<br />
Sorry to be a picky swine :)
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Volodia</title>
		<link>http://phpit.net/article/php-security-basic/#comment-434</link>
		<pubDate>Tue, 17 Jan 2006 13:20:02 +0000</pubDate>
		<guid>http://phpit.net/article/php-security-basic/#comment-434</guid>
					<description>$var['email']='';
$var=array_merge($var,$_GET,$_POST);
$sql_query="select * from table where email='.addslashes($var['email']).'";

if in php.ini -&#62; magic_quote_gpc=on
$sql_query="select * from table where email='.addslashes(stripslashes($var['email'])).'";</description>
		<content:encoded><![CDATA[<p>$var[&#8217;email&#8217;]='&#8217;;<br />
$var=array_merge($var,$_GET,$_POST);<br />
$sql_query=&#8221;select * from table where email=&#8217;.addslashes($var[&#8217;email&#8217;]).&#8217;&#8221;;</p>
<p>if in php.ini -&gt; magic_quote_gpc=on<br />
$sql_query=&#8221;select * from table where email=&#8217;.addslashes(stripslashes($var[&#8217;email&#8217;])).&#8217;&#8221;;
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Matthijs</title>
		<link>http://phpit.net/article/php-security-basic/#comment-428</link>
		<pubDate>Mon, 16 Jan 2006 16:57:08 +0000</pubDate>
		<guid>http://phpit.net/article/php-security-basic/#comment-428</guid>
					<description>Good article Dennis. Filter ALL input, escape ALL output. Solid advice! 

One remark about prefixing variables to avoid mistakes. That is a good aproach. The method I personally apply is the one Chris Shiflett uses in his book. Start with declaring an empty $clean array. After that add only data to the $clean array after validation. Then, if you want to do something in your script, you only work with the $clean array.  See for an example http://phpsecurity.org/code/ch01-3

This makes sure you never process tainted/unsafe data, even if a variable hasn't been declared earlier on in your script. For example, if I process some data like this:
$clean = array();
$email = $_POST['email'];
$sql = mysql_real_escape_string($clean['Emali']);
as you can see, there's a typo in the last line. But apart from the fact that my script probably doesn't work as intended, it is not dangerous. The variable "Emali" can not be injected from outside, because I declare the $clean array empty at the start of the script.

I find this approach very useful. 

On the other hand, if I would have processed the line as:
$Email = $_POST['email'];
$sql = mysql_real_escape_string($Emali);
the variable $Emali would not have been declared and could be injected from outside.

Hope I explained it well. There's a lot to consider when you want to write secure scripts, so it's good you give it some attention Dennis! And the links you provide are indeed excellent reading material for further study.</description>
		<content:encoded><![CDATA[<p>Good article Dennis. Filter ALL input, escape ALL output. Solid advice! </p>
<p>One remark about prefixing variables to avoid mistakes. That is a good aproach. The method I personally apply is the one Chris Shiflett uses in his book. Start with declaring an empty $clean array. After that add only data to the $clean array after validation. Then, if you want to do something in your script, you only work with the $clean array.  See for an example <a href='http://phpsecurity.org/code/ch01-3' rel='nofollow'>http://phpsecurity.org/code/ch01-3</a></p>
<p>This makes sure you never process tainted/unsafe data, even if a variable hasn&#8217;t been declared earlier on in your script. For example, if I process some data like this:<br />
$clean = array();<br />
$email = $_POST[&#8217;email&#8217;];<br />
$sql = mysql_real_escape_string($clean[&#8217;Emali&#8217;]);<br />
as you can see, there&#8217;s a typo in the last line. But apart from the fact that my script probably doesn&#8217;t work as intended, it is not dangerous. The variable &#8220;Emali&#8221; can not be injected from outside, because I declare the $clean array empty at the start of the script.</p>
<p>I find this approach very useful. </p>
<p>On the other hand, if I would have processed the line as:<br />
$Email = $_POST[&#8217;email&#8217;];<br />
$sql = mysql_real_escape_string($Emali);<br />
the variable $Emali would not have been declared and could be injected from outside.</p>
<p>Hope I explained it well. There&#8217;s a lot to consider when you want to write secure scripts, so it&#8217;s good you give it some attention Dennis! And the links you provide are indeed excellent reading material for further study.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
