Some time ago I faced a challenge to design secure method for change email process in our authentication service. Every system has an user and usually uses the email address as a login to the systems. Moreover, they use email address for the purpose of communication with the end user. Even if we had an artificial login name in system, we should still care about the way, how we communicate with the user. Additionally systems use email address for forget password functionality, so it is very sensitive to change or acquisition by potential attacker. That’s why we need to secure it very strong.
There is also a good idea to give the customer a possibility to change the email address defined in system. Especially, if you want to have a long term relationship with him/her.
That’s why it is very important to secure the process of change email address properly. Many sources describe the process of reset password very often, but I didn’t find any information about changing email address.
We will consider two dimensions: action on email address (create or update) and the origin of the request (admin or end user). The whole flow relies on the email sent to the user, both informational and actionable.
Below you can see the diagram of flows for each cases.
Add user flow (triggered by user):
- The user creates a new account
- The application saves the request to create the
user. Applicationsends an email to confirm the email address.
caseof no confirming, system doesn’t create user account and useraccount request is removed.
- In case of confirmation, system send informational email to new address and create a
Add user flow (triggered by admin):
- Admin create new user.
- Application sends informational email to new address.
Change email process flow (triggered by user):
- User changes his email address.
Applicationsaves the request to change the email address.
- The application sends an email to confirm the email address change.
caseof no confirming, system remove the change request from database.
caseof confirmation, system save a new email in the database.
- Then it saves revert change request and the send email to old address with the function to the change.
- In case of ignoring this email, system removes “revert change” request after some delay.
- In case of when
userdecides to reject change, system revert the email address in the database using the stored previous value.
Change email process flow (triggered by admin):
- Admin change his email address.
- Application sends informational email to old and new address.
As you can see on the diagram above we need to sent a few informational emails to user. We can specify following mail types in the process:
- Information email to new address.
- Information email to old address.
- Request to confirm new email sent to new address.
- Information email to old address with the functionality of revert email change (new email should be anonymized like ad*****@br*****.org)
The application doesn’t apply the change of the email immediately. It change it after the confirmation by the affected user on new email (3). Moreover, system notify the user on the old email, that email was changed (4).
That way of changing email is secure against any type of hijacking the account and gives the 100% assurance, that email address is correct.