Click here to Skip to main content
15,884,298 members
Home / Discussions / C#
   

C#

 
GeneralRe: Hosting ActiveX Pin
Heath Stewart28-Dec-03 3:58
protectorHeath Stewart28-Dec-03 3:58 
Generalfiltering properties Pin
Roger Alsing28-Dec-03 1:34
Roger Alsing28-Dec-03 1:34 
GeneralRe: filtering properties Pin
Wizard_0128-Dec-03 2:53
Wizard_0128-Dec-03 2:53 
GeneralRe: filtering properties Pin
Roger Alsing28-Dec-03 3:37
Roger Alsing28-Dec-03 3:37 
GeneralRe: filtering properties Pin
Wizard_0128-Dec-03 4:07
Wizard_0128-Dec-03 4:07 
GeneralRe: filtering properties Pin
Roger Alsing28-Dec-03 4:34
Roger Alsing28-Dec-03 4:34 
GeneralRe: filtering properties Pin
Heath Stewart28-Dec-03 3:38
protectorHeath Stewart28-Dec-03 3:38 
GeneralSalted Hash add vulnerabilities Pin
laphijia27-Dec-03 23:15
laphijia27-Dec-03 23:15 
I was going through the process of deciding how to store my passwords in a SQL Server database.

I was using the basic hashing approach when I came through the idea of trying with salted hashes.

When using normal hashed I didn't need to retrieve the password from the database. What I would do was to use a stored procedure like this.

CREATE PROCEDURE [dbo].[proc_authenticate]
(
@UserID nvarchar(16),
@Password nvarchar(64),
@SessionVariable nvarchar(64)
)
AS

DECLARE @AuthUserId nvarchar (16)
SET @AuthUserId = (SELECT UserId FROM Users WHERE (UserID = @UserID AND Password = @Password))

-- IF ABOVE SELECT RETURN ONLY ONE ROW THEN STORE SESSION VARIABLE IN LOCALS TABLE ELSE RETURN

IF @AuthUserId = null
RETURN

UPDATE Locals
SET
SessionVariable = @SessionVariable,
LastLoginDate = GETDATE()
WHERE (UserID = @UserID)
GO


Basically in my application I would ask the user for a username and password. Then I would generate a random session variable.
I send everything to the stored procedure on SQL Server.

It's the stored procedure that does all the authentication and there is no way to read a password if not by compromising SQL Server and gaining SA privileges.

On the other hand the approach with salted hashes is different.

1- Retrieve the stored password and the salt for an user using a stored procedure.
2- Extract salt
3- Calculate salted hash of user provided password
4- Compare stored password with user provided
5- If they are the same call a stored procedure that given UserID writes a ticket in the database.


Step one means basically giving away the User table to anybody that can steal our connection string.

This in my opinion is a security problem because basically just by cracking the user of our connection string we can retrieve any password from any user. Of course it's hashed and salted and the malicious user has to guess a username but he can use a brute force attack to decode a password.

With the previous approach instead to use brute force attack he would have had to call the sored procedure once for every attempt. This would have slowed him down and would leave a trace in our logs of a suspect activity.

But since we cannot autheniticate from inside a stored procedure using Salted Hashes we have to retrieve the password. In this case an attacker can perform the brute force attack on his own computer without any delay from accessing our server through the internet and without leavin any trace.

Step five is even worst because one can just bypass the whole authentication system and authenticate himself. Of course we might sign our tickets using a keyed hash using the server private key so that the attacked cannot just generate a ticket.

What are your opinions to this approach. I have to say that I didn't come up with this but read it in Wrox C# Data Security Handbook so I'm surprised that a tested procedure seems so weak to me.

Edd
GeneralRe: Salted Hash add vulnerabilities Pin
Heath Stewart28-Dec-03 3:34
protectorHeath Stewart28-Dec-03 3:34 
QuestionHow to use array update the xml file?███ Pin
nichen100127-Dec-03 20:19
nichen100127-Dec-03 20:19 
AnswerRe: How to use array update the xml file? Pin
Nick Parker28-Dec-03 3:19
protectorNick Parker28-Dec-03 3:19 
GeneralAttention C++ developers Pin
Alex Korchemniy27-Dec-03 15:40
Alex Korchemniy27-Dec-03 15:40 
GeneralRe: Attention C++ developers Pin
Colin Angus Mackay27-Dec-03 17:07
Colin Angus Mackay27-Dec-03 17:07 
GeneralRe: Attention C++ developers Pin
Alex Korchemniy27-Dec-03 17:11
Alex Korchemniy27-Dec-03 17:11 
GeneralRe: Attention C++ developers Pin
Colin Angus Mackay27-Dec-03 17:52
Colin Angus Mackay27-Dec-03 17:52 
GeneralRe: Attention C++ developers Pin
leppie27-Dec-03 19:07
leppie27-Dec-03 19:07 
GeneralRe: Attention C++ developers Pin
Heath Stewart28-Dec-03 3:21
protectorHeath Stewart28-Dec-03 3:21 
QuestionHow Do I transform 2d coordinates of the mouse into 3d? Pin
SherKar27-Dec-03 14:21
SherKar27-Dec-03 14:21 
AnswerRe: How Do I transform 2d coordinates of the mouse into 3d? Pin
Colin Angus Mackay27-Dec-03 17:55
Colin Angus Mackay27-Dec-03 17:55 
AnswerRe: How Do I transform 2d coordinates of the mouse into 3d? Pin
leppie27-Dec-03 19:12
leppie27-Dec-03 19:12 
GeneralRe: How Do I transform 2d coordinates of the mouse into 3d? Pin
Colin Angus Mackay28-Dec-03 1:55
Colin Angus Mackay28-Dec-03 1:55 
GeneralRe: How Do I transform 2d coordinates of the mouse into 3d? Pin
Nick Parker28-Dec-03 3:44
protectorNick Parker28-Dec-03 3:44 
GeneralRe: How Do I transform 2d coordinates of the mouse into 3d? Pin
Colin Angus Mackay28-Dec-03 12:13
Colin Angus Mackay28-Dec-03 12:13 
GeneralRe: How Do I transform 2d coordinates of the mouse into 3d? Pin
Nick Parker28-Dec-03 16:55
protectorNick Parker28-Dec-03 16:55 
AnswerRe: How Do I transform 2d coordinates of the mouse into 3d? Pin
Bryan White29-Dec-03 22:30
Bryan White29-Dec-03 22:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.