Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update password autofill mechanism to simulate user typing behavior (#684)

Leendert de Borst3c72fa3fdedb
diff --git a/browser-extension/src/utils/formDetector/FormFiller.ts b/browser-extension/src/utils/formDetector/FormFiller.ts
index 7ac8182dc..4aacfd523 100644
--- a/browser-extension/src/utils/formDetector/FormFiller.ts
+++ b/browser-extension/src/utils/formDetector/FormFiller.ts
@@ -35,12 +35,12 @@ export class FormFiller {
}
if (this.form.passwordField) {
- this.form.passwordField.value = credential.Password;
+ this.fillPasswordField(this.form.passwordField, credential.Password);
this.triggerInputEvents(this.form.passwordField);
}
if (this.form.passwordConfirmField) {
- this.form.passwordConfirmField.value = credential.Password;
+ this.fillPasswordField(this.form.passwordConfirmField, credential.Password);
this.triggerInputEvents(this.form.passwordConfirmField);
}
@@ -70,6 +70,26 @@ export class FormFiller {
}
}
+ /**
+ * Fill the password field with the given password. This uses a small delay between each character to simulate human typing.
+ * In the past there have been issues where Microsoft 365 login forms would clear the password field when just setting the value directly.
+ *
+ * @param field The password field to fill.
+ * @param password The password to fill the field with.
+ */
+ private async fillPasswordField(field: HTMLInputElement, password: string): Promise<void> {
+ // Clear the field first
+ field.value = '';
+ this.triggerInputEvents(field);
+
+ // Type each character with a small delay
+ for (let i = 0; i < password.length; i++) {
+ field.value = password.substring(0, i + 1);
+ // Small random delay between 5-15ms to simulate human typing
+ await new Promise(resolve => setTimeout(resolve, Math.random() * 10 + 5));
+ }
+ }
+
/**
* Fill the birthdate fields of the form.
* @param credential The credential to fill the form with.