Skip to content

"Access Denied" on CoCreateInstance causes IEDriverServer crash on Windows' #5564

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

Closed
kart opened this issue Mar 4, 2018 · 1 comment
Closed
Labels

Comments

@kart
Copy link

kart commented Mar 4, 2018

Meta -

OS: Windows Server 2012 R2

Selenium Version: 3.0.1, IEDriver version: 3.0.0.0

Browser: IE10/IE11

In our environment, IEDriverServer.exe runs as a low privileged user and it runs fine for
the most part. The environment is deployed as a Windows VM (2012R2) on Amazon EC2. Also,
we are running with IEDriver version 3.0.0.0. But, I have verified that the problem persists
even in the most recent version of the driver.

After running webdriver scripts for a while, things start to go south. For reasons unknown, IEDriverServer begins crashing everytime an attempt is made to create a new webdriver.
Nothing fancy, just a simple webdriver.Ie() is enough to crash the IEDriverServer.

I managed to get the crash dump and after debugging it for a bit, I discovered that, in
AttachToBrowserUsingShellWindows, an attempt is made to CoCreateInstance of
CLSID_ShellWindows and this call fails with 'Access Denied'. Since there is no error
checking following this, later code which tries to invoke _NewEnum on the IShellWindows
fails badly.

bool BrowserFactory::AttachToBrowserUsingShellWindows(
...
  CComPtr<IShellWindows> shell_windows;
  shell_windows.CoCreateInstance(CLSID_ShellWindows);

  CComPtr<IUnknown> enumerator_unknown;
  HRESULT hr = shell_windows->_NewEnum(&enumerator_unknown);
  if (FAILED(hr)) {
    LOGHR(WARN, hr) << "Unable to get enumerator from IShellWindows interface";
    return false;
  }

Notice that there is no check for HRESULT for the CoCreateInstance call. In our environment,
this call fails and as a result shell_windows instance is bogus.

There are two aspects that I don't understand:

  1. The system runs fine for a while, and only then it starts misbehaving. It appears as if
    the permissions to CoCreateInstance was valid at one point for the low-privileged user and
    becomes invalid later.

  2. Given that the low-privileged user is unable to CoCreateInstance, how can it be fixed?
    I tried to poke around Component Services but even when logged in as administrator, all
    the property settings are greyed out for ShellWindows.

I'd be happy to attach the crash dump if needed. I can submit a patch for the missing check for CoCreateInstance call.

Browser Version: IE10/IE11

Expected Behavior -

No IEDriverServer.exe crashes. And the driver object should be created without any issues.

Actual Behavior -

IEDriverServer.exe crashes because of 'Access Denied' for CoCreateInstance.

Steps to reproduce -

There is no easy way to reproduce this. It happens in our system after running scripts for a long time as the unprivileged user.

@jimevans
Copy link
Member

I've papered over the crash, adding error checking around the call to CoCreateInstance. Unfortunately, if that call fails, there's precious little the driver can do about it. That's calling into an OS component that the driver has no influence on or control over.

@lock lock bot locked and limited conversation to collaborators Aug 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants