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

[BUG] - Value of form input for email is over-trusted #67

Open
peaceful-james opened this issue Jun 25, 2024 · 3 comments
Open

[BUG] - Value of form input for email is over-trusted #67

peaceful-james opened this issue Jun 25, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@peaceful-james
Copy link
Contributor

Description

The handle_info of :registration_successful trusts the assigned form value of the email. The email could be changed during the WebAuthn flow.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Visit http://localhost:4000/sign-in
  2. Enter [email protected] into the email input.
  3. In console, run this JS:
function changeEmail() {
  var emailInput = document.getElementById("email")
  emailInput.value = "[email protected]";
  emailInput.dispatchEvent(new Event("input", {bubbles: true}))
}

setTimeout(changeEmail, 10000);
  1. Click "Sign Up".
  2. Wait at most 10 seconds for the email input to change (because of JS from step 3).
  3. Complete the sign up flow successfully.

Expected behavior

The difference in the form email and the email of the created passkey should cause user creation to fail.

Suggestion

Pass the email back as part of the :registration_successful payload and check that the form email matches exactly.

I do not think this is a realistic attack vector for any serious system. Email confirmation should be done after creating the passkey.

@peaceful-james peaceful-james added bug Something isn't working triage Needs to be prioritized labels Jun 25, 2024
@type1fool
Copy link
Collaborator

Thank you for the bug report, @peaceful-james. I will look into this.

@type1fool
Copy link
Collaborator

I see what's happening here. The email field from the form is being read when :registration_successful is received, where it should be taking the value from the @webauthn_user assign or possibly a separate assign.

It may also be preferable to remove the email form field when the registration starts so it can't be modified. That may lead to a bit of rethinking the design of the authentication_live.ex template used by the code generator. 🤔

Good catch! I will consider breaking up the form into a multistep process, which will probably affect the way the component works as well.

@type1fool type1fool removed the triage Needs to be prioritized label Jun 26, 2024
@type1fool
Copy link
Collaborator

Relates to #76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants