-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
WASM error handling in SubtleCrypto through web worker #69740
Comments
Tagging subscribers to this area: @dotnet/area-system-security, @vcsjones Issue DetailsThe work to enable WASM to use SubtleCrypto, #65966, had some follow ups on how to handle error cases. Specifically, the communication channel with the web worker could be hardened to convey more errors/failures. This could be accomplished through throwing an exception or the web worker communicating a failure case explicitly. Source hints:
/cc @radical @ericstj @layomia
|
Another suggestion would be for the tests to confirm when running on browser that it did actually use the worker implementation. |
I think this is being done. See src/tests/BuildWasmApps/Wasm.Build.Tests/NativeLibraryTests.cs. There is a check for console output. I commented on this in the JavaScript file. |
Yes, but the xharness webserver is setup in two different places for Wasm.Build.Tests, and the library tests. I was just suggesting that we add some kinda confirmation for the library tests also, so it doesn't accidentally start using the fallback, and we don't find out. |
Note: when fixing this, we also need to ensure that the "lock" added in #70185 is cleared on error. |
Handle exceptions from SubtleCrypto by catching and logging exceptions coming from the crypto stack. Contributes to dotnet#69740
Handle exceptions from SubtleCrypto by catching and logging exceptions coming from the crypto stack. Reset web worker when a request fails. Also, fix race conditions where the web worker can read its own response as part of the next request. Contributes to dotnet#69740
* Better error handling in SubtleCrypto workers Handle exceptions from SubtleCrypto by catching and logging exceptions coming from the crypto stack. Reset web worker when a request fails. Also, fix race conditions where the web worker can read its own response as part of the next request. Contributes to #69740
What is left to do here? |
Only this, if @eerhardt thinks we should do it. |
@radical - do you know how we would do this in the libraries tests? |
One simple check would be to call
runtime/src/mono/wasm/runtime/crypto-worker.ts Lines 120 to 123 in ed2a5a1
|
This is actually a problem in the current code, because of the following C# code: Line 21 in 8f75cc9
This only gets called once, and then cached in the field. So if an error happens subsequently, we don't P/Invoke back into JS code to see if How fast is the P/Invokes in WASM? Should this |
I dunno. I think (in all sincerity) we should just let all crypto operations blow up. |
The work to enable WASM to use SubtleCrypto, #65966, had some follow ups on how to handle error cases. Specifically, the communication channel with the web worker could be hardened to convey more errors/failures. This could be accomplished through throwing an exception or the web worker communicating a failure case explicitly.
Source hints:
crypto-worker.ts
read_response
and consider throwing anerror
.dotnet-crypto-worker.js
try
/catch
inawait_request
.await_request
function could return a bespoke "error occurred" message instead of an exception string.See #69741
/cc @radical @ericstj @layomia
The text was updated successfully, but these errors were encountered: