oscarb / flowlist

A read it sooner list populated by your friends
MIT License
2 stars 1 forks source link

Hash phone number #7

Closed oscarb closed 7 years ago

oscarb commented 7 years ago

To allow the user to see which contacts are also users of Flowlist contact phone numbers needs to be stored on the backend along with a user id.

To respect user privacy and avoid leaking sensitive data, the phone number of a user should not be stored in a readable format on the back-end. A solution would be to hash the phone number.

However, as phone numbers follow a limited pattern, lookup tables can easily be generated.

How can phone numbers be hashed to reduce the risk of an attacker resolving the phone number behind the hash?

oscarb commented 7 years ago

Similar topics:

oscarb commented 7 years ago

Using a salt would increase the "strength" of the hash. However there are two situations where the phone number is used in different contexts:

Therefore, a salt needs to be based on information available to both Adam and Eve. In this case, other than the phone number the name of the user could be shared. However, if Eve has named Adam something else in her phonebook, e.g. "Adam at Work", then a common salt can not be generated.

oscarb commented 7 years ago

A secret salt could be stored on the server to increase the strength of the hash. Then every phone number would be hashed like

phoneNumberHash = hashFunction(SECRET_SALT + phoneNumber)

This solution would be as secure as the salt is secret.

oscarb commented 7 years ago

Another solution would be to base the salt on information about the phone number (as the phone number of Adam is the only information available to both Adam and Eve).

For example, if the country code of the phone number can be retrieved, the salt could be based on that.

phoneNumber = "+46123456789"
countryCode = getCountryCode(phoneNumber) // +46
individualSalt = getCountryName(countryCode) // Sweden
phoneNumberHash = hashFunction(individualSalt + phoneNumber)

This could then be combined with a secret salt, e.g:

phoneNumberHash(individualSalt + SECRET_SALT + phoneNumber)

Would this approach make it difficult enough to generate lookup tables so that the hashes can be stored on the back-end without the risk of exposing users phone numbers?

dbosk commented 7 years ago

If you base the salt on a part of the phone number (e.g. country code), then it is no better than just the phone number. To add any value, it must be independent from the phone number, e.g. the name (which causes problems as you mentioned above).

You can have a secret salt (one salt per phone number, same as for passwords), then you'd protect the list of registered phone numbers. But each user must submit the contact list in plaintext, as it's only the server who has the salts required for the hashing.

This is not an easily solved problem, see Difficulty of Private Contact Discovery. But we're working on it ;-)

dbosk commented 7 years ago

Just to try to think of other solutions: why do you want to allow anyone with your phone number to send stuff to your reading lists? Do you want anyone with your email address to put emails in your inbox? (I'm thinking of all those emails that you now have to filter to your spam folder, which is a bad solution already from the start.)

A solution for this would be a secure and usable identity manager which is fully decentralized. I think that one of the main problems facing Signal (in the above article) is that it's a centralized solution. The same applies to your thinking above, it's a centralized solution. I'll get back to you with a suggestion.

dbosk commented 7 years ago

You can probably change the title of this issue to "contact discovery".

oscarb commented 7 years ago

Note to self - look into this for hashing: https://github.com/jdconley/pwhaas

dbosk commented 7 years ago

I looked at this one only quickly. Interesting idea, but I'm not entirely comfortable with it yet.

On Sun 04 Jun 2017 14:37:16 GMT, Oscar Björkman wrote:

Note to self - look into this for hashing: https://github.com/jdconley/pwhaas

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/oscarb/flowlist/issues/7#issuecomment-306068749

dbosk commented 7 years ago

And it will not help you for the case of phone numbers: there are too few of them, so brute force works.

oscarb commented 7 years ago

https://github.com/SilentCircle/contact-discovery

Interesting read, needs further investigation if this would be suitable for Flowlist.

oscarb commented 7 years ago

Solution

The solution I will move forward with is to not hash the phone numbers of users. Instead Flowlist will limit the phone numbers that are transferred from the contact book to only those necessary. Any transfer of phone numbers is done over HTTPS.

Discussion

Pros

Cons

Flow

Sign up

Sharing links

Getting links

Flowlist Web

At first Adam should be able to login and see his lists by verifying his phone number. Photos and names will not be available for the senders of the links, neither will Adam be able to send links using the web version.

Adam should be able to either