<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
	<channel>
		<title>Retour à La Source • Tag: Securite • RSS</title>
		<link>http://www.ab-d.fr/tag/Securite/</link>
		<description>Retour à La Source • Tag: Securite • RSS</description>
		<copyright>http://www.ab-d.fr/tag/Securite/ (c) 2012</copyright>
		<language>fr</language>
		<pubDate>Sun, 05 Feb 2012 01:27:41 +0100</pubDate>
		<generator>Retour à La Source • Tag: Securite • RSS • version 1.0</generator>
		<webMaster>noreply@ab-d.fr ( Benoit Asselin )</webMaster>
		<image>
			<url>http://www.ab-d.fr/images/rss.gif</url>
			<title>Retour à La Source • Tag: Securite • RSS</title>
			<link>http://www.ab-d.fr/tag/Securite/</link>
			<width>90</width>
			<height>30</height>
		</image>

		<item>
			<title>$_SERVER['PHP_SELF'] et injection de code HTML (création site internet)</title>
			<link>http://www.ab-d.fr/date/2008-03-02/</link>
			<pubDate>Sun, 02 Mar 2008 04:24:24 +0100</pubDate>
			<author>noreply@ab-d.fr ( Benoit Asselin )</author>
			<category><![CDATA[PHP]]></category>
			<category><![CDATA[XHTML]]></category>
			<category><![CDATA[Securite]]></category>
			<description><![CDATA[<p>
Cette faille de sécurité n'est pas nouvelle en soit, mais il est parfois bon de faire un petit rappel. De manière générale, ne faites jamais confiance aux variables <code>$_SERVER</code>, <code>$_COOKIE</code>, mais aussi, <code>$_GET</code>, <code>$_POST</code>, <code>$_REQUEST</code>, <code>$_FILES</code>...
</p>
<p>
Exemple de faille avec <code>&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;</code> dans la page php suivante :
</p>
<pre>
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd"&gt;

&lt;html lang="fr"&gt;
&lt;head&gt;
	&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
	&lt;title&gt;$_SERVER['PHP_SELF']&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;form action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;" action="post"&gt;
		&lt;fieldset&gt;
			&lt;legend&gt;Ma FORM&lt;/legend&gt;
			&lt;p&gt;&lt;input type="submit"&gt;&lt;/p&gt;
		&lt;/fieldset&gt;
	&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>

<p>Si vous appelez la page ci-dessus avec le lien suivant :</p>
<pre>http://www.monsite.com/page.php/"&gt;&lt;script&gt;alert('Injection!');&lt;/script&gt;</pre>
<p>vous verrez une belle fenêtre de dialogue Javascript "Injection!" ...</p>

<p>Pour remédier à cette faille de sécurité, pensez à toujours sécuriser vos variables avec une fonction du type <code>htmlentities()</code>.</p>

<hr /><a href="http://res.feedsportal.com/viral/bookmark_fr.cfm?link=http%3A%2F%2Fwww.ab-d.fr%2Fdate%2F2008-03-02%2F&title=%24_SERVER%5B%27PHP_SELF%27%5D+et+injection+de+code+HTML+%28cr%C3%A9ation+site+internet%29"><img src="http://www.ab-d.fr/images/bookmark.gif" border="0" /></a><br /><br />]]></description>
			<comments>http://www.ab-d.fr/tag/Securite/</comments>
			<guid isPermaLink="false">http://www.ab-d.fr/date/2008-03-02/</guid>
		</item>

	</channel>
</rss>

