david-dick / firefox-marionette

This is a client module to automate the Mozilla Firefox browser via the Marionette protocol
https://metacpan.org/dist/Firefox-Marionette
Other
12 stars 3 forks source link

Firefox v127 on Windows 11 crashed with Firefox::Marionette 1.57 + profle_name #45

Closed prozorecJP closed 2 months ago

prozorecJP commented 2 months ago

Hello. I encountered problem on Firefox-127 on Windows 11 with profile name option. The perl script (test.pl) is

use strict;
use warnings;

use Firefox::Marionette;

local $| = 1;

my $firefox = Firefox::Marionette->new(
  'profile_name' => 'test',
  'visible' => 1,
  'survive' => 1,
  'har' => 1
  );
sleep (2);
print "Marionette version=", $Firefox::Marionette::VERSION, "\n";

And the error message is

unknown error: [Exception... "Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIWebAuthnService.addVirtualAuthenticator]" nsresult: "0x80004001 (NS_ERROR_NOT_IMPLEMENTED)" location: "JS frame :: chrome://remote/content/marionette/webauthn.sys.mjs :: webauthn.addVirtualAuthenticator :: line 39" data: no] at test.pl line 8 If I remove profile_name option, it looks OK. I also tried the script on FreeBSD-14.1 and the script worked, so I guess this is something related to Windows.

david-dick commented 2 months ago

Very interesting. Can you try with adding webauthn => 0 to the list of parameters for the new call?

prozorecJP commented 2 months ago

I changed something like this.

my $firefox = Firefox::Marionette->new(
  'profile_name' => 'test',
  'visible' => 1,
  'survive' => 1,
  'har' => 1,
  'webauthn' => 0
  );

This works fine.

david-dick commented 2 months ago

okay, it looks like something in that profile has disabled webauthn. Any ideas?

david-dick commented 2 months ago

my config settings look like


security.webauth.webauthn   true    
security.webauth.webauthn_enable_android_fido2  false   
security.webauth.webauthn_enable_softtoken  false   
security.webauth.webauthn_enable_usbtoken   true    
security.webauth.webauthn_testing_allow_direct_attestation  false   
security.webauthn.ctap2 true    
security.webauthn.webauthn_enable_android_fido2.residentkey false
prozorecJP commented 2 months ago

test profile contains

security.webauth.webauthn   true    
security.webauth.webauthn_enable_softtoken  false   
security.webauth.webauthn_enable_usbtoken   true    
security.webauth.webauthn_testing_allow_direct_attestation  false   
security.webauthn.ctap2 true    
security.webauthn.enable_conditional_mediation  true    
security.webauthn.enable_json_serialization_methods true    
security.webauthn.enable_macos_passkeys true    
security.webauthn.show_ms_settings_link true    
security.webauthn.webauthn_enable_android_fido2.residentkey false
prozorecJP commented 2 months ago

I'm rather puzzled. If I start firefox with -p test, then Settings privacy and securities -> Passwords -> Ask to save password is checked. However if I start firefox with -p test -marionette, the same option is unchecked. Is this something related to this case?

david-dick commented 2 months ago

Not sure. The original case is caused by when an existing profile is used on Windows, the security.webauth.webauthn_enable_softtoken preference for that profile must be set to true. That should fix your immediate problem. I need some time to think about the best way to fix this in a more long term way.

prozorecJP commented 2 months ago

Indeed, security.webauth.webauthn_enable_softtoken=true solves the issue. Thank you.

david-dick commented 2 months ago

i think this issue can be resolved by documenting the issue as part of the profile_name parameter part of the new call. Does that sound acceptable to you?

prozorecJP commented 2 months ago

Yes, the documentation helps to avoid this issue.

I have 2 questions.

  1. Are there any other configuration parameters to be changed? I notice lots of values are set in profile new module and I have no idea how they work.
  2. Is there any way to change configuration value while firefox is running? I understand changing configuration value on the fly doesn't solve the issue, but I just wonder if there is any way.
david-dick commented 2 months ago

Answers follow;

1) I'm not too sure. I mainly set the configuration to resist tracking, fingerprinting and improving privacy as much as possible. Some of them will be for very old firefox versions, so there may be no impact for recent versions.

2) Have a look at the set_pref method in Firefox::Marionette. It will change the config values for that profile permanently though.

Documentation has been pushed. Reopen if you wish to discuss. Thanks for the bug report