News for hackers. Stuff that matters.
Re:Apple starts rejecting apps with “hot code push” features by dilipray on Tuesday March 07, 2017 @11:44PM (#13817957)
"Hi there -- I believe that title isn't quite accurate; Apple specifically is referring to behavior of a library called Rollout which lets people dynamically inject Objective-C/Swift. They are doing hot delivery of native, Objective-C code. It's really not about React Native nor Expo.

Expo (and the React Native library we use) doesn't do any of that. We also make sure we don't expose ways to dynamically execute native code such as the dlopen() function that Apple mentioned in that message. We also haven't received any messages from Apple about Expo, nor have we heard of any Expo developers receiving the same." - Exponent Team

Re:Apple starts rejecting apps with “hot code push” features by jameside on Wednesday March 08, 2017 @12:43AM (#13818211)
Hi, I work on Expo (YC S16) and also am a core contributor to React Native.

Apple's message reads to me that they're concerned about libraries like Rollout and JSPatch, which expose uncontrolled and direct access to native APIs (including private APIs) or enable dynamic loading of native code. Rollout and JSPatch are the only two libraries I've heard to be correlated with the warning.

React Native is different from those libraries because it doesn't expose uncontrolled access to native APIs at runtime. Instead, the developer writes native modules that define some functions the app can call from JavaScript, like setting a timer or playing a sound. This is the same strategy that "hybrid" apps that use a UIWebView/WKWebView have been using for many years. From a technical perspective, React Native is basically a hybrid app except that it calls into more UI APIs.

Technically it is possible for a WebView app or a React Native app also to contain code that exposes uncontrolled access to native APIs. This could happen unintentionally; someone using React Native might also use Rollout. But this isn't something specific to or systemic about React Native nor WebViews anyway.

One nice thing about Expo, which uses React Native, is that we don't expose uncontrolled or dynamic access to native APIs and take care of this issue for you if your project is written only in JS. We do a lot of React Native work and are really involved in the community and haven't heard of anyone using Expo or React Native alone having this issue.

Re:Apple starts rejecting apps with “hot code push” features by Vinnl on Wednesday March 08, 2017 @03:27AM (#13818848)
I do wonder why, if they're _really_ fine with that, why they're not fine with browsers with different rendering engines on iOS.

Since they're not, I wouldn't have _too much_ faith in other things not being rejected.

Re:Apple starts rejecting apps with “hot code push” features by jameside on Wednesday March 08, 2017 @12:50PM (#13821963)
Apple has been fine with WebViews in apps since the beginning of the App Store, including WebViews that make calls to native code, like in the Quip app. WKWebView even has APIs for native and web code to communicate. It's OK for a WebView to call out to your native code that saves data to disk, registers for push notifications, plays a sound, and so on.

React Native is very much like a WebView except it calls out to one more native API (UIKit) for views and animations instead of using HTML.

What neither WebViews nor React Native do is expose the ability to dynamically call any native method at runtime. You write regular Objective-C methods that are statically analyzed by Xcode and Apple and it's no easier to call unauthorized, private APIs.

With Expo all of the native modules are safe to use and don't expose arbitrary access to native APIs. Apps made with Expo are set up to be good citizens in the React Native and Apple ecosystems.

Re:Apple starts rejecting apps with “hot code push” features by iOSGuy on Wednesday March 08, 2017 @01:40PM (#13822480)
Well, let's be clear here. I use React Native, and it would take me about 30m to write a bridged React Native method that could execute ObjC code dynamically, including accessing all the private APIs you could want.
Re:Apple starts rejecting apps with “hot code push” features by jameside on Wednesday March 08, 2017 @02:27PM (#13822905)
Yeah. Objective-C is definitely really flexible. From my reading of the warning, the important thing is not to execute Objective-C dynamically or access private APIs regardless of whether you're using React Native, Cordova, a WebView, or even a bare iOS app.
Re:Apple starts rejecting apps with “hot code push” features by t1amat on Wednesday March 08, 2017 @02:07PM (#13822697)
Re:Apple starts rejecting apps with “hot code push” features by jahewson on Wednesday March 08, 2017 @03:49AM (#13818941)
Simple: JIT compilers are banned and so that excludes any modern browser's JavaScript implementation from iOS. But anyone using Apple's JavaScriptCore has nothing to fear.
Re:Apple starts rejecting apps with “hot code push” features by kalleboo on Wednesday March 08, 2017 @05:01AM (#13819209)
The rules explicitly forbid any HTML renderer or JS interpreter aside from WebKit, JIT or no JIT. I believe all the popular third party browsers today still use the non-JIT UIWebView rather than WKWebView because the former gives you more control over the request cycle
Re:Apple starts rejecting apps with “hot code push” features by Operyl on Wednesday March 08, 2017 @07:32AM (#13819779)
Re:Apple starts rejecting apps with “hot code push” features by Xylakant on Wednesday March 08, 2017 @08:53AM (#13820209)
Chrome uses WKWebView on iOS, so it's basically safari with a different UI (so does firefox on iOS)
Re:Apple starts rejecting apps with “hot code push” features by Operyl on Wednesday March 08, 2017 @11:03AM (#13821116)
Yes, I know. I was saying the OP of this thread was wrong because it's not UIWebView, it's WKWebView with a JIT :).
Re:Apple starts rejecting apps with “hot code push” features by je42 on Wednesday March 08, 2017 @02:19PM (#13822814)
WKWebView has JIT. In executes the JS in a different process than the hosted app; there the JIT lives, this special process is whitelisted to do JIT magic.
Re:Apple starts rejecting apps with “hot code push” features by Operyl on Thursday March 09, 2017 @02:38PM (#13832564)
I understand that, the original OP was stating that none of the "browser skins" had JIT because they all used UIWebView, which isn't the case with the link I posted :p.
Re:Apple starts rejecting apps with “hot code push” features by dikaiosune on Wednesday March 08, 2017 @12:56PM (#13822031)
Webkit is the only acceptable browser engine on iOS. Firefox and Chrome both use webkit on iOS.
Re:Apple starts rejecting apps with “hot code push” features by chj on Wednesday March 08, 2017 @02:32AM (#13818627)
How can you ship an app with access to private APIs? There is a private API usage scanning before you can submit for review.
Re:Apple starts rejecting apps with “hot code push” features by 0x0 on Wednesday March 08, 2017 @03:01AM (#13818733)
The scanner isn't foolproof. You could fool it if you obfuscate your calls to performSelector well enough, for example

if jsonResponseFromYourBackend contains:"runThis" then performSelector:json["runThis"]

and make sure you don't send a runThis param while the app is in review.

Unfortunately for Apple's app review process, Apple's own objective-C language and runtime has very strong dynamic reflection capabilities.

Re:Apple starts rejecting apps with “hot code push” features by joosters on Wednesday March 08, 2017 @10:20AM (#13820801)
Apple could potentially close any loopholes here by scanning new apps for their API usage, checking for any 'bad' calls, and then writing the remaining discovered calls into a permissions file that is delivered with the app in the store.

At runtime, any API calls made by the app are checked against this file; if a new API call is found, then it must have escaped Apple's code scanning logic. The API call can be rejected and logged for Apple to improve their scanner.

Re:Apple starts rejecting apps with “hot code push” features by edude03 on Wednesday March 08, 2017 @11:32AM (#13821328)
This is a great idea actually. Actually, isn't google already doing this via SELinux? You give the app a manifest of calls it's allowed to make, and if the call isn't in the manifest the call gets rejected?
Re:Apple starts rejecting apps with “hot code push” features by AstralStorm on Thursday March 09, 2017 @05:38AM (#13828409)
SELinux is not that strong. It works on kernel syscall boundaries and some parameters thereof, and those aren't particularly fine grained. Service access is governed by a separate Google API, for example.

Moreover, any random app cannot enhance SELinux policy of the system.

Re:Apple starts rejecting apps with “hot code push” features by leonatan on Thursday March 09, 2017 @03:22AM (#13827913)
There are many legitimate uses of calling methods and functions using reflection. Expecting to hit all of them in a short review process is comically optimistic for anything but the simplistic of apps.

Your suggestion of enforcing this also makes no sense from performance or privacy standpoint.

Re:Apple starts rejecting apps with “hot code push” features by ThrustVectoring on Wednesday March 08, 2017 @04:24AM (#13819078)
Fair warning that I'm not familiar with Swift

Obvious (to me) idea: have the private API access stored as data sent from the server at runtime, rather than code in the reviewed app. Basically the equivalent of eval()-ing a string for front-end javascript code.

Re:Apple starts rejecting apps with “hot code push” features by santiagobasulto on Wednesday March 08, 2017 @01:10AM (#13818326)
James, do you know if they're going to go agains the Exponent app per-se?
Re:Apple starts rejecting apps with “hot code push” features by jameside on Wednesday March 08, 2017 @01:12AM (#13818332)
Oh, no, I don't have reason to believe so.
Re:Apple starts rejecting apps with “hot code push” features by weego on Wednesday March 08, 2017 @07:23AM (#13819741)
Rather than a speculating on what really boils down to semantics once ToS is involved maybe someone could actually try submitting an app and reporting back on whether it triggers the same failure?
Re:Apple starts rejecting apps with “hot code push” features by jameside on Wednesday March 08, 2017 @01:02PM (#13822109)
I haven't heard any reports of Expo developers or React Native developers (who aren't using Rollout or JSPatch) getting this warning.
Re:Apple starts rejecting apps with “hot code push” features by menckenjr on Wednesday March 08, 2017 @05:51AM (#13819418)
This needs a little elaboration. Cached Javascript in any hybrid app is a security hole because that can be exposed through a jailbreak. Depending on how much of your business logic you've pushed into the JS layer to enable that "80% code sharing" that makes managers go all tingly you may be exposing all kinds of things - cached access tokens, API keys and whatnot - to anyone who wants to install your app and mine its secrets.
Re:Apple starts rejecting apps with “hot code push” features by woah on Wednesday March 08, 2017 @07:52AM (#13819847)
Huh? Are you saying that the security hole is that a user could see stuff in the memory of their own phone?
Re:Apple starts rejecting apps with “hot code push” features by menckenjr on Wednesday March 08, 2017 @09:23AM (#13820384)
Or someone that steals your phone, or picks it up when you lose it somewhere. Yes, there's the lock screen and passcode but...

http://www.wikihow.com/Bypass-iPhone-Passcode

Re:Apple starts rejecting apps with “hot code push” features by a_t48 on Wednesday March 08, 2017 @12:06PM (#13821582)
At that point your phone is fucked, anyhow. If you've lost physical control of the device and an attacker has broken the lock, you're compromised in much bigger ways.
Re:Apple starts rejecting apps with “hot code push” features by mikewhy on Wednesday March 08, 2017 @11:27AM (#13821285)
"This bypass won't work on iPhones running iOS 9.3 and up"
Re:Apple starts rejecting apps with “hot code push” features by menckenjr on Wednesday March 08, 2017 @01:36PM (#13822435)
Re:Apple starts rejecting apps with “hot code push” features by marcinzm on Wednesday March 08, 2017 @08:27AM (#13820064)
How is this any different from native code? Afaik, you can access the native compiled source code of an app on a jailbroken phone. Sure it's more of a pain to parse through but security through obscurity isn't security.
Re:Apple starts rejecting apps with “hot code push” features by jameside on Wednesday March 08, 2017 @12:18PM (#13821678)
Definitely, running "strings" on a binary is about as easy as finding the JS for a hybrid app (WebViews or React Native). Depending on your experience it could be easier to extract API keys from an IPA than from JS.

In either case the root issue is about sending secrets like an unscoped API key to the client. "Client secret" is an oxymoron in this context regardless of the programming language.

Re:Apple starts rejecting apps with “hot code push” features by menckenjr on Wednesday March 08, 2017 @01:45PM (#13822510)
You'd have to know a few things first, like (1) the IPA is a ZIP file, (2) the ZIP file is actually of a directory and (3) you can dump the actual code in the JS files (if they're in the bundle directory) much easier than you can look for strings from the binary that might look like an API key.

The API key is actually the least of the hazards, since you can hide that in the keychain. Having source code for your business logic shipping in your app is not good; having it be hackable business logic (by changing the JS in place) is very not good.

Re:Apple starts rejecting apps with “hot code push” features by jameside on Wednesday March 08, 2017 @02:08PM (#13822703)
Shipping source code with business logic (assuming the definition of source code includes obfuscated JS) is how the entire web works today! With WASM the code that is shipped will be even further away from the original source code and really not so different from downloading ARM from the App Store or Java/ART bytecode from the Play Store.
Re:Apple starts rejecting apps with “hot code push” features by menckenjr on Wednesday March 08, 2017 @02:48PM (#13823113)
Not the entire web. eBay and Amazon don't put all their algorithms in the browser; PayPal doesn't either. They hide their company jewels behind their API where they're a little more secure. What you see in the browser is the presentation layer code.

Hybrid apps could achieve that same kind of relative business logic security, but at the cost of pushing more and more of the actual business logic behind an API and not in the JS in the app. At that point, the benefits of code sharing (such as they are) get fewer and fewer since it's really pretty easy to write API code in Objective C, Swift, Java or Kotlin.

Re:Apple starts rejecting apps with “hot code push” features by menckenjr on Wednesday March 08, 2017 @09:19AM (#13820365)
You aren't "parsing" through compiled (and linked) code; you're decompiling it, which is a much trickier thing to do and get right. Having your app logic in Javascript in the sandbox cache is just serving it up on a plate.
Re:Apple starts rejecting apps with “hot code push” features by trakout on Wednesday March 08, 2017 @09:56AM (#13820616)
I'm having trouble seeing this as a valid argument when applied to cached JavaScript within a mobile browser. The same security practices apply.
Re:Apple starts rejecting apps with “hot code push” features by menckenjr on Thursday March 09, 2017 @09:43AM (#13829555)
They do, and it's for this reason that the really important stuff isn't in the web page at all - it's behind the company's API. The "business logic" that you can safely push out to a browser or hybrid app is somewhat limited, which means there is a hard upper limit on the real code sharing savings you can get with hybrid apps versus full native.
Re:Apple starts rejecting apps with “hot code push” features by scarface74 on Wednesday March 08, 2017 @07:05AM (#13819679)
You as an end user jailbreaking your own phone is not a "security hole".

I'm not aware of any non-tethered jailbreak for iOS 10

Re:Apple starts rejecting apps with “hot code push” features by nb777 on Wednesday March 08, 2017 @07:17AM (#13819721)
I think he's talking about application wide (not user specific) "secrets" in the javascript layer.
Re:Apple starts rejecting apps with “hot code push” features by menckenjr on Wednesday March 08, 2017 @07:27AM (#13819752)
Yes, I am. As for untethered jailbreaks, http://pangu8.com/10.html mentions a few.
Re:Apple starts rejecting apps with “hot code push” features by davewritescode on Wednesday March 08, 2017 @12:29PM (#13821769)
Yes it is, jailbreaking bypasses critical security features of your phone. Granted, it's required to run certain kinds of software but there are better ways to run your own code on your phone (like getting your own developer certificate) that preserve the security model.
Re:Apple starts rejecting apps with “hot code push” features by jeswin on Wednesday March 08, 2017 @12:21AM (#13818104)
The problem with Apple that you and your customers need to be aware of (or concerned about), is that once a number of your customers sidestep Apple policies w.r.t. pushing or changing features via JavaScript, Apple will change their policies to close that loophole. It's only a matter of time before companies take advantage of this path to sidestep app store approvals.
Re:Apple starts rejecting apps with “hot code push” features by Twisell on Wednesday March 08, 2017 @01:13AM (#13818337)
As a client I'm pretty baffled that some developer had specifically bypassed something that I see as a security measure.

If an app is modified on the fly to use an undocumented and maybe "forbidden by apple" method in order to bypass security features or worse spy on me I'm clearly not ok.

Do you really think the apple ecosystem work because clients see AppStore as a evil cage and that the external developers are all angels with good intentions?

Re:Apple starts rejecting apps with “hot code push” features by K0SM0S on Wednesday March 08, 2017 @11:12AM (#13821185)
It's actually a double-edged security sword.

By not allowing developers to patch their app 'on the fly', directly, without going through a new version in the app store (which is a very lengthy process, almost forever in security terms), Apple effectively protects their iOS users from malicious code (not from the dev, which is probably to be trusted if the app is already installed, but from MITM attacks and the likes). However at the same time they deny very hasty security patches, which may compromise the device and all associated data and accounts entirely.

So there's no best world but undoubtingly many aspects to consider. Anecdotally I find that it's often better to trust the developers of an app to maintain their own thing; the OS only being a facilitator, provided the user has control (UAC on Windows, Permissions on mobile, etc.) [note: obviously you trust the OS vendor to patch said OS, it's just a particular kind of app]

edit: wording

Re:Apple starts rejecting apps with “hot code push” features by Twisell on Wednesday March 08, 2017 @01:14PM (#13822222)
I believe carefully crafted update should mostly mitigate that risk.

Also current policy don't prevent app developers to implement a "kill switch" that will prompt user to update (or wait for update) at splash screen and abort loading the malfunctioning version.

Re:Apple starts rejecting apps with “hot code push” features by dylanpyle on Wednesday March 08, 2017 @12:17AM (#13818087)
Though the security justification here is limited to private APIs & native code pushing, the first few sentences of the rejection definitely seem like the "spirit" of the terms includes any significant functionality pushing at all. Wouldn't be surprised if they ramp up enforcement on that.
Re:Apple starts rejecting apps with “hot code push” features by teknologist on Wednesday March 08, 2017 @12:22AM (#13818107)
This appears to affect apps using JSPatch which is not pushing Objective-C but JavaScript.

Source: https://github.com/bang590/JSPatch/issues/746 (in Chinese)

Re:Apple starts rejecting apps with “hot code push” features by jameside on Wednesday March 08, 2017 @02:07AM (#13818537)
The key part of JSPatch is that it exposes arbitrary, uncontrolled access to native APIs. You could use it to call private APIs even because Objective-C doesn't distinguish between public and private APIs at runtime, so Xcode's compiler checks and Apple's static analysis can't anticipate which APIs are possibly called.

In contrast, React Native doesn't expose uncontrolled access to native APIs. You write regular Objective-C methods that are callable from JavaScript, and within your Objective-C methods you write regular Objective-C that is statically checked by Xcode and Apple.

Re:Apple starts rejecting apps with “hot code push” features by teknologist on Wednesday March 08, 2017 @02:55AM (#13818717)
I'm not sure why people are concerned about React Native being targeted by this new enforcement of the rule. It is not the same thing at all.
Re:Apple starts rejecting apps with “hot code push” features by je42 on Wednesday March 08, 2017 @05:53AM (#13819430)
it shares some components. like javascriptcore.

difference is the js - native bridge. for react native it is fixed bridge, that can only change with a change in the binary.

for rollout they can execute any native code with an update of the JS.

Re:Apple starts rejecting apps with “hot code push” features by batmansmk on Wednesday March 08, 2017 @12:23PM (#13821709)
The main reason for React Native to not be impacted is that Facebook + Instagram + Airbnb + Soundcloud + ... are using it and Apple cannot justify to their userbase to not accept those favorite apps for a technical reason.
Re:Apple starts rejecting apps with “hot code push” features by matthewmacleod on Wednesday March 08, 2017 @02:20PM (#13822826)
No, it's not. It's because React Native is a totally different technical solution.
Re:Apple starts rejecting apps with “hot code push” features by prabodhprakash on Wednesday March 08, 2017 @05:44AM (#13819389)
"You write regular Objective-C methods that are callable from JavaScript," - the objC function that I am calling from JS can be capable of calling a private API received by it in an argument - that breaks the entire claim of reactNative not supporting calls to private API. React Native must also go down.
Re:Apple starts rejecting apps with “hot code push” features by jameside on Wednesday March 08, 2017 @12:25PM (#13821720)
If you deliberately write code that calls private APIs that are exposed to JS in your React Native app, I expect only your specific app to receive this warning. The same would be true in an app that doesn't use React Native at all, as we've seen with apps using Rollout.

The warning is not about React Native, it's about exposing uncontrolled access to native APIs including private ones and React Native doesn't do that.

Re:Apple starts rejecting apps with “hot code push” features by wruza on Wednesday March 08, 2017 @07:21AM (#13819736)
See the difference between a regular human who in theory can take a knife and violently rob or kill someone, and human-like robot that can be easily programmed to do the same. Who has to be isolated?

It is all about intents. If app allows that, it is banned for that behavior, not for having React in his kitchen. But if you have armed drone there, then police has a question.