<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title>Using purify to secure a password</title>
        <description>Hello,

I currently uses and try to improve the Vtiger CRM system.  It uses a lot the vtlib_purify function to secure user input.  I understood that it uses htmlpurifier tool.

I found a bug in the Vtiger login page, when logging with a password containing an ampersand.

I was able to point out the problem : The password input is passed through the vtlib_purify function
before it's hashed with php crypt function and compared to the one from the database.

When the password an ampersand (&amp;amp;), all these ampersand are replaced by their html encoded 
code :



&amp;amp;amp;


Of course, when encoding the purified password and comparing with the hash in the database, there is no match.

I was able to solve the problem by adding a htmlspecialchars_decode($password) call after the purify call, but I suspect that leaves a security breach and makes the purify call useles... 

Is it standard to deny passwords containing an ampersand or others special characters ?
Is it useful to use the purify tool with the password, if it's passed to crypt function later ?
I used myself a lot of passwords with an ampersand, and it's the first time I have a problem with it.

Please, if someone have a solution to my problem,i'm very interested.

P.S. Please excuse my not always perfect English, I'm speaking French.

Ismaël</description>
        <link>http://htmlpurifier.org/phorum/read.php?3,5304,5304#msg-5304</link>
        <lastBuildDate>Sat, 25 May 2013 13:40:42 -0400</lastBuildDate>
        <generator>Phorum 5.2.18</generator>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?3,5304,5317#msg-5317</guid>
            <title>Re: Using purify to secure a password</title>
            <link>http://htmlpurifier.org/phorum/read.php?3,5304,5317#msg-5317</link>
            <description><![CDATA[<p>Thank you both for your answer.  I'm relatively new to the php and Vtiger world, that's why I didn't doubt of the need to use the purifier function.  I will remove it from my own Vtiger system source code, and indeed i will resolve the problem.</p>

<p>Ismaël</p>]]></description>
            <dc:creator>igelineau</dc:creator>
            <category>Support</category>
            <pubDate>Sat, 05 Feb 2011 13:07:44 -0500</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?3,5304,5307#msg-5307</guid>
            <title>Re: Using purify to secure a password</title>
            <link>http://htmlpurifier.org/phorum/read.php?3,5304,5307#msg-5307</link>
            <description><![CDATA[<p>Hello,</p>

<p>This problem belies a very fundamental misunderstanding about how encoding works. I will try to elucidate. What is a password? A password is an arbitrary string of characters, with no structure to them. As such, there is no "validation" that needs to be done on it, you just hash it and then perform the comparison on it with the database. HTML Purifier should NOT be called on passwords.</p>

<p>Edward</p>]]></description>
            <dc:creator>Ambush Commander</dc:creator>
            <category>Support</category>
            <pubDate>Sat, 05 Feb 2011 06:49:10 -0500</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?3,5304,5306#msg-5306</guid>
            <title>Re: Using purify to secure a password</title>
            <link>http://htmlpurifier.org/phorum/read.php?3,5304,5306#msg-5306</link>
            <description><![CDATA[<p>don't use htmlpurifier for NON-HTML. purifier is designed for HTML code only.</p>

<p>if you want to filter plain text, then use a different filter.</p>

<p>there are plenty of PHP functions available to do the job.</p>

<p>for passwords i would probably use filter_var($plaintext_pass, FILTER_SANITIZE_STRING); or if it's a $_POST, then filter_input(INPUT_POST, $plaintext_pass, FILTER_SANITIZE_STRING)</p>

<p>filter_var() &amp; filter_input() are both native PHP functions. see <a href="http://www.php.net/manual/en/ref.filter.php">http://www.php.net/manual/en/ref.filter.php</a></p>

<p>but never use htmlpurifier for filtering plaintext or non-html input.</p>]]></description>
            <dc:creator>vaughan</dc:creator>
            <category>Support</category>
            <pubDate>Sat, 05 Feb 2011 06:47:25 -0500</pubDate>
        </item>
        <item>
            <guid>http://htmlpurifier.org/phorum/read.php?3,5304,5304#msg-5304</guid>
            <title>Using purify to secure a password</title>
            <link>http://htmlpurifier.org/phorum/read.php?3,5304,5304#msg-5304</link>
            <description><![CDATA[<p>Hello,</p>

<p>I currently uses and try to improve the Vtiger CRM system.  It uses a lot the vtlib_purify function to secure user input.  I understood that it uses htmlpurifier tool.</p>

<p>I found a bug in the Vtiger login page, when logging with a password containing an ampersand.</p>

<p>I was able to point out the problem : The password input is passed through the vtlib_purify function
before it's hashed with php crypt function and compared to the one from the database.</p>

<p>When the password an ampersand (&amp;), all these ampersand are replaced by their html encoded 
code :
</p>

<pre>
&amp;amp;
</pre>

<p>Of course, when encoding the purified password and comparing with the hash in the database, there is no match.</p>

<p>I was able to solve the problem by adding a htmlspecialchars_decode($password) call after the purify call, but I suspect that leaves a security breach and makes the purify call useles... </p>

<p>Is it standard to deny passwords containing an ampersand or others special characters ?
Is it useful to use the purify tool with the password, if it's passed to crypt function later ?
I used myself a lot of passwords with an ampersand, and it's the first time I have a problem with it.</p>

<p>Please, if someone have a solution to my problem,i'm very interested.</p>

<p>P.S. Please excuse my not always perfect English, I'm speaking French.</p>

<p>Ismaël</p>]]></description>
            <dc:creator>Igelineau</dc:creator>
            <category>Support</category>
            <pubDate>Fri, 04 Feb 2011 21:39:52 -0500</pubDate>
        </item>
    </channel>
</rss>
