formtools / module-submission_accounts

The Submission Accounts module.
https://docs.formtools.org/modules/submission_accounts/
GNU General Public License v3.0
2 stars 7 forks source link

Encryption of passwords #11

Open kubajal opened 5 years ago

kubajal commented 5 years ago

Hello, to begin with, Submission Accounts is a very useful module that I want to use in order to register editable submissions in my NGO organization. The problem I am facing is that according to https://docs.formtools.org/userdoc/field_types/ft_passwords/ fields of type "Password" are stored as plain text. It is possible to see their unencrypted value in the database, which imho discourages the usage of Submission Accounts. Is there any extension to Form Tools that encrypts password fields? If not, how would such an extension look like? Any tips would be welcome because I have only very basic knowledge of PHP. I assume that the prefered way to implement such a functionality is to use Submission Pre-Parser. There we can extract the password field from the POST request, use some kind of hashing to encrypt it and then save the result to the database, am I right? Thanks in advance.

kubajal commented 5 years ago

OK, after some more investigation I think that implementation would not be that hard. There are 2 things to do in order to encrypt passwords:

  1. encrypt all "password" fields, probably using Submissions Pre-Parser (is there a better way? I imagine there must be a more low-level way to do so for example hardcoding encryption in the module that implements all default field types, but I do not know which one that is),
  2. in the Users class of Submission accounts change:
    • login function so that it validates passwords using the same encryption method as in 1.,
    • sendPassword to generate a random password and send it to the user instead of sending the password from the database as plain text.

There are some more questions I have in mind:

  1. Would low-level encryption of all "password" fields have any impact on other modules than Submission Accounts?
  2. What encryption method would you recommend? Would password_hash() with PASSWORD_BCRYPT be sufficient?
kubajal commented 5 years ago

After more investigation I created 3 pull requests:

  1. module-submission_accounts: https://github.com/formtools/module-submission_accounts/pull/12
  2. core: https://github.com/formtools/core/pull/617
  3. module-form_builder: https://github.com/formtools/module-form_builder/pull/37

In general, I found a low level way encrypt password fields using _phpprocessing hook in Core\Password.class.

@benkeen, it would be awesome if you could review the changes. Thanks!

mmelon commented 3 years ago

i would love to see password encryption added to the module. Also a fix for multiple submissions with the same username and password.

https://github.com/formtools/module-submission_accounts/issues/13

I think it should detect the same username and password and update the record rather than creating a new one that can no longer be viewed or edited.

@kubajal could you fork the module and develop it a bit more?

philipschilling commented 3 years ago

I just ran into the same issues:

kubajal commented 3 years ago

I'm sorry for late response, I haven't visited this thread for a very long time. At the moment I do not have time to take a look into this issue again.

philipschilling commented 3 years ago

Thank you and no problem. It was just feedback.