You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2021/09/13 03:01:33 UTC

[GitHub] [cordova-ios] breautek commented on issue #1063: Can't Read Scrom File In IOS

breautek commented on issue #1063:
URL: https://github.com/apache/cordova-ios/issues/1063#issuecomment-917796504


   I didn't know how to respond to your last remark but I finally got around the time of researching.
   
   It appears WebKit terminology of "Sandbox" does not mean the same thing as the iOS sandbox.
   
   First we can see where WebKit prints out the sandbox error in question [here](https://github.com/WebKit/WebKit/blob/592c83ba59dca6723df558e0938b8d9d6f7ab915/Source/WebKit/UIProcess/WebPageProxy.cpp#L5339), and it does so when `checkURLReceivedFromCurrentOrPreviousWebProcess` returns false.
   
   That [method](https://github.com/WebKit/WebKit/blob/592c83ba59dca6723df558e0938b8d9d6f7ab915/Source/WebKit/UIProcess/WebPageProxy.cpp#L10372) does a few different checks, but I believe the main reason why it doesn't work is because I believe `m_mayHaveUniversalFileReadSandboxExtension` is false.
   
   We know it doesn't enter any of the conditions and eventually reaches to [process.checkURLReceivedFromWebProcess(url);](https://github.com/WebKit/WebKit/blob/592c83ba59dca6723df558e0938b8d9d6f7ab915/Source/WebKit/UIProcess/WebPageProxy.cpp#L10384) because of your error message prints a couple lines before. This brings us to the [WebProcessProxy](https://github.com/WebKit/WebKit/blob/592c83ba59dca6723df558e0938b8d9d6f7ab915/Source/WebKit/UIProcess/WebProcessProxy.cpp#L747) class. Again, it does some further checks, but the interested one is the `m_mayHaveUniversalFileReadSandboxExtension` variable is falsy because we do see `"Received an unexpected URL from the web process"` being printed.
   
   So looking to see if/when that variable becomes truthy, that seems to be handled in [WebPageProxy::maybeInitializeSandboxExtensionHandle](https://github.com/WebKit/WebKit/blob/592c83ba59dca6723df558e0938b8d9d6f7ab915/Source/WebKit/UIProcess/WebPageProxy.cpp#L1249)
   
   In `maybeInitializeSandboxExtensionHandle`, we also see a lot of references of `resourceDirectoryURL`.
   
   From the [Appe Docs](https://developer.apple.com/documentation/foundation/nsbundle/1413058-pathsforresourcesoftype?language=objc)
   
   So I believe this is what instructs WKWebView that it is okay to load in content from the app bundle container, so I think the first half of `maybeInitializeSandboxExtensionHandle`.
   
   The second half of that method [here](https://github.com/WebKit/WebKit/blob/592c83ba59dca6723df558e0938b8d9d6f7ab915/Source/WebKit/UIProcess/WebPageProxy.cpp#L1305-L1314) is what needs to run successfully for WKWebVIew to grant access to loading content outside of the app bundle container. `willAcquireUniversalFileReadSandboxExtension` method is what sets `m_mayHaveUniversalFileReadSandboxExtension` to true.
   
   > In macOS, the top-level nonlocalized resource directory is typically called Resources but in iOS, it is the main bundle directory.
   
   I'm not an expert on the WebKit base at all, but based on the information available, I believe `if (auto handle = SandboxExtension::createHandle("/", SandboxExtension::Type::ReadOnly)) {` is returning a nullish/falsey value and the code is not entering the if condition, restricting access to outside of the app bundle.
   
   I don't know if there is a path to make it work, but I think this makes it clear that when WebKit talks about the sandbox, it isn't the same as the iOS sandbox architecture. It's talking about a broad sandbox (as this code is not strictly for iOS, it's used for mac as well).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org