dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.28k stars 1.76k forks source link

[Bug] [WebAuthenticator] [iOS] Native iOS crash when completing authentication in a separate browser app #16733

Open nc-kano opened 1 year ago

nc-kano commented 1 year ago

Description

This is the copy of the bug from https://github.com/xamarin/Essentials/issues/1519 and https://github.com/xamarin/Essentials/issues/1242 After migration to MAUI Essentials we can see it is still the issue.

Description

Authenticating from a separate browser window results in a native iOS crash even though you get an auth result back. Steps to Reproduce

Steps to Reproduce

1. Call AuthenticateAsync
2. Copy the URL from the embedded web view
3. Open Safari (or another browser app)
4. Paste and go to the URL
5. Complete the auth
6. Verify you get a WebAuthenticationResult back
7. Verify in your console/output you get a native iOS crash
8. Your app should no longer be usable

Link to public reproduction project repository

https://github.com/nc-kano/MauiWebAuthenticatorIssue

No access to BE to specify .well-known/apple-app-site-association. Just replace host and redirect url. It crash with ANY https redirect url

Version with bug

8.0.0-preview.7.8842

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 13 - 16

Did you find any workaround?

a in the https://github.com/xamarin/Essentials/issues/1242#issuecomment-620126451 a custom build of Xamarin.Essentials with suggested workaround do the thing

Relevant log output

=================================================================
    Native Crash Reporting
=================================================================
Got a segv while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

=================================================================
    Native stacktrace:
=================================================================
    0x10734ff0c - /private/var/containers/Bundle/Application/924B7BB5-4532-4486-B042-990061097314/Samples.iOS.app/Samples.iOS : _ZN7plcrash2MS5async24dwarf_cfa_state_iteratorIyxE4nextEPjPNS1_28plcrash_dwarf_cfa_reg_rule_tEPy
    0x107346178 - /private/var/containers/Bundle/Application/924B7BB5-4532-4486-B042-990061097314/Samples.iOS.app/Samples.iOS : _ZN7plcrash2MS5async24dwarf_cfa_state_iteratorIyxE4nextEPjPNS1_28plcrash_dwarf_cfa_reg_rule_tEPy
    0x107354334 - /private/var/containers/Bundle/Application/924B7BB5-4532-4486-B042-990061097314/Samples.iOS.app/Samples.iOS : mono_pmip
    0x1d8c4edbc - /usr/lib/system/libsystem_platform.dylib : <redacted>
    0x1d8be8784 - /usr/lib/system/libsystem_blocks.dylib : _Block_release
    0x1d8be8784 - /usr/lib/system/libsystem_blocks.dylib : _Block_release
    0x1d8be8784 - /usr/lib/system/libsystem_blocks.dylib : _Block_release
    0x194ff7b54 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
    0x194ffc0e8 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
    0x19512dfd4 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
    0x195c8b80c - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
    0x195c8b4c0 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
    0x195cc0a5c - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
    0x195c95114 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
    0x195c9561c - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
    0x195c9576c - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
    0x1961e15e8 - /System/Library/Frameworks/QuartzCore.framework/QuartzCore : <redacted>
    0x192bba280 - /usr/lib/system/libdispatch.dylib : <redacted>
    0x192b9c5b8 - /usr/lib/system/libdispatch.dylib : <redacted>
    0x192f00c30 - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : <redacted>
    0x192efb0e8 - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : <redacted>
    0x192efa200 - /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation : CFRunLoopRunSpecific
    0x1a9077598 - /System/Library/PrivateFrameworks/GraphicsServices.framework/GraphicsServices : GSEventRunModal
    0x1957c3bcc - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : <redacted>
    0x1957c91a0 - /System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore : UIApplicationMain
    0x1049874a8 - /private/var/containers/Bundle/Application/924B7BB5-4532-4486-B042-990061097314/Samples.iOS.app/Samples.iOS : _ZN7plcrash2MS5async24dwarf_cfa_state_iteratorIyxE4nextEPjPNS1_28plcrash_dwarf_cfa_reg_rule_tEPy
    0x1040411e0 - /private/var/containers/Bundle/Application/924B7BB5-4532-4486-B042-990061097314/Samples.iOS.app/Samples.iOS : _ZN7plcrash2MS5async24dwarf_cfa_state_iteratorIyxE4nextEPjPNS1_28plcrash_dwarf_cfa_reg_rule_tEPy
    0x104041064 - /private/var/containers/Bundle/Application/924B7BB5-4532-4486-B042-990061097314/Samples.iOS.app/Samples.iOS : _ZN7plcrash2MS5async24dwarf_cfa_state_iteratorIyxE4nextEPjPNS1_28plcrash_dwarf_cfa_reg_rule_tEPy
    0x102e207a0 - /private/var/containers/Bundle/Application/924B7BB5-4532-4486-B042-990061097314/Samples.iOS.app/Samples.iOS : _ZN7plcrash2MS5async24dwarf_cfa_state_iteratorIyxE4nextEPjPNS1_28plcrash_dwarf_cfa_reg_rule_tEPy
    0x1036c7660 - /private/var/containers/Bundle/Application/924B7BB5-4532-4486-B042-990061097314/Samples.iOS.app/Samples.iOS : _ZN7plcrash2MS5async24dwarf_cfa_state_iteratorIyxE4nextEPjPNS1_28plcrash_dwarf_cfa_reg_rule_tEPy
    0x1073577a4 - /private/var/containers/Bundle/Application/924B7BB5-4532-4486-B042-990061097314/Samples.iOS.app/Samples.iOS : mono_pmip
    0x107413a00 - /private/var/containers/Bundle/Application/924B7BB5-4532-4486-B042-990061097314/Samples.iOS.app/Samples.iOS : mono_pmip
    0x107419c58 - /private/var/containers/Bundle/Application/924B7BB5-4532-4486-B042-990061097314/Samples.iOS.app/Samples.iOS : mono_pmip
    0x107335d38 - /private/var/containers/Bundle/Application/924B7BB5-4532-4486-B042-990061097314/Samples.iOS.app/Samples.iOS : _ZN7plcrash2MS5async24dwarf_cfa_state_iteratorIyxE4nextEPjPNS1_28plcrash_dwarf_cfa_reg_rule_tEPy
    0x10751f964 - /private/var/containers/Bundle/Application/924B7BB5-4532-4486-B042-990061097314/Samples.iOS.app/Samples.iOS : xamarin_localized_string_format_9
    0x102e206a0 - /private/var/containers/Bundle/Application/924B7BB5-4532-4486-B042-990061097314/Samples.iOS.app/Samples.iOS : _ZN7plcrash2MS5async24dwarf_cfa_state_iteratorIyxE4nextEPjPNS1_28plcrash_dwarf_cfa_reg_rule_tEPy
    0x192bd9588 - /usr/lib/system/libdyld.dylib : <redacted>

=================================================================
    Basic Fault Address Reporting
=================================================================
Memory around native instruction pointer (0x1a683adf0):0x1a683ade0  1f 04 00 f1 4b 02 00 54 08 7c 5f c8 09 81 7d 92  ....K..T.|_...}.
0x1a683adf0  2a 81 40 39 8a 02 10 36 a8 03 00 36 09 00 c4 d2  *.@9...6...6....
0x1a683ae00  0a fd 6c d3 0a 04 00 b4 0a 01 09 eb 23 01 00 54  ..l.........#..T
0x1a683ae10  0a fc 08 c8 88 00 00 34 08 7c 5f c8 28 ff 07 37  .......4.|_.(..7

=================================================================
    Managed Stacktrace:
=================================================================
      at <unknown> <0xffffffff>
      at UIKit.UIApplication:UIApplicationMain <0x00007>
      at UIKit.UIApplication:Main <0x0002f>
      at UIKit.UIApplication:Main <0x00043>
      at Samples.iOS.Application:Main <0x0007f>
      at System.Object:runtime_invoke_dynamic <0x0010f>
=================================================================
ghost commented 1 year ago

Hi @nc-kano. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

drasticactions commented 1 year ago

If you could scaffold how you've set up the WebAuthenticator in a repro project, that will help us track down the root cause and see if it's something in your setup, or with the platform. Obviously you don't need to set up the full auth flow (Committing Auth tokens is never advised, 😉) but having placeholders makes it easier to swap them out to check.

nc-kano commented 1 year ago

Hello @drasticactions

We are doing exactly the same as in https://github.com/xamarin/Essentials/issues/1242#issue-606334061

var ssoInitiationUri = new Uri("https://thirdpartyidp.com/saml2/sso/intiate"); Xamarin.Essentials.WebAuthenticator.AuthenticateAsync(ssoInitiationUri, new Uri("https://universallink.yourcompany.com"));

App crashes when it is trying to resolve https scheme. Custom schemes work fine but it is definitely not a solution for our project.

ghost commented 1 year ago

Hi @nc-kano. We have added the "s/needs-repro" label to this issue, which indicates that we require steps and sample code to reproduce the issue before we can take further action. Please try to create a minimal sample project/solution or code samples which reproduce the issue, ideally as a GitHub repo that we can clone. See more details about creating repros here: https://github.com/dotnet/maui/blob/main/.github/repro.md

This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

drasticactions commented 1 year ago

I understand that, but if you can make a full reproduction sample to show it (As, a full project) then that would help us be able fully debug this issue.

nc-kano commented 1 year ago

Updated

ghost commented 1 year ago

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

alexshikov commented 5 months ago

Hi @nc-kano. We're having the same issue and I was wondering if you've found a workaround?