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

Electron crash when switching protocols #27382

Closed
3 tasks done
nkavian opened this issue Jan 20, 2021 · 8 comments
Closed
3 tasks done

Electron crash when switching protocols #27382

nkavian opened this issue Jan 20, 2021 · 8 comments
Labels
9-x-y 10-x-y 11-x-y 12-x-y crash 💥 has-repro-repo Issue can be reproduced by cloning a git repo platform/all status/confirmed A maintainer reproduced the bug or agreed with the feature
Projects

Comments

@nkavian
Copy link

nkavian commented Jan 20, 2021

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project adheres to.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Issue Details

  • Electron Version:
    • 11.2.0
  • Operating System:
    • macOS10.14.6
  • Last Known Working Electron version:
    • N/A

Expected Behavior

I should be able to serve content from multiple protocols. i.e. using the standard file:// as well as my custom protocol foo://.

Actual Behavior

If I use win.loadFile('index.html') and stay within file://, there is no crash.
If I use win.loadURL('foo://abc/deep.htm') and stay within foo://, there is no crash.
If index.html has an href-link to foo://.... then Electron crashes.

To Reproduce

A very simple commit provided on the electron-quick-start: nkavian/electron-quick-start@7b49ad9

$ git clone git@github.com:nkavian/electron-quick-start.git
$ cd electron-quick-start
$ npm install
$ npm start
@miniak
Copy link
Contributor

miniak commented Jan 24, 2021

[27527:0124/060437.761306:FATAL:navigation_request.cc(4577)] Check failed: policy->CanAccessDataForOrigin(process_id, origin). 
0   Electron Framework                  0x000000010d629e99 base::debug::CollectStackTrace(void**, unsigned long) + 9
1   Electron Framework                  0x000000010d54a2f3 base::debug::StackTrace::StackTrace() + 19
2   Electron Framework                  0x000000010d56523f logging::LogMessage::~LogMessage() + 175
3   Electron Framework                  0x000000010d5660de logging::LogMessage::~LogMessage() + 14
4   Electron Framework                  0x000000010c799e63 content::NavigationRequest::GetOriginForURLLoaderFactory() + 1139
5   Electron Framework                  0x000000010c78e911 content::NavigationRequest::CommitNavigation() + 545
6   Electron Framework                  0x000000010c798f95 content::NavigationRequest::OnWillProcessResponseChecksComplete(content::NavigationThrottle::ThrottleCheckResult) + 581
7   Electron Framework                  0x000000010c79bc7f content::NavigationRequest::OnWillProcessResponseProcessed(content::NavigationThrottle::ThrottleCheckResult) + 719
8   Electron Framework                  0x000000010c79b128 content::NavigationRequest::OnNavigationEventProcessed(content::NavigationThrottleRunner::Event, content::NavigationThrottle::ThrottleCheckResult) + 424
9   Electron Framework                  0x000000010c7a90eb content::NavigationThrottleRunner::ProcessInternal() + 1483
10  Electron Framework                  0x000000010c7a8b10 content::NavigationThrottleRunner::ProcessNavigationEvent(content::NavigationThrottleRunner::Event) + 160
11  Electron Framework                  0x000000010c7956e3 content::NavigationRequest::WillProcessResponse() + 195
12  Electron Framework                  0x000000010c795055 content::NavigationRequest::OnResponseStarted(mojo::StructPtr<network::mojom::URLLoaderClientEndpoints>, mojo::StructPtr<network::mojom::URLResponseHead>, mojo::ScopedHandleBase<mojo::DataPipeConsumerHandle>, content::GlobalRequestID, bool, content::NavigationDownloadPolicy, net::NetworkIsolationKey, base::Optional<content::SubresourceLoaderParams>) + 9077
13  Electron Framework                  0x000000010c5de3c9 content::NavigationURLLoaderImpl::NotifyResponseStarted(mojo::StructPtr<network::mojom::URLResponseHead>, mojo::StructPtr<network::mojom::URLLoaderClientEndpoints>, mojo::ScopedHandleBase<mojo::DataPipeConsumerHandle>, content::GlobalRequestID const&, bool) + 345
14  Electron Framework                  0x000000010c5e22d8 void base::internal::FunctorTraits<void (content::NavigationURLLoaderImpl::*)(mojo::StructPtr<network::mojom::URLResponseHead>, mojo::StructPtr<network::mojom::URLLoaderClientEndpoints>, mojo::ScopedHandleBase<mojo::DataPipeConsumerHandle>, content::GlobalRequestID const&, bool), void>::Invoke<void (content::NavigationURLLoaderImpl::*)(mojo::StructPtr<network::mojom::URLResponseHead>, mojo::StructPtr<network::mojom::URLLoaderClientEndpoints>, mojo::ScopedHandleBase<mojo::DataPipeConsumerHandle>, content::GlobalRequestID const&, bool), base::WeakPtr<content::NavigationURLLoaderImpl>, mojo::StructPtr<network::mojom::URLResponseHead>, mojo::StructPtr<network::mojom::URLLoaderClientEndpoints>, mojo::ScopedHandleBase<mojo::DataPipeConsumerHandle>, content::GlobalRequestID, bool>(void (content::NavigationURLLoaderImpl::*)(mojo::StructPtr<network::mojom::URLResponseHead>, mojo::StructPtr<network::mojom::URLLoaderClientEndpoints>, mojo::ScopedHandleBase<mojo::DataPipeConsumerHandle>, content::GlobalRequestID const&, bool), base::WeakPtr<content::NavigationURLLoaderImpl>&&, mojo::StructPtr<network::mojom::URLResponseHead>&&, mojo::StructPtr<network::mojom::URLLoaderClientEndpoints>&&, mojo::ScopedHandleBase<mojo::DataPipeConsumerHandle>&&, content::GlobalRequestID&&, bool&&) + 200
15  Electron Framework                  0x000000010c5e21f8 base::internal::Invoker<base::internal::BindState<void (content::NavigationURLLoaderImpl::*)(mojo::StructPtr<network::mojom::URLResponseHead>, mojo::StructPtr<network::mojom::URLLoaderClientEndpoints>, mojo::ScopedHandleBase<mojo::DataPipeConsumerHandle>, content::GlobalRequestID const&, bool), base::WeakPtr<content::NavigationURLLoaderImpl>, mojo::StructPtr<network::mojom::URLResponseHead>, mojo::StructPtr<network::mojom::URLLoaderClientEndpoints>, mojo::ScopedHandleBase<mojo::DataPipeConsumerHandle>, content::GlobalRequestID, bool>, void ()>::RunOnce(base::internal::BindStateBase*) + 72
16  Electron Framework                  0x000000010c5e2c24 _ZN4base8internal7InvokerINS0_9BindStateIZN7content23NavigationURLLoaderImpl12ParseHeadersERK4GURLPN7network5mojom15URLResponseHeadENS_12OnceCallbackIFvvEEEE3$_0JSE_SB_EEEFvN4mojo9StructPtrINS9_13ParsedHeadersEEEEE7RunOnceEPNS0_13BindStateBaseEOSK_ + 180
17  Electron Framework                  0x000000010917d745 network::mojom::NetworkContext_ParseHeaders_ForwardToCallback::Accept(mojo::Message*) + 309
18  Electron Framework                  0x000000010d9d6b98 mojo::InterfaceEndpointClient::HandleValidatedMessage(mojo::Message*) + 1608
19  Electron Framework                  0x000000010d9da42b mojo::MessageDispatcher::Accept(mojo::Message*) + 251
20  Electron Framework                  0x000000010d9d7f21 mojo::InterfaceEndpointClient::HandleIncomingMessage(mojo::Message*) + 97
21  Electron Framework                  0x000000010d9df77e mojo::internal::MultiplexRouter::ProcessIncomingMessage(mojo::internal::MultiplexRouter::MessageWrapper*, mojo::internal::MultiplexRouter::ClientCallBehavior, base::SequencedTaskRunner*) + 1278
22  Electron Framework                  0x000000010d9ded70 mojo::internal::MultiplexRouter::Accept(mojo::Message*) + 384
23  Electron Framework                  0x000000010d9da42b mojo::MessageDispatcher::Accept(mojo::Message*) + 251
24  Electron Framework                  0x000000010d9cfbbc mojo::Connector::DispatchMessage(mojo::Message) + 444
25  Electron Framework                  0x000000010d9d0797 mojo::Connector::ReadAllAvailableMessages() + 279
26  Electron Framework                  0x000000010d9d0563 mojo::Connector::OnHandleReadyInternal(unsigned int) + 99
27  Electron Framework                  0x0000000108cdd880 mojo::SimpleWatcher::DiscardReadyState(base::RepeatingCallback<void (unsigned int)> const&, unsigned int, mojo::HandleSignalsState const&) + 80
28  Electron Framework                  0x000000010d9ff218 mojo::SimpleWatcher::OnHandleReady(int, unsigned int, mojo::HandleSignalsState const&) + 440
29  Electron Framework                  0x000000010d9ff910 base::internal::Invoker<base::internal::BindState<void (mojo::SimpleWatcher::*)(int, unsigned int, mojo::HandleSignalsState const&), base::WeakPtr<mojo::SimpleWatcher>, int, unsigned int, mojo::HandleSignalsState>, void ()>::RunOnce(base::internal::BindStateBase*) + 160
30  Electron Framework                  0x000000010d5c833b base::TaskAnnotator::RunTask(char const*, base::PendingTask*) + 395
31  Electron Framework                  0x000000010d5e607f base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::sequence_manager::LazyNow*) + 543
32  Electron Framework                  0x000000010d5e5cd0 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() + 176
33  Electron Framework                  0x000000010d640341 base::MessagePumpCFRunLoopBase::RunWork() + 65
34  Electron Framework                  0x000000010d638de2 base::mac::CallWithEHFrame(void () block_pointer) + 10
35  Electron Framework                  0x000000010d63fd4f base::MessagePumpCFRunLoopBase::RunWorkSource(void*) + 63
36  CoreFoundation                      0x00007fff38cdd884 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
37  CoreFoundation                      0x00007fff38cdd823 __CFRunLoopDoSource0 + 103
38  CoreFoundation                      0x00007fff38cdd63d __CFRunLoopDoSources0 + 209
39  CoreFoundation                      0x00007fff38cdc359 __CFRunLoopRun + 937
40  CoreFoundation                      0x00007fff38cdb953 CFRunLoopRunSpecific + 466
41  HIToolbox                           0x00007fff378f6abd RunCurrentEventLoopInMode +

@miniak
Copy link
Contributor

miniak commented Jan 24, 2021

Commenting out the CHECK fixes the crash and the app works correctly.

@miniak
Copy link
Contributor

miniak commented Jan 24, 2021

@zcbenz or @deepak1556 can you help?

@ckerr ckerr added has-repro-repo Issue can be reproduced by cloning a git repo status/confirmed A maintainer reproduced the bug or agreed with the feature crash 💥 and removed bug 🪲 labels Jan 25, 2021
@codebytere
Copy link
Member

codebytere commented Jan 29, 2021

To dig a little farther, the failure comes from here - logging the failure reason string produces: [BI=2]lock_mismatch:url

@deepak1556
Copy link
Member

Sorry missed this notification, this has to do with whether a process locked to a particular origin can navigate to another origin in the same process or different one safely. The above custom scheme is registered as a non standard scheme which means its origin is null by default.

Chromium by default doesn't allow pages loaded over file to navigate to another page that has null origin, try changing the link from foo to data:text/html, but in this case chromium throws a loud error instead of crash. So we can do the same to better rise the error rather than crash.

As from the user end, the custom scheme should be registered as standard scheme so that it obeys the process security policies and loads, add the following to main.js

protocol.registerSchemesAsPrivileged([
  { scheme: 'foo', privileges: { standard: true } }
])

@nkavian
Copy link
Author

nkavian commented Jan 29, 2021

This ticket might be an opportunity to improve the documentation and help me and others avoid misconfiguring the scheme.

When I first saw the documentation for registerSchemesAsPrivileged, I found it vague on certain points which lead me to believe that it might be optional altogether.

Looking today at the privileges, I can now appreciate I need to set some of these flags to enabled, but the documentation doesn't explain the intended behavior/consequence if a flag is on or off.

For example, if stream is enabled, does that mean all content has to be streamable and all served via registerStreamProtocol or does it mean something else? Another example, performing a text search on both links above for secure, the word appears only once in each page, and provides no details other than stating the field is a boolean.

@nornagon
Copy link
Member

nornagon commented Apr 1, 2021

Duplicate of #28407

@nornagon nornagon marked this as a duplicate of #28407 Apr 1, 2021
@nornagon nornagon closed this as completed Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
9-x-y 10-x-y 11-x-y 12-x-y crash 💥 has-repro-repo Issue can be reproduced by cloning a git repo platform/all status/confirmed A maintainer reproduced the bug or agreed with the feature
Projects
No open projects
11-x-y
Awaiting triage
Development

No branches or pull requests

6 participants