I'm trying to think of a way to get around the following, because it looks like someone did, and I want to fix it. But, I would really like to understand how the attack works before fixing it with something like OWASP Recommendation
Set conn = Server.CreateObject("ADODB.Connection")
conn.open xDb_Conn_Str
sSql = "SELECT * FROM [User]"
sSql = sSql & " WHERE [Username] = '" & CleanSql(sUserId) & "'"
Set rs = conn.Execute(sSql)
CleanSql -
Function CleanSql(str)
Dim sWrk
sWrk = Trim(str&"")
sWrk = Replace(sWrk, "'", "''") ' Adjust for Single Quote
sWrk = Replace(sWrk, "[", "[[]") ' Adjust for Open Square Bracket
CleanSql = sWrk
End Function
Single quote is obviously escaped in this.
Right after this it will do a check if it finds the user to validate the password with the following:
If UCase(rs("Password")) = UCase(sPassWd) Then
DoStuff()
Any help is appreciated.