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

ExtendedProcessFailedEventArgs.md #3824

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review comments
  • Loading branch information
vbryh-msft committed Sep 28, 2023
commit b5d7cafdd47824a190695588e01b73cac60b0cbe
38 changes: 25 additions & 13 deletions specs/ExtendedProcessFailedEventArgs.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@

Title
Code integrity failure source module path
===

# Background
Code integrity is a feature of Windows that verifies the authenticity and integrity of the code that runs on the system. It helps protect it from malware, tampering, and unauthorized changes. Code integrity checks the digital signatures of the files that are loaded into memory, and prevents any file that does not have a valid signature from running in WebView2. We are extending ProcessFailedEventArgs with BlockedFile property which caused webview2 process to exit with code STATUS_INVALID_IMAGE_HASH.
[Windows Code Integrity](https://learn.microsoft.com/en-us/mem/intune/user-help/you-need-to-enable-code-integrity) is a feature that verifies the
integrity of the code that runs on the system. It helps protect it from malware,
tampering, and unauthorized changes. Code integrity checks the digital
signatures of the files that are loaded into memory, and prevents any
file that does not have a valid signature from running in WebView2 process.
We are extending ProcessFailedEventArgs with FailureSourceModulePath property
which caused webview2 process to exit with code STATUS_INVALID_IMAGE_HASH.

# Examples

Expand All @@ -13,7 +19,10 @@ Code integrity is a feature of Windows that verifies the authenticity and integr
{
if (e.ExitCode == -1073740760 /*STATUS_INVALID_IMAGE_HASH*/)
{
SendTelemetry(e.BlockedFile);
// If the process crashed because of STATUS_INVALID_IMAGE_HASH,
// then we want to log to our app's telemetry the name of the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
// then we want to log to our app's telemetry the name of the
// then we want to log to our app's telemetry the path of the

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix.

// DLL that caused the issue.
SendTelemetry(e.FailureSourceModulePath);
}
}
```
Expand All @@ -28,10 +37,13 @@ Code integrity is a feature of Windows that verifies the authenticity and integr
CHECK_FAILURE(args->get_ExitCode(&exit_code));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_ExitCode is a method on ICoreWebView2ProcessFailedEventArgs2, so would have to QI to it first.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix.


if (exit_code == -1073740760 /*STATUS_INVALID_IMAGE_HASH*/) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FailureSourceModulePath doesn't appear to be specific to STATUS_INVALID_IMAGE_HASH or Windows Code Integrity. Is the expectation that this string could be populated in other failure cases, but STATUS_INVALID_IMAGE_HASH is the only case when we're currently promising it will always be populated?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that is exactly what I was thinking.

wil::unique_cotaskmem_string blockedFile;
CHECK_FAILURE(arg_blocked_file->get_BlockedFile(&blockedFile));
wil::unique_cotaskmem_string modulePath;
CHECK_FAILURE(args->get_FailureSourceModulePath(&modulePath));

SendTelemetry(blockedFile);
// If the process crashed because of STATUS_INVALID_IMAGE_HASH,
// then we want to log to our app's telemetry the name of the
// DLL that caused the issue.
SendTelemetry(modulePath);
}

return S_OK;
Expand All @@ -42,29 +54,29 @@ Code integrity is a feature of Windows that verifies the authenticity and integr
# API Details

```
/// A continuation of the ICoreWebView2ProcessFailedEventArgs2 interface
/// fot getting blocked file for code integrity process failures.
[uuid(a9fc1af8-f934-4f0f-a788-7be0808c329b), object, pointer_default(unique)]
interface ICoreWebView2ProcessFailedEventArgs : IUnknown {
vbryh-msft marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Um, we already have a ICoreWebView2ProcessFailedEventArgs. and even a ICoreWebView2ProcessFailedEventArgs2. Shouldn't this be ICoreWebView2ProcessFailedEventArgs3?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix. Yes, should be ICoreWebView2ProcessFailedEventArgs3 and it should be derived from ICoreWebView2ProcessFailedEventArgs2

/// This property is the full path of the module that caused the
/// crash in cases of Windows Code Integrity failures.
/// Code Integrity is a feature that verifies the integrity and
david-risney marked this conversation as resolved.
Show resolved Hide resolved
/// authenticity of dynamic-link libraries (DLLs)
/// on Windows systems. It ensures that only trusted
/// code can run on the system and prevents unauthorized or
/// malicious modifications.
/// When ProcessFailed occurred due to a failed Code Integrity check,
/// this property returns the name of the blocked file that was prevented from
/// this property returns the full path of the file that was prevented from
/// loading on the system.
/// The webview2 process which tried to load blocked DLL will fail with
/// The webview2 process which tried to load the DLL will fail with
/// exit code STATUS_INVALID_IMAGE_HASH(-1073740760).
/// A file can be blocked for various
/// A file can fail integrity check for various
/// reasons, such as:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be out of scope, but will the developer ever need to know the more specific reason?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this is required and we can look into adding it if necessary in the future. @vbryh-msft or @aluhrs13 can comment otherwise.

/// - It has an invalid or missing signature that does
/// not match the publisher or signer of the file.
/// - It has been tampered with or corrupted by malware or other software.
/// - It has been blocklisted by an administrator or a security policy.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// - It has been blocklisted by an administrator or a security policy.
/// - It has been blocked by an administrator or a security policy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix.

/// This property always will be empty if failure is not caused by
david-risney marked this conversation as resolved.
Show resolved Hide resolved
/// STATUS_INVALID_IMAGE_HASH.
[propget] HRESULT BlockedFile([out, retval] LPWSTR* blockedFile);
[propget] HRESULT FailureSourceModulePath([out, retval] LPWSTR* modulePath);
}
```

Expand All @@ -77,7 +89,7 @@ namespace Microsoft.Web.WebView2.Core
[interface_name("Microsoft.Web.WebView2.Core.ICoreWebView2ProcessFailedEventArgs3")]
{
// ICoreWebView2ProcessFailedEventArgs3 members
String BlockedFile { get; };
String FailureSourceModulePath { get; };
}

}
Expand Down