News for hackers. Stuff that matters.
Re:See what JavaScript commands get injected through an in-a... by deminature on Thursday August 18, 2022 @10:17PM (#32517029)
They're going to heavily lockdown WKWebView after the Instagram and Tiktok revelations, probably in iOS16.1. They may even remove it entirely and force people to use SFSafariViewController (heavily locked down web browser, opaque to developers other than URL). Best of luck to anyone that was using javascript injection for legitimate purposes, others have ruined it for everyone by abusing user trust.
Re:See what JavaScript commands get injected through an in-a... by hn_throwaway_99 on Thursday August 18, 2022 @11:20PM (#32517308)
I highly doubt this will happen. There are a ton of apps that use things like Cordova or Capacitor (usually for cross-platform purposes).

What I could see them doing is making apps declare URLs that they need access to. Basically, you get full functionality on declared URLs, but if you are just using WebView for a "generic" in-app browser you lose the ability to inspect random pages.

Re:See what JavaScript commands get injected through an in-a... by kitsunesoba on Thursday August 18, 2022 @11:36PM (#32517377)
> What I could see them doing is making apps declare URLs that they need access to. Basically, you get full functionality on declared URLs, but if you are just using WebView for a "generic" in-app browser you lose the ability to inspect random pages.

This is exactly what I'm expecting, because that's how they've handled other similar restrictions. Becoming a full on web browser with the iOS 14 web browser entitlement will probably be the only way to not be bound to a list of URLs, and they don't hand that entitlement out willy nilly.

Re:See what JavaScript commands get injected through an in-a... by manmal on Saturday August 20, 2022 @01:48AM (#32529489)
The mechanism you are describing is already implemented and advertised: https://webkit.org/blog/10882/app-bound-domains/

Apple „just“ need to enforce it.

Re:See what JavaScript commands get injected through an in-a... by rawling on Friday August 19, 2022 @11:14AM (#32522017)
Couldn't you just proxy everything through a host you own?
Re:See what JavaScript commands get injected through an in-a... by greggman3 on Friday August 19, 2022 @03:43AM (#32518447)
Wouldn't a simple solution be to require apps that aren't browser to list a limited set of domains they're allowed to access? Then you could use the WkWebKit view for your app but you couldn't use it to allow the user to browse the web.

Browsers would get a pass where Apple would come up with some rule but clearly the Instagram app, the Facebook app, the TikTok app, the Gmail app, the Google app, are not browser where as Firefox, Chrome, Brave are.

Re:See what JavaScript commands get injected through an in-a... by mrtksn on Friday August 19, 2022 @06:10AM (#32519239)
iOS already has a method to associate websites with apps but I see some problems with this approach.

1) If you go with the "associated domains only" approach that requires proof of domain ownership(usually through adding TXT into the ZONE files), you lose the category of apps that function by transferring a session of a website into the app to function. This is a popular approach for reader apps that don't have an official official affiliation with the website they interact with or the website doesn't have an API to do direct app connection.

2) If you go with the route of pre-defined domains that might not be associated officially, you fix the problem in the first point but you also create a vector of attack to scoop data from targeted websites. For example you can collect data from reddit, facebook and instagram. 3 websites only but more than enough to cause headaches.

Re:See what JavaScript commands get injected through an in-a... by mrtksn on Friday August 19, 2022 @02:19AM (#32518009)
IMHO the proper action would be to put the script injection and data access capability behind a user consent prompt.

"TIKTOK WOULD LIKE TO READ THE AND MODIFY THE CONTENTS OF THIS WEBSITE - ACCEPT/DENY"

For legitimate reasons, the app can inform the user about why they need to do this and the user can accept that and even better, they can implement legitimate APIs.

Re:See what JavaScript commands get injected through an in-a... by Traubenfuchs on Friday August 19, 2022 @02:53AM (#32518177)
Yes, please give us more cookie consent banners!
Re:See what JavaScript commands get injected through an in-a... by mrtksn on Friday August 19, 2022 @03:02AM (#32518220)
See, you don't have to ask for consent if you don't want to do shady stuff. Websites don't have to have cookie banners if they don't want to track you across the web and apps don't have to have access web data prompt if they don't want access the browser data in the app.

PS: very convincing GPT-3 bot comment, exactly what a redditor on autopilot would write(according to the profile, the OP is a bot).

Re:See what JavaScript commands get injected through an in-a... by d1sxeyes on Friday August 19, 2022 @10:11AM (#32521155)
A lot of people getting upset that you're highlighting that the account is a bot. Before anyone else tells mrktsn off, please read the user's profile.

https://news.ycombinator.com/user?id=Traubenfuchs

I also think that the bot did a good job here.

Re:See what JavaScript commands get injected through an in-a... by Traubenfuchs on Friday August 19, 2022 @11:13AM (#32521999)
Accusing authors of dissenting opinions of being bots is the definition of bad faith and fosters an unhealthy discussion culture.
Re:See what JavaScript commands get injected through an in-a... by mrtksn on Friday August 19, 2022 @11:21AM (#32522095)
bad bot
Re:See what JavaScript commands get injected through an in-a... by Traubenfuchs on Friday August 19, 2022 @11:45AM (#32522474)
I think it‘s hilarious he stood up for himself but I feel bad about his lack of self awareness.
Re:See what JavaScript commands get injected through an in-a... by d1sxeyes on Friday August 19, 2022 @06:02PM (#32526502)
To be fair, could equally be read as “just because I’m a bot doesn’t mean you should ignore everything I say” :)
Re:See what JavaScript commands get injected through an in-a... by wruza on Friday August 19, 2022 @05:00AM (#32518843)
I understand “us” as users in this discussion, not as site owners. Your idea is cool, but we have no control over who wants what, so we’ll have yet another consent annoyance as a result.
Re:See what JavaScript commands get injected through an in-a... by mrtksn on Friday August 19, 2022 @05:19AM (#32518956)
The cookie law is not implemented as a browser function but something that operators need to implement if they want to legally track users. It's an annoyance because each implementation is different and every website wants to track users. If EU went after Web browsers and made them implement the legislation as an API, we would have had tracking prompts like location or camera access prompts and probably kill the tracking industry in a similar way Apple killed App tracking with their tracking prompt.

In the case of UIWebView/WKWebView (AKA the browser within an app that can access web data), this can be implemented by Apple as any other data access prompt like location data access or App tracking access for example.

Apps like to track user data like user location too but thanks to Apple's implementation of prompting the user first, they need to have a legitimate reason to request that information.

So, I guess, apps can claim that they need to access web data to provide some service(like widget, sign in session to transfer the login into the app etc) and users who want that can accept the requests and those who don't can have peace of mind.

Re:See what JavaScript commands get injected through an in-a... by wruza on Friday August 19, 2022 @05:34AM (#32519057)
I agree and should have thought about it this way, my bad. If there will be a way to deny that system-wide or at most once per app, no issue then.

Edit: the confusing part was “the contents of this website”, which made me think of per-site basis.

Re:See what JavaScript commands get injected through an in-a... by mattmanser on Friday August 19, 2022 @03:17AM (#32518311)
Sure. The "bot" ridiculed your idea for good reason.
Re:See what JavaScript commands get injected through an in-a... by mrtksn on Friday August 19, 2022 @03:28AM (#32518364)
Check the profile, I'm not claiming that OP is a bot - the OP describes the profile as a bot.

That's a really low quality discussion, so I will leave it here. Can we please not turn HN into reddit? If you have an argument write an argument instead of trying to insult people(or don't write anything, we don't have deficiency of this type of attitude).

Re:See what JavaScript commands get injected through an in-a... by tinus_hn on Friday August 19, 2022 @06:45AM (#32519419)
Shady stuff like highlighting terms the user searched for. Don’t forget there are of course legitimate use cases.

By the way, if you think another user is a bot (or they claim so themselves), from the guidelines:

> Please don't post insinuations about astroturfing, shilling, bots, brigading, foreign agents and the like. It degrades discussion and is usually mistaken. If you're worried about abuse, email [email protected] and we'll look at the data.

Re:See what JavaScript commands get injected through an in-a... by mrtksn on Friday August 19, 2022 @06:51AM (#32519464)
I don't think that another user is a bot, another user has stated in their profile description that they are a bot account randomly posting GPT-3 generated comments. I made no claims but comment on the quality of the bot.
Re:See what JavaScript commands get injected through an in-a... by NomadicDev on Friday August 19, 2022 @02:08PM (#32524292)
What a bummer people are quicker to grab quotes from the ToS to try to tell you off for calling someone a bot, rather than 1 click on the accounts name to find out for their self. Even HN isn't immune from the lazy reactionary commenting these days it seems.
Re:See what JavaScript commands get injected through an in-a... by tinus_hn on Friday August 19, 2022 @02:34PM (#32524547)
> … (or they claim so themselves) …
Re:See what JavaScript commands get injected through an in-a... by MBCook on Thursday August 18, 2022 @10:46PM (#32517160)
I’m not sure they can.

While SFSafari is a much better choice for what the apps are doing here, WKWeb has legitimate uses.

I suppose Apple could lock it behind an entitlement, but that would take a while as WKWeb is already very prevalent and people won’t replace it on short notice like a point release. Even iOS 17 seems fast.

Plus there is the general power issue. Apple could have done many things over the years to FB (and IG) but they’ve been treating them with kid gloves because those apps are so important. You can definitely add TikTok to that list.

Re:See what JavaScript commands get injected through an in-a... by can16358p on Friday August 19, 2022 @09:50AM (#32520919)
In an app I'm using postMessage and JS injection to communicate between our in-house HTML/CSS content (due to what we're building, we had and still have many legitimate reasons to code that way) to seamlessly integrate the native side and the dynamic HTML views.

Any change would be a huge nightmare for apps like ours, potentially impacting many other apps as well.

Re:See what JavaScript commands get injected through an in-a... by K0nserv on Friday August 19, 2022 @12:58PM (#32523474)
Apple started moving in this direction in 2020 with the introduction of App-Bound Domains[0]. These are currently opt in but I have always expected that, just like with the HTTPs adoption, they'll start enforcing this more strictly. With App Bound domains an app specifies ahead of time which domains are app bound and should allow injecting Javascript etc.

I expect app-bound domains to become required for all apps in iOS 16 or possibly iOS 17. There will probably a be a limit and some review on which domains an app specify as app-bound. Web browser that use WKWebView already have a special entitlement that excludes them from this.

0: https://webkit.org/blog/10882/app-bound-domains/

Re:See what JavaScript commands get injected through an in-a... by jabbany on Friday August 19, 2022 @12:24AM (#32517534)
Locking down in-app browsers seems like a reasonable trade-off. Kind of surprised it wasn't the case before, since browser extensions have had site permissions for ages now.

One could just follow what browsers do for extensions: have the developer specify a list of all the hostnames that they want to enable script injection on in a manifest, and ask for permissions at the start. Anything not on the list must be loaded via a sandboxed browser.

Keeps legitimate uses functional while preventing broad script injection.

Re:See what JavaScript commands get injected through an in-a... by fsckboy on Thursday August 18, 2022 @11:40PM (#32517396)
> They're going to heavily lockdown WKWebView after the Instagram and Tiktok revelations, probably in iOS16.1

are you just making a prediction, or do you have knowledge of this?

Re:See what JavaScript commands get injected through an in-a... by deminature on Friday August 19, 2022 @01:30AM (#32517784)
Just a guess if I were responsible for making the decision. All these methods will probably disappear or get much tighter on how they can be used: https://developer.apple.com/documentation/webkit/wkuserconte... https://developer.apple.com/documentation/webkit/wkwebview/1...
Re:See what JavaScript commands get injected through an in-a... by mark_l_watson on Thursday August 18, 2022 @10:25PM (#32517070)
+1 thanks for the info - it makes sense that Apple would try to mitigate this on their platform.

I use Apple’s new Lockdown Mode on the beta iOS 16 and iPadOS 16. I generally like it. It largely disables arbitrary JavaScript, as far as I know. A few times a week, I will turn off Lockdown temporarily for a few minutes for a web site if there are any problems. This is usually Amazon.com’s Kindle preview feature.

Re:See what JavaScript commands get injected through an in-a... by leodriesch on Friday August 19, 2022 @03:31AM (#32518385)
Lockdown mode is a security measure and not a privacy one.

It disables JavaScript JIT compilation, which makes it slower but more secure.

It should not disable any JavaScript execution itself.

Re:See what JavaScript commands get injected through an in-a... by MBCook on Thursday August 18, 2022 @10:48PM (#32517169)
Do we know if lockdown’s JS protection applies to apps using WKWebView? That could flat out break a lot of apps.

I thought lockdown mostly applied to system stuff (including Safari).

Re:See what JavaScript commands get injected through an in-a... by DecoPerson on Thursday August 18, 2022 @11:39PM (#32517393)
I hope they leave means of communication available. Something like window.postMessage. Like how Chrome extensions can expose a limited part of the Chrome API to webpages so they can post messages to certain extensions, without needing to inject anything into those webpages.
Re:See what JavaScript commands get injected through an in-a... by rvz on Thursday August 18, 2022 @11:13PM (#32517270)
I hope it gets locked down further just like how Apple introduced App Tracking Transparency, to further reduce and make it harder for data collection like this so that it is not open to abuse, not just this but in all of iOS in general.

Whether if it is collecting biometric data, voice prints, reading the clipboard, collecting information around local network devices and now abusing the in-app browser to further collect user data, the same social networks will try anything to abuse the iOS system to collect as much data as they can.

Given that Facebook did the exact same invasive actions and was fined in the billions, there is enough evidence of these invasive data collection practices that TikTok has done over the years to be worthy of a multi-billion dollar fine.

There is no exceptions, excuses or any room for double standards.