<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.owasp.org/index.php?action=history&amp;feed=atom&amp;title=Talk%3APHP_CSRF_Guard</id>
		<title>Talk:PHP CSRF Guard - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.owasp.org/index.php?action=history&amp;feed=atom&amp;title=Talk%3APHP_CSRF_Guard"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:PHP_CSRF_Guard&amp;action=history"/>
		<updated>2026-05-05T04:49:52Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:PHP_CSRF_Guard&amp;diff=140889&amp;oldid=prev</id>
		<title>Abbas Naderi: added discussions on flaws</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:PHP_CSRF_Guard&amp;diff=140889&amp;oldid=prev"/>
				<updated>2012-12-08T00:07:32Z</updated>
		
		<summary type="html">&lt;p&gt;added discussions on flaws&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Flaws and Updates==&lt;br /&gt;
&lt;br /&gt;
===2012/12/08===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Thanks very much.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
---&lt;br /&gt;
Jakub&lt;br /&gt;
&lt;br /&gt;
On 8 December 2012 00:54, Abbas Naderi &amp;lt;abbas.naderi@owasp.org&amp;gt; wrote:&lt;br /&gt;
Yes but then I assumed you don't have edit permissions on the wiki. I'll do this and mention you on the bottom and discussion page.&lt;br /&gt;
-Abbas&lt;br /&gt;
On ۱۸ آذر ۱۳۹۱, at ۳:۱۷, Jakub Kałużny &amp;lt;jakub.artur.kaluzny@gmail.com&amp;gt; wrote:&lt;br /&gt;
&lt;br /&gt;
You probably meant changing wiki, sorry :)&lt;br /&gt;
&lt;br /&gt;
On 8 December 2012 00:47, Jakub Kałużny &amp;lt;jakub.artur.kaluzny@gmail.com&amp;gt; wrote:&lt;br /&gt;
Hi,&lt;br /&gt;
just change&lt;br /&gt;
              if (!isset($_POST['CSRFName']))&lt;br /&gt;
to&lt;br /&gt;
              if (!isset($_POST['CSRFName']) || !isset($_POST['CSRFToken']))&lt;br /&gt;
this should work.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Jakub&lt;br /&gt;
&lt;br /&gt;
On 8 December 2012 00:43, Abbas Naderi &amp;lt;abbas.naderi@owasp.org&amp;gt; wrote:&lt;br /&gt;
Hi Jakub,&lt;br /&gt;
You are right and we are aware of this. Would you like to fix it or I shall do so?&lt;br /&gt;
-Abbas&lt;br /&gt;
On ۱۸ آذر ۱۳۹۱, at ۳:۱۱, Jakub Kałużny &amp;lt;jakub.artur.kaluzny@gmail.com&amp;gt; wrote:&lt;br /&gt;
&lt;br /&gt;
Hi Abbas,&lt;br /&gt;
&lt;br /&gt;
I found a note about a bug in PHP CSRF Guard&lt;br /&gt;
(http://blog.kotowicz.net/2012/12/on-handling-your-pets-and-csrf.html)&lt;br /&gt;
The code was patched so that a NULL $token cannot be validated with&lt;br /&gt;
empty (&amp;quot;&amp;quot;) CSRFToken parameter.&lt;br /&gt;
Isn't the code still vulnerable by passing a non existing CSRFName and&lt;br /&gt;
not passing CSRFToken ?&lt;br /&gt;
Only the CSRFName is checked - if(!isset($_POST['CSRFName']))&lt;br /&gt;
but later then there is $token=$_POST['CSRFToken'] which still can be&lt;br /&gt;
null if no CSRFToken parameter is passed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Regards,&lt;br /&gt;
Jakub&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===2012/12/06===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Hi Krzysztof,&lt;br /&gt;
Thanks for the tip. &lt;br /&gt;
Actually I did the code on the fly and never got to test it! And never had a chance to review it.&lt;br /&gt;
Thanks for fixing the flaw.&lt;br /&gt;
Would be a good idea to post this email on discussion page of the wiki so that people know the flow and update it.&lt;br /&gt;
Also add a version on top of the code.&lt;br /&gt;
Regards&lt;br /&gt;
-Abbas&lt;br /&gt;
On ۱۶ آذر ۱۳۹۱, at ۱۷:۴۴, Krzysztof Kotowicz &amp;lt;krzysztof.kotowicz@securing.pl&amp;gt; wrote:&lt;br /&gt;
&lt;br /&gt;
Hi!&lt;br /&gt;
&lt;br /&gt;
PHP CSRFGuard that you posted at OWASP wiki&lt;br /&gt;
https://www.owasp.org/index.php/PHP_CSRF_Guard is vulnerable to a simple&lt;br /&gt;
bypass method:&lt;br /&gt;
&lt;br /&gt;
When you submit a non-existing form id as CSRFName and empty CSRFToken&lt;br /&gt;
csrf_validate_token() function will return true.&lt;br /&gt;
&lt;br /&gt;
function csrfguard_validate_token($unique_form_name,$token_value)&lt;br /&gt;
{&lt;br /&gt;
	$token=get_from_session($unique_form_name); &lt;br /&gt;
&lt;br /&gt;
      // non existing form name, $token = null;&lt;br /&gt;
&lt;br /&gt;
	if ($token===false)&lt;br /&gt;
	{&lt;br /&gt;
		return true;&lt;br /&gt;
	}&lt;br /&gt;
	elseif ($token==$token_value) // type insensitive comparison!!&lt;br /&gt;
	{&lt;br /&gt;
              // $token_value = &amp;quot;&amp;quot;, $token = null, both are equivalent to == operator&lt;br /&gt;
		$result=true;&lt;br /&gt;
	}&lt;br /&gt;
	else&lt;br /&gt;
	{ &lt;br /&gt;
		$result=false;&lt;br /&gt;
	} &lt;br /&gt;
	unset_session($unique_form_name);&lt;br /&gt;
	return $result;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
I've been able to exploit it already on a live site for a client that&lt;br /&gt;
used PHP CSRFGuard. I've fixed the code on wiki by using === operator.&lt;br /&gt;
This is just to notify you of the change, if you use this project elsewhere.&lt;br /&gt;
&lt;br /&gt;
-- &lt;br /&gt;
Best regards,&lt;br /&gt;
Krzysztof Kotowicz&lt;br /&gt;
SecuRing&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Abbas Naderi</name></author>	</entry>

	</feed>