Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you support a web app with hashed or encrypted passwords?

When supporting a new web app in an enterprise environment, it is often necessary to log in as a specific user in order to diagnose a real or perceived problem they are having. Two opposing issues apply here:

  1. Best practice is to use hashed or encrypted passwords, not clear text. Sometimes, there is a third-party SSO (single sign-on) in the middle. There is no way to retrieve the user's password. Unless the user provides it (not encouraged), there is no way to log in as that user.

  2. Many web app's have personalization and complex authorization. Different users have different roles (admin, manager, user) with different permissions. Sometimes users can only see their data -- their customers or tasks. Some users have read-only access, while others can edit. So, each user's view of the web app is unique.

Assume that in an enterprise environment, it isn't feasible to go to the user's desk, or to connect directly to their machine.

How do you handle this situation?

Edit: I want to reiterate that in a large financial institution or typical Fortune 500 company with hundreds of thousands of employees all of the country, and around the world, it is not possible for a mere developer in some IT unit to be able to directly access a user's machine. Some of those are public-facing web apps used by customers (such as online banking and stock trading). And, many of those are intranet applications rely on Active Directory or an SSO, meaning that user credentials are the same for many applications. I do thank you all for your suggestions; some may be highly useful in other kinds of environments.

like image 519
DOK Avatar asked Nov 04 '08 20:11

DOK


People also ask

Are passwords encrypted or hashed?

Hashing vs Encryption However, in almost all circumstances, passwords should be hashed, NOT encrypted. Hashing is a one-way function (i.e., it is impossible to "decrypt" a hash and obtain the original plaintext value). Hashing is appropriate for password validation.

How are passwords hashed?

Password hashing is defined as putting a password through a hashing algorithm (bcrypt, SHA, etc) to turn plaintext into an unintelligible series of numbers and letters. This is important for basic security hygiene because, in the event of a security breach, any compromised passwords are unintelligible to the bad actor.


3 Answers

A number of these ideas inconvenience the user, either by forcing them to change their password, or by occupying their desktop for your debugging session.

Markc's idea is the best: augment your authentication logic to allow superusers to log in as a particular user by supplying not the user's credentials, but the user's name plus their superuser credentials.

I've done it like this in the past (pseudo-ish python):

if is_user_authenticated(username, userpassword):
    login the user
else if ':' in userpassword:
    supername, superpassword = userpassword.split(':')
    if is_superuser_authenticated(supername, superpassword):
        login the user

In other words, if the username and password don't authenticate, if the password has a colon, then it's actually the admin username and admin password joined by a colon, so login as the username if they are the right admin username and password.

This means you can login as the user without knowing their secrets, and without inconveniencing them.

like image 180
Ned Batchelder Avatar answered Sep 20 '22 15:09

Ned Batchelder


For our web applications we use a process that for lack of a better term is defined as 'hijacking' a user's account.

Basically, administrators can 'hijack' a user's account with a simple button click. In the code, you simply use a unique identifier (user id works in a less secure environment) that then establishes the necessary credentials in the session so that they can then work within that user's profile. For a more secure environment you could use a unique hash for each user.

In order to ensure that this hijack method is secure, it always first verifies that the request is being made by an authenticated administrator with the appropriate rights. Because of this it becomes necessary for either the administrator's session to be hijacked or for their authentication credentials to be captured in order for someone to ever exploit the hijack function within the application.

like image 43
Noah Goodrich Avatar answered Sep 20 '22 15:09

Noah Goodrich


I had 4 ideas. While I was typing 3 of them were already suggested (so I upvoted them)

Variant on idea 3 - impersonation:

To make this as "identical as possible" to a normal login with minimal code changes, you might add the ability to impersonate directly at login by supplying Admin credentials plus an alternate username, e.g. login as Admin:user, adminpassword. The system would treat this exactly as logging in as user with userpassword.

Idea 4: Can you access the password store? If so, temporarily replace the user's hash with the hash of a known password. (the passwords are often stored online in a database. A SQL Query tool can do the swaps )

like image 38
Markc Avatar answered Sep 20 '22 15:09

Markc