Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6BCF217FE0 for ; Mon, 3 Nov 2014 15:48:34 +0000 (UTC) Received: (qmail 44807 invoked by uid 500); 3 Nov 2014 15:48:34 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 44783 invoked by uid 500); 3 Nov 2014 15:48:33 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 44756 invoked by uid 99); 3 Nov 2014 15:48:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Nov 2014 15:48:33 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of mmocny@google.com designates 209.85.213.169 as permitted sender) Received: from [209.85.213.169] (HELO mail-ig0-f169.google.com) (209.85.213.169) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Nov 2014 15:48:06 +0000 Received: by mail-ig0-f169.google.com with SMTP id hn18so4725268igb.4 for ; Mon, 03 Nov 2014 07:47:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=wr/nNTPo+/CzxV+8kv7SNx7yFzJvVIyethnKwmF6PJc=; b=fOMUkelEEYQyW152Ru+x+/eXzugPJAr6Ms/rmsx4lmuGliGMJmveZGSyYCv52wspH2 IgblikvhWt04o7FSrOsOVUyrvsKDaS0UOVoTjTVvXriG47Tm5sHoWNBjI95J5HiALyW8 nU4qYnCHjSAQU4TEo8EZvzOrX/Ca3welSJgqaVEePTbb3mnSwHs1WRY6NQZR5Qu8mXW6 YElN2Y3zXlx8gL/5TteqOeL5HphJbCq+rCND3RXmqSvMrUba5nA+/t/o8x3PGYrun2sO u1Z4hcyyCByrV9QMNnun+0mB+qZs/YuafWY905t0KN/RuqXnK46d/hbqv9qCt8OSWx3V 8jYA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:content-type; bh=wr/nNTPo+/CzxV+8kv7SNx7yFzJvVIyethnKwmF6PJc=; b=KUfm6WOkdKE4xzYEg6p8ZVv/JIqBg+7Aut+bRVtsRUW/evGZ3mSaE1kqMNTU+VzxAS JuQK9W9xjvw15Nn68nRZPzSnxUAPvVHFWaeqmD0QTGa7ebaA9cZH0624QpaQSycDUz0B 9GnDA/utFdVeIC2Uv8ywVE3yrArkyvRjw5HNs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:content-type; bh=wr/nNTPo+/CzxV+8kv7SNx7yFzJvVIyethnKwmF6PJc=; b=Q3qN9vsKOZ9+669XAa0U/2guHRBJjQ7vN8DQsj3QEfBp1fohU/OJgzuIDZ2tRhPYMZ 6/NyHbEoO1bz3cEob9g731uwJv/jz0+XMvgaksMWTYSUgMZo7AYY4tN7KFJTjM01CUQ7 DxJvf79Wgwl3OYVlJw1oG9744lOaKrIPeQ7llft+VHK0P4xkozoDMiGH9hCtFkvVItEJ yXXK9KiUntsMXDzv7DQWAYl9CBJDaG5bac2yx8ZUTvJRakyosikHmKyGQVwD6tji8TCy ELbMByd39cAHPHxrvWRkpO0GCgHnnuTyyVuJHt6TPXb4NKpCO02zn0nCsPlcgOn5lmQk +uRg== X-Gm-Message-State: ALoCoQmhXqkFvZsTliYG1quRwmd3FbiZ2aXHgqnnrDfkSUm0VlKrhc5Y/ibJdsVNiZ7umIhdazxx X-Received: by 10.107.13.137 with SMTP id 131mr48773070ion.2.1415029640020; Mon, 03 Nov 2014 07:47:20 -0800 (PST) MIME-Version: 1.0 Sender: mmocny@google.com Received: by 10.64.59.168 with HTTP; Mon, 3 Nov 2014 07:46:59 -0800 (PST) In-Reply-To: References: From: Michal Mocny Date: Mon, 3 Nov 2014 10:46:59 -0500 X-Google-Sender-Auth: V5ULOgUCNlIQWwwhhGUDd9ngyh8 Message-ID: Subject: Re: [iOS 8] WKWebView moving forward To: dev Content-Type: multipart/alternative; boundary=001a113fdfd40a60820506f6438d X-Virus-Checked: Checked by ClamAV on apache.org --001a113fdfd40a60820506f6438d Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Awesome analysis Tony, thanks for the efforts & the great summary. On Mon, Nov 3, 2014 at 10:27 AM, Homer, Tony wrote: > I spent a lot of time thinking about ways to avoid replay attacks for the > local web server plugin this weekend. > > Specifically, I felt like there should be a way to take advantage of the > fact that the client and the server are running in the same process. > I thought this might enable some kind of sideband (non-http) > authentication possibility. > The 2 possibilities I was most interested in, but eventually concluded ar= e > not practical were: > 1. unique token per http request - not practical because there is no per > http request event available > 2. a whitelist of =E2=80=9Cremote=E2=80=9D ports - not practical because = there is no > simple way to get a list of ports in use by WKWebView > > After going down this rathole and coming up empty, I reconsidered the > original problem and came to the following conclusions. > 1. restricting requests to localhost-only limits =E2=80=9Cattacks=E2=80= =9D to backgrounded > apps > 2. including a token in the requests will prevent backgrounded apps from > being able to successfully make unwanted requests > 3. the token is vulnerable to network analysis, but that cannot be done o= n > device > > Therefore, vulnerability is limited to the case where the there is > (1) a =E2=80=9Chostile" app installed on device and running in the backgr= ound and > (2) the user=E2=80=99s device is connected to a wi-fi network where an at= tacker is > able to perform network analysis to capture the token. > In this case, the attacker could just inspect the HTTP traffic instead of > capturing the token and sending it to their backgrounded app. > In other words, it seems that replay attacks are possible but not useful. > If we care about the =E2=80=9Chostile wifi network=E2=80=9D case, we need= something like > SSL. > > On 11/1/14, 4:28 PM, "Homer, Tony" wrote: > > >I started looking at how to make the camera plugin be able to work in > >WKWebView. > >Before, I had mentioned intercepting resource requests as a way to fix t= he > >file:// requests. > >However, WKWebView does not offer a way to intercept resource requests s= o > >that won=E2=80=99t work. > >:/ > > > >Andrew had suggested introducing some proxy paths as a way to deal with > >the path problems, which seems fine. > >On the other hand, the request handlers could just inspect the path in t= he > >request and do the right thing - are the proxy paths needed? > >I think implicit in those comments was a suggestion that the affected > >plugins such as camera could return URLs using those paths. > >The thing about changing camera and file plugins to support localhost th= at > >bothers me, is that now those core plugins effectively support a non-cor= e > >plugin. > >Also, other (on-cordova) plugins that depend on file protocol will be > >incompatible with the local web server wkwebview solution (unless they > >make changes to support it). > > > >I wonder if it would be better to handle this in CDVPluginResult? > >A hook could be added to initWithStatus and exposed to plugins. > >Then the SALocalWebServer plugin can use the hook to inspect the message > >and fix it, if it is a file:// URL. > >So, for example, when camera calls CDVPluginResult > >resultWithStatus:messageAsString and passes in a file URL, SALocalServer > >can get a chance to inspect and modify the result =E2=80=93 changing it = to an > >http:localhost URL. It could simply replace the file protocol with > >http://localhost:port, then the handler could decode the path before > >building the response. > >This is ugly, but it would prevent the need to change the camera and fil= e > >and should allow other non-cordova plugins that depend on file:// URLs t= o > >work. > > > > > >Tony > > > >On 10/31/14, 2:03 PM, "Homer, Tony" wrote: > > > >>I started with cookies in my POC, but I was concerned about replay > >>attacks. > >>I couldn=E2=80=99t think of a way to avoid replay vulnerability with co= okies > >>(without SSL), so I was going to switch to the side channel approach I > >>tried to describe. Do you think replay vulnerability is irrelevant? I= =E2=80=99m > >>not a security guy, so I wasn=E2=80=99t sure if it mattered or not. Tha= t=E2=80=99s > >>actually one of the things I was hoping to get feedback about. > >> > >>I guess I don=E2=80=99t follow how CORS relates to the camera plugin, d= oes it use > >>XHR? Maybe you can elaborate? > >>I expect I=E2=80=99ll see it when I try the camera plugin from WKWebVie= w, just > >>didn=E2=80=99t get around to it yet. > >>The only thing that jumps out at me is that you get a file:// url back = - > >>we could change that. > >>Or maybe intercept file:// requests in the plugin? If it=E2=80=99s jus= t a path > >>problem, maybe we could intercept the request, fix the path, then respo= nd > >>with the right thing... > >> > >>Tony > >> > >>On 10/31/14, 1:19 PM, "Andrew Grieve" wrote: > >> > >>>Unless you're having the server proxy requests to remote sites, I don'= t > >>>think CORS headers are necessary. > >>> > >>>Tony - awesome stuff! absolutely doing it right. More technical-focuse= d > >>>discussion the better :). Using cookies seems the best way to me since > >>>that > >>>covers all requests. Adding headers works only for XHRs. > >>> > >>>On Fri, Oct 31, 2014 at 12:12 PM, Kirk Shoop (MS OPEN TECH) < > >>>Kirk.Shoop@microsoft.com> wrote: > >>> > >>>> Yes, the handler should be able to add CORS headers to its responses > >>>>that > >>>> will enable requests from any origin. > >>>> > >>>> For instance adding 'Access-Control-Allow-Origin: *' would allow any > >>>> origin to make a request from the local server. > >>>> > http://www.w3.org/TR/cors/#access-control-allow-origin-response-header > >>>> > >>>> Similarly Access-Control-Allow-Methods and > >>>>Access-Control-Allow-Headers > >>>> could be used to define valid requests. > >>>> > >>>> Kirk > >>>> > >>>> Developer > >>>> Microsoft Open Technologies, Inc. > >>>> > >>>> -----Original Message----- > >>>> From: Homer, Tony [mailto:tony.homer@intel.com] > >>>> Sent: Friday, October 31, 2014 8:40 AM > >>>> To: dev@cordova.apache.org > >>>> Subject: Re: [iOS 8] WKWebView moving forward > >>>> > >>>> Last night I added a handler to the Local Web Server plugin that > >>>>returns > >>>> 403 for non-localhost requests. > >>>> The handler also has a prototype token system to restrict requests t= o > >>>>the > >>>> app, but I need to change the approach a bit. > >>>> Currently I set a cookie and the handler just checks for the cookie > >>>>and > >>>> returns 403 if it is missing. > >>>> This is susceptible to replay attacks from backgrounded apps - not > >>>>sure > >>>>if > >>>> that is important or not. > >>>> > >>>> I=C2=B9m going to investigate adding a map to the plugin, then add a= n entry > >>>>for > >>>> every request. > >>>> The entry will be a hash of the request and a random number. > >>>> > >>>> I=C2=B9ll have to wire up support for overriding url loads so that I= can > >>>>add > >>>> the header with the random number to the request. > >>>> Then the request handler will look the entry up in the map and remov= e > >>>>it - > >>>> this should eliminate re-playability. > >>>> > >>>> I=C2=B9m not sure about the CORS issue with camera plugin=C5=A0 I=C2= =B9ll be curious > >>>>to > >>>> test it - maybe it could be addressed by modifying the response in t= he > >>>> GCDWebServer handler? > >>>> > >>>> Tony > >>>> > >>>> P.S. This is my first attempt participating in discussion on the lis= t > >>>>- > >>>> let me know if I=C2=B9m doing it wrong! > >>>> Am I wasting my time investigating this? Should I just leave it > >>>>Shazron? > >>>> > >>>> On 10/30/14, 9:52 PM, "Andrew Grieve" wrote: > >>>> > >>>> >On Thu, Oct 30, 2014 at 5:05 PM, Shazron wrote: > >>>> > > >>>> >> The port conflict situation has been solved with the latest versi= on > >>>> >>of the plugin. Passing in a port of "0" will choose a random port= . > >>>> >>More details in the plugin's README.md > >>>> >> > >>>> >Awesome! Why even allow a non-random port? > >>>> >Also learned today that in chrome, webcrypto API is disabled for ht= tp > >>>> >origins, but enabled for https. Not sure if this is true for Safari > >>>>as > >>>> >well, but certainly this change will be a can of worms! > >>>> > > >>>> > > >>>> >> > >>>> >> Ouch - didn't think about Camera plugin and File plugin impact. > >>>>That > >>>> >>proxy thing might work, as long as there are no folder name > >>>> >>collisions. > >>>> >> > >>>> >Prefixing all resources into a fake top-level directory will > >>>>eliminate > >>>> >the folder name collision problem I think. > >>>> > > >>>> > > >>>> >> > >>>> >> My point regarding mixing WKWebView and UIWebView on iOS 8 is, if > >>>>you > >>>> >>have a user on iOS 8.x, you want all users on that iOS version to > >>>> >>have the same experience, and for bug reporting purposes. > >>>> > > >>>> > > >>>> >> On Wed, Oct 29, 2014 at 5:11 PM, Andrew Grieve > >>>> > >>>> >> wrote: > >>>> >> > >>>> >> > We could restrict access to the webserver by stuffing a cookie > >>>>into > >>>> >>the > >>>> >> > webview with an access token, then have the server just 500 on > >>>>any > >>>> >> request > >>>> >> > missing the cookie. We should also be able to restrict external > >>>> >>requests > >>>> >> > just by listening on 127.0.0.1 instead of 0.0.0.0 (doesn't look > >>>> >> > like GCDWebServer supports this, but we can hack it in). > >>>> >> > > >>>> >> > The problem of port conflicts is annoying though. Maybe we try > >>>>random > >>>> >> ports > >>>> >> > until one works? Is there any need to use the same port for > >>>>multiple > >>>> >> runs? > >>>> >> > > >>>> >> > The CORS thing is sad, because it also means things like Camera > >>>>plugin > >>>> >> will > >>>> >> > be broken (can't use resulting URL in ). > >>>> >> > > >>>> >> > Although we might just do (this is different than the current > >>>>mapping > >>>> >>in > >>>> >> > the plugin): > >>>> >> > http://localhost:RANDOM_PORT/www > >>>> >> > http://localhost:RANDOM_PORT/asset-library > >>>> >> > http://localhost:RANDOM_PORT/file-system > >>>> >> > > >>>> >> > to proxy the three locations. > >>>> >> > > >>>> >> > This also means we can't use FileEntry.toURL() and have it work= , > >>>> >>unless > >>>> >> > toURL returns http://localhost:RANDOM_PORT/file-system/... > >>>>Maybe > >>>> >> that's > >>>> >> > fine? > >>>> >> > > >>>> >> > > >>>> >> > I don't think it's weird that an app will need to support > >>>>WKWebView on > >>>> >> some > >>>> >> > OS versions, and UIWebView on others. That's already the case t= o > >>>> >>support > >>>> >> > iOS 7. > >>>> >> > > >>>> >> > > >>>> >> > > >>>> >> > On Wed, Oct 29, 2014 at 6:22 PM, Shazron > >>>>wrote: > >>>> >> > > >>>> >> > > This does not preclude using the file url API function I > >>>>suppose. > >>>> >> Here's > >>>> >> > a > >>>> >> > > flowchart on how I think it would work: > >>>> >>http://i.imgur.com/zq4zreN.png > >>>> >> > > > >>>> >> > > > >>>> >> > > On Wed, Oct 29, 2014 at 2:48 PM, Tommy Williams > >>>> >>>> > > >>>> >> > > wrote: > >>>> >> > > > >>>> >> > > > This whole thing reeks of sadness and pain. > >>>> >> > > > > >>>> >> > > > The security implications of this will have to be considere= d > >>>>very > >>>> >> > > > carefully. > >>>> >> > > > On 29 Oct 2014 16:40, "Shazron" wrote: > >>>> >> > > > > >>>> >> > > > > ## What We Know So Far > >>>> >> > > > > > >>>> >> > > > > 1. Because of the file:// url loading bug, we couldn't > >>>>support > >>>> >>the > >>>> >> > > > > WKWebView in the iOS 8 GM release. It has since been fixe= d, > >>>>for > >>>> >> > release > >>>> >> > > > > post iOS 8.1 (not sure when), through a new WKWebView API > >>>> >>function > >>>> >> ( > >>>> >> > > > > http://trac.webkit.org/changeset/174029/trunk) > >>>> >> > > > > 2. The alternative is embedding a local web server and > >>>>serving > >>>> >> assets > >>>> >> > > > from > >>>> >> > > > > that > >>>> >> > > > > > >>>> >> > > > > ## Abandon file:// url Loading API Method > >>>> >> > > > > > >>>> >> > > > > My proposal is, we abandon the local file:// url loading > >>>>method > >>>> >>in > >>>> >> > (1) > >>>> >> > > > > above, since it will create problems with support. > >>>> >> > > > > > >>>> >> > > > > For example, if we support the new local file url loading > >>>>API > >>>> >> > function > >>>> >> > > in > >>>> >> > > > > iOS 8.2.0 (speculated) -- and a user is on 8.0.2, what > >>>>then? > >>>>You > >>>> >> > would > >>>> >> > > > not > >>>> >> > > > > have WKWebView support for that user, and you would use > >>>> >>UIWebView > >>>> >> > > > instead. > >>>> >> > > > > This will just be confusing, and leads to problems. > >>>> >> > > > > > >>>> >> > > > > With the embedded local web server method, you can suppor= t > >>>> >>**any** > >>>> >> > > > version > >>>> >> > > > > of iOS 8.x. > >>>> >> > > > > > >>>> >> > > > > ## Embrace Embedded Local Web Server Method > >>>> >> > > > > > >>>> >> > > > > I have a Cordova plugin that implements this, and it shou= ld > >>>>work > >>>> >> with > >>>> >> > > > > cordova-ios 3.7.0: > >>>> >> > > > > https://github.com/shazron/CordovaLocalWebServer > >>>> >> > > > > > >>>> >> > > > > It dynamically updates the tag value when it > >>>>loads, > >>>> >> > overriding > >>>> >> > > > it > >>>> >> > > > > to the actual location and port. Since it is a plugin, it > >>>>can be > >>>> >> > > > swappable > >>>> >> > > > > (for whatever reason). > >>>> >> > > > > > >>>> >> > > > > It does not solve the problem where any backgrounded app > >>>>can > >>>> >>access > >>>> >> > our > >>>> >> > > > > local web server. > >>>> >> > > > > > >>>> >> > > > > ## Future Steps > >>>> >> > > > > > >>>> >> > > > > This plugin is already working in cordova-ios 3.7.0 > >>>> >>(un-released, > >>>> >> up > >>>> >> > > next > >>>> >> > > > > for vote release). > >>>> >> > > > > > >>>> >> > > > > The wkwebview branch: > >>>> >> > > > > > >>>> >> > > > > 1. Needs be rebased > >>>> >> > > > > 2. Needs to be re-tested > >>>> >> > > > > 3. issues in CB-7043 that relate to the wkwebview have to > >>>>be > >>>> >> resolved > >>>> >> > > > > 4. branch presented for review to other committers > >>>> >> > > > > 5. resolve any comments and issues from (4) > >>>> >> > > > > 6. wkwebview branch integrated into master > >>>> >> > > > > > >>>> >> > > > > I will work on these items next after getting cordova-ios > >>>>3.7.0 > >>>> >> out. > >>>> >> > > Any > >>>> >> > > > > help is welcome. > >>>> >> > > > > > >>>> >> > > > > ## Migration Issues > >>>> >> > > > > > >>>> >> > > > > If you are migrating to WKWebView from UIWebView, you wil= l > >>>>lose > >>>> >> some > >>>> >> > > > > functionality. > >>>> >> > > > > > >>>> >> > > > > 1. No more whitelist feature (NSURLProtocol is not > >>>>supported > >>>>in > >>>> >> > > > WKWebView) > >>>> >> > > > > 2. Your XmlHttpRequest calls now need to be CORS complian= t > >>>> >>(this is > >>>> >> > > still > >>>> >> > > > > true if loaded through a file:// url) > >>>> >> > > > > 3. HTML5 offline application cache is not available in > >>>> >>WKWebView ( > >>>> >> > > > > https://devforums.apple.com/message/1060452) > >>>> >> > > > > > >>>> >> > > > > >>>> >> > > > >>>> >> > > >>>> >> > >>>> > >>>> > >>>> --------------------------------------------------------------------= - > >>>> To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org > >>>> For additional commands, e-mail: dev-help@cordova.apache.org > >>>> > >>>> > >>>> --------------------------------------------------------------------= - > >>>> To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org > >>>> For additional commands, e-mail: dev-help@cordova.apache.org > >>>> > >>>> > >> > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org > For additional commands, e-mail: dev-help@cordova.apache.org > --001a113fdfd40a60820506f6438d--