Password Hashing and User Authentication



Thanks for your time.

When a hashed password is stored in a db - how should it appear in the table?

In the MySQL table I'm using to store username and passwords, it appears as
system.byte[]. The data type is defined as varchar(16), binary. The field
is not behaving as it should during authentication - as long at I enter a
valid username, the system authenticates me despite a correct or incorrect
password value. Below is the code I'm using to hash the password and save
the password to the MySQL table:

Dim md5Hasher As New MD5CryptoServiceProvider
Dim hashedBytes As Byte()
Dim encoder As New UTF8Encoding

hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(txtPwd.Text))

With da.InsertCommand

.Connection = sqlconStBarts
.Parameters.Item("usr").Value = txtUsr.Text
.Parameters.Item("pwd").Value = hashedBytes

db.Open()
.ExecuteNonQuery()
db.Close()

End With

Below is the code i'm using for authentication:

Dim md5Hasher As New MD5CryptoServiceProvider
Dim hashedBytes As Byte()
Dim encoder As New UTF8Encoding

hashedBytes =
md5Hasher.ComputeHash(encoder.GetBytes(txtPassword.Text))

With sqldaSecurity.SelectCommand
.Connection = sqlcon
.Parameters.Item("user").Value = txtUser.Text
.Parameters.Item("pwd").Value = hashedBytes
sqlcon.Open()

If sqldaSecurity.SelectCommand.ExecuteScalar() = "true" Then
sqlcon.Close()
Session.Add("ip_address", Request.UserHostAddress)
Session.Add("user_id", txtUser.Text)
Response.Redirect("AdminDefault.aspx")
Else
lblErr.Visible = True
sqlcon.Close()
End If

End With

.



Relevant Pages

  • MySQL Authentication Bypass
    ... MySQL Authentication Bypass / Buffer Overflow ...
    (Bugtraq)
  • [VulnWatch] MySQL Authentication Bypass
    ... MySQL Authentication Bypass / Buffer Overflow ...
    (VulnWatch)
  • [EXPL] MySQL Authentication Bypass Exploit
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... An authentication vulnerability was reported in our previous article, ... MySQL Authentication ... # break the username string into chars and rebuild it ...
    (Securiteam)
  • Re: FreeRadius and md5 hashed passwords
    ... mysql> select * from radgroupcheck; ... modcall: entering group authorize ... modcall: group authorize returns ok ... >> I have set up freeradius with authentication agains MySQL. ...
    (freebsd-isp)
  • Re: HTTP Post Authentication
    ... Here is a link to very good resource for web authentication topics...not ... > authentication process that validates the incoming transaction prior to ... > Some design ideas that I have in mind are adding a custom request header ... > store username and pswd. ...
    (microsoft.public.dotnet.framework.aspnet)