Bug #75922 MySqlSimpleMembershipProvider.GeneratePasswordResetToken

Submitted: 17 Feb 2015 0:25 Modified: 17 Feb 2015 6:00
Reporter: Song Kevin Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.9.5.0 OS:Windows (7)
Assigned to: CPU Architecture:Any
Tags: simplemembership

[17 Feb 2015 0:25] Song Kevin
Description:
The if criteria is opposite. Compare to the Microsoft's implementation WebMatrix.WebData.SimpleMembershipProvider.GeneratePasswordResetToken, you will see it should be if (str == null)

-- MySql.Web.MySqlSimpleMembershipProvider

using (MySqlDatabaseWrapper wrapper = new MySqlDatabaseWrapper(this.GetConnectionString()))
                {
                    string str = wrapper.ExecuteScalar(string.Format("select PasswordVerificationToken from {0} where userid=? and PasswordVerificationTokenExpirationDate > ?;", this._membershipTable), new object[] { userId, DateTime.Now }) as string;
                    if (str != null)
                    {
                        str = this.GenerateToken();
                        if (wrapper.ExecuteNonQuery(string.Format("update {0} set PasswordVerificationToken=?, PasswordVerificationTokenExpirationDate=? where userid=?;", this._membershipTable), new object[] { str, DateTime.Now.AddMinutes((double) tokenExpirationInMinutesFromNow), userId }) <= 0)
                        {
                            throw new System.Configuration.Provider.ProviderException(Resources.GeneratePassVerificationTokenFailed);
                        }
                    }
                    return str;
                }

-- WebMatrix.WebData.SimpleMembershipProvider

using (IDatabase database = this.ConnectToDatabase())
    {
        bool throwException = true;
        int num = this.VerifyUserNameHasConfirmedAccount(database, userName, throwException);
        string str = (string) database.QueryValue("SELECT PasswordVerificationToken FROM " + MembershipTableName + " WHERE (UserId = @0 AND PasswordVerificationTokenExpirationDate > @1)", new object[] { num, DateTime.UtcNow });
        if (str == null)
        {
            str = GenerateToken();
            if (database.Execute("UPDATE " + MembershipTableName + " SET PasswordVerificationToken = @0, PasswordVerificationTokenExpirationDate = @1 WHERE (UserId = @2)", new object[] { str, DateTime.UtcNow.AddMinutes((double) tokenExpirationInMinutesFromNow), num }) != 1)
            {
                throw new ProviderException(WebDataResources.Security_DbFailure);
            }
        }
        return str;
    }

How to repeat:
Try to generate password reset token

Suggested fix:
Change if (str != null) to if (str == null)
[17 Feb 2015 6:00] Chiranjeevi Battula
Hello Song Kevin,

Thank you for the bug report.
This is duplicate of Bug #75411.

Thanks,
Chiranjeevi.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.