Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement] Encrypt user_id on account verification instead of actual user_id #728

Open
sidopufn opened this issue Sep 21, 2015 · 6 comments

Comments

@sidopufn
Copy link

When an email is sent to verify a new user's account, the clickback string contains the actual user_id of the user. It would probably be a better practice to use a random or hash value for that clickback instead of the actual user_id.

@OmarElgabry
Copy link
Contributor

+1 encrypted value not hash value

@panique panique changed the title Hash user_id on account verification instead of actual user_id [Security Improvement] Hash user_id on account verification instead of actual user_id Oct 4, 2015
@panique panique changed the title [Security Improvement] Hash user_id on account verification instead of actual user_id [TODO][Security Improvement] Hash user_id on account verification instead of actual user_id Oct 11, 2015
@panique panique changed the title [TODO][Security Improvement] Hash user_id on account verification instead of actual user_id [TODO][Improvement] Hash user_id on account verification instead of actual user_id Nov 29, 2015
@panique panique changed the title [TODO][Improvement] Hash user_id on account verification instead of actual user_id [Improvement] Encrypt user_id on account verification instead of actual user_id Dec 1, 2015
@panique
Copy link
Owner

panique commented Dec 2, 2015

This will generate an extremely long and "ugly" link like this:

/register/verify/d9a32f8b6215ff64957c3e5c58491afb6be76124a51d7424847bfbc66b8d30c3%AD%B4%971%C4%1F%C0%84%93%F3%E6%1C%82%B4%8D%D1E%AB%DF%B7%F9%AE_%AA%29k%D8%23%3C4Mk/88983430bb0286f95a8fb3703b929f9b09a1272d

which is for unknown reasons not clickable in thunderbird, and also fails to become properly de-encrypted, even when used with urldecode() ..

Does somebody know how to do this properly ? Please do not use these links, I think for the initial verification link it's totally okay to use the real user_id. What's the potential value for an attacker, does somebody know this ? thanks! :)

@geozak
Copy link
Contributor

geozak commented Dec 2, 2015

You could hash them like git commit id hashes. Just take the first 7 or so characters and to prevent collisions when generating the value check if the shorted hash is already used by another user and if it is then make it one character longer until there is no conflict. Although with most decent hashing algorithms there should not be any similarities in the hash value of numbers close to each other and unless your user base is millions large that should be even less a problem.

@geozak
Copy link
Contributor

geozak commented Dec 2, 2015

Although I am not sure of the necessity of this is either as the user_id is just a pointer to internal information.
I haven't seen anything in the huge repo that would suggest having a user_id would provide any link into the system and even if there is an attacker could simply make guesses a few thousand time and find a user_id.

There is the possibility of them using it as part an injection attack and dropping that user but that is not a problem with the user_id, its a problem with blocking the attack.

@sidopufn
Copy link
Author

sidopufn commented Dec 2, 2015

The problem with exposing the user_id is that user_id might be used as an identifier outside the platform - like an account number.

@OmarElgabry
Copy link
Contributor

This is because you are sanitizing the URL before passing arguments to action method. And at the same time, you can't omit the sanitizing part .

The solution is to use an algorithm that hashes the user_id like the way YouTube hashes the video Ids, GitHub commits & comment, ...etc(not highly secured as Encryption::encrypt() but It will almost do the job)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants