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

[Problem/Bug]: Unable to launch application using a webview2 component in process running under a restricted token #4850

Open
davte-beijer opened this issue Oct 7, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@davte-beijer
Copy link

davte-beijer commented Oct 7, 2024

What happened?

I have an application (app launcher) that needs to launch other applications. The app launcher starts the other application with a restricted token in order to protect certain directories that are only intended for the app launcher. When a launched application contains a webview2 component it is rendered blank since the renderer process seem to fail.

Importance

Blocking. My app's basic functions are not working due to this issue.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

127.0.2651.86

SDK Version

1.0.2792.45

Framework

WPF

Operating System

Windows 10

OS Version

10.0.19045 Build 19045

Repro steps

Reproduction Steps

Create two applications, one representing the "app launcher" and one representing the "app to launch" with a webview2 component.

  1. In the implementation of the app launcher call method CreateRestrictedToken in order to create a restricted token.
CreateRestrictedToken(
                    Token, // <-- current token
                    0,
                    0, IntPtr.Zero,
                    0, IntPtr.Zero,
                    (uint)restrictedSidStrings.Count, restrictedSidsPtr,  // <-- Provide some valid SID data to these two parameters
                    out SafeTokenHandle restrictedToken))
  1. Then call method CreateProcessAsUser providing the restricted token from step 1
CreateProcessAsUser(
                    restrictedToken,
                    appToRun, // <--- path to application to launch with a restricted token
                    IntPtr.Zero,
                    IntPtr.Zero,
                    false,
                    0,
                    IntPtr.Zero,
                    startupFolder, 
                    ref startupInfo,
                    out PROCESS_INFORMATION processInfo))
  1. Execute the app launcher to start the application to launch. No webview2 component is rendered.

Repros in Edge Browser

Yes, issue can be reproduced in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

@davte-beijer davte-beijer added the bug Something isn't working label Oct 7, 2024
@victorhuangwq
Copy link
Collaborator

you stated this

Yes, issue can be reproduced in the corresponding Edge version

Is this by accident, else could you elaborate?

@davte-beijer
Copy link
Author

davte-beijer commented Oct 8, 2024

I might have interpreted that field wrong in the template... however i did the same scenario, but instead of launching an application hosting a webview2 component I instead launched msedge.exe in similar fashion with a restricted token, which seem to end up with the same result, i.e. nothing is rendered in the browser.

@davidterins
Copy link

davidterins commented Oct 14, 2024

@victorhuangwq what is the status of this issue?

@victorhuangwq
Copy link
Collaborator

I am assuming this is the same result if you launch a Chrome browser as well?

@LiangTheDev
Copy link
Member

This is currently a limitation of WebView2. Chromium code will try to setup sandbox for renderer process and to setup the sandbox, it requires a lot of privilege and would not work if the process is with a restricted token.
WebView2 works in AppContainer for supporting of UWP apps. If you create the sandboxed app in an AppContainer, then it would work.

@davte-beijer
Copy link
Author

Okay will look into appcontainers to work around this limitation.

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

4 participants