News for hackers. Stuff that matters.
Re:Python 3.11 in the Web Browser by modeless on Saturday March 26, 2022 @06:32PM (#30815949)
I really, really wish it were possible for wasm modules like this to be shared between sites. That is, python.org could host an official wasm module, and the first time you visited a site using python the browser would download and compile it once and cache the result, and then any other website could use python with no download size or load time penalty. But unfortunately privacy concerns killed this utopia. Caches are now partitioned per origin, so every site that uses python has to download and compile the wasm module separately even if it's the exact same module from the same place, and that is unlikely to ever change: https://developer.chrome.com/blog/http-cache-partitioning/
Re:Python 3.11 in the Web Browser by nine_k on Sunday March 27, 2022 @12:15AM (#30817655)
While I understand how finding a particular unique resource cached may allow to glean some privacy-infringing info, I don't see how detecting a common library downloaded from a site that provides it for everyone (like python.org) would help reveal anything.

If users might define a list of sites trusted for cross-site caching (like fonts.google.com and other known library CDNs), this could help cache quite some common resources without downsides to user's privacy.

Re:Python 3.11 in the Web Browser by berkes on Sunday March 27, 2022 @03:10AM (#30818367)
But then those 'common trusted sites' can spy on users massively.

fonts.google.com is, after google analytics, the most effective spyware around today.

Re:Python 3.11 in the Web Browser by remorses on Sunday March 27, 2022 @07:02AM (#30819327)
The problem is that you can identify people by checking what resources they have already cached
Re:Python 3.11 in the Web Browser by xpressvideoz on Saturday March 26, 2022 @06:47PM (#30816045)
Wait, so the traditional "use the JavaScript CDN as a cross-site cache" method does not work anymore? How did I not know that!
Re:Python 3.11 in the Web Browser by simonw on Saturday March 26, 2022 @06:53PM (#30816073)
It was a huge privacy hole: malicious pages could measure how long it took for URLs to load and use that to tell which other sites you had visited in the past.
Re:Python 3.11 in the Web Browser by jefftk on Sunday March 27, 2022 @12:10AM (#30817637)
Re:Python 3.11 in the Web Browser by wolpoli on Saturday March 26, 2022 @09:48PM (#30817034)
We could solve the privacy issue by implementing an installable plugin system into the browser. Let's call it NPAPI!
Re:Python 3.11 in the Web Browser by doctoboggan on Saturday March 26, 2022 @07:21PM (#30816244)
It seems like there could be some sort of cross origin cache header that could be set? That way by default you couldn't store in a global cache but server operators would be able to mark certain resources that could be.
Re:Python 3.11 in the Web Browser by modeless on Saturday March 26, 2022 @07:32PM (#30816300)
Server operators would just set that header on everything. There's no downside for them. The privacy issue only impacts users and it would still exist even if only a subset of libraries were shared.
Re:Python 3.11 in the Web Browser by zdw on Saturday March 26, 2022 @11:50PM (#30817546)
One proposed solution is checksums on CDN provided javascript:

https://w3c.github.io/webappsec-subresource-integrity/

Re:Python 3.11 in the Web Browser by eigenvalue on Saturday March 26, 2022 @07:45PM (#30816371)
Surprised the clients couldn’t just randomly add a small random delay on N percent of requests to nullify the side-channel info leakage.
Re:Python 3.11 in the Web Browser by dagenix on Saturday March 26, 2022 @08:12PM (#30816537)
It's my understanding that that type of countermeasure can be defeated with some statistical analysis.
Re:Python 3.11 in the Web Browser by gizmo686 on Saturday March 26, 2022 @10:00PM (#30817087)
Normally they could be, but it might actually work in this case. To do a statistical analysis, you need to be able to make many measurements. However, you only get one measurement per resource as a subsequent attempts will be cached regardless.
Re:Python 3.11 in the Web Browser by codethief on Sunday March 27, 2022 @07:18AM (#30819397)
AFAIU you can invalidate the browser cache for a certain resource by hand:

> To delete the HTTP Cache, you just have to either issue a POST request to the resource, or use the fetch API with cache: "reload" in a way that returns an error on the server (eg, by setting an overlong HTTP referrer), which will lead to the browser not caching the response, and invalidating the previous cached response.

https://sirdarckcat.blogspot.com/2019/03/http-cache-cross-si...

Re:Python 3.11 in the Web Browser by dagenix on Saturday March 26, 2022 @10:52PM (#30817326)
This is very much not my area of expertise, but there are a few things that I think could be challenging. Let's assume that a cached resource loads in ~0.1 seconds and an uncached one loads in ~1.0 second:

* Any random delay of up to less than 0.9 seconds is completely pointless since we would know that any resource that loads in 0.5 seconds has to be cached - the 0.4 seconds spent waiting is useless.

* A random delay of up to a second creates ambiguous cases: is 1.1 a cached + maximally delayed response or an uncached but only slightly delayed response? But, with a random delay, we're still going to have pretty different peaks in the expected latency graphs for cached and uncached resources - uncached ones would peak around 0.5 seconds and cached ones would peak around 1.5 seconds.

* A random delay much more than a second would start causing the peaks on our expected latency graphs to be closer together - at a 10 second delay, we'll have a peak in the graph around 5 seconds for cached resources and 6 seconds for cached ones. I'm a bit fuzzy on how many resources we'd have to load to get a statistically significant finger print. I suspect its not all that many - but I could be wrong. However, we're also talking about a pretty significant delay by this point.

We also have the issue of how to handle AJAX requests. You only get one shot to measure the initial load. But, after that you can make an AJAX request to re-load that same resource with caching disabled and measure that. I'm not a statistician, but, I suspect that that information will be pretty helpful in figuring out what was cached vs not cached. Of course, we could add in some random delays here too - but since we can measure this an unlimited number of times, I suspect this would be even easier to defeat.

So, my suspicion is, that these type of random delays are possible to defeat if you have a better grasp of statistics than I do.

But, we could also assume that that is not the case and that they can't be defeated - what does that get us? We've had to add all these random delays in to block the side channel which is going to hurt latency - the very thing we're trying to improve with caching. I also suspect there is a ton of complexity to consider if you want to avoid having all of the same random delays on repeated visits.

Re:Python 3.11 in the Web Browser by a1369209993 on Sunday March 27, 2022 @01:04AM (#30817854)
Isn't the obvious solution here to just cache the delay? The browser presumably knows how long the original resource request took when site A made it, so it can just expose the same latency to site B and - since the cache by definition only hits if the request is identical - site B can't tell whether it's delayed by artificial cache latency or actual network latency. Chuck a symlink to the resource into each per-origin cache so non-initial requests still finish immediately, and possibly add a small chance of silently retrying the underlying request to see if it gets faster (with probability that can be computed entirely from site-B-observable load times).
Re:Python 3.11 in the Web Browser by dagenix on Sunday March 27, 2022 @02:51AM (#30818294)
Caching the delay defeats a big purpose of the cache in the first place - to reduce latency. But, also, the entity trying to fingerprint the request might also control the CDN - in which case, they can control the latency of non-cached requests. So, maybe in even minutes non-cached requests complete fast, but in odd minutes they are slow - in which case, a deviation from that behavior could be detected as a signal.
Re:Python 3.11 in the Web Browser by a1369209993 on Sunday March 27, 2022 @04:14AM (#30818625)
> a big purpose of the cache in the first place - to reduce latency.

You can't reduce first-visit-to-site-B latency below what it would be if you hadn't visited site A and also not reduce first-visit-to-site-B latency below what it would be if you hadn't visited site A; no possible delay policy will help with that.

> they can control the latency of non-cached requests.

This is more of a problem, but it doesn't need latency as such - site B could compare request traffic to b.example versus cdn.example to see whether a request was skipped due to already being cached.

(To be clear, I'm not sure you can actually do cross-origin caching securely for web traffic, for the above reason; I was addressing the narrow question of how to pick a delay - namely, don't delay cached and uncached responses by the same amount relative to their naive latency, because the whole point is that their naive latencies are different and we're trying to make that not true.)

Re:Python 3.11 in the Web Browser by Asooka on Monday March 28, 2022 @05:24AM (#30828752)
You should be able to do something like this:

- if the resource isn't in cache, download it and note the time it took.

- if the current site has requested the resource before, just return it instantly.

- otherwise, wait the exact same time it took originally.

With this the first request a site makes for a resource will always take the same time and you have no way of knowing if that was the first time it was downloaded or if it's served from cache. It's obviously not quite that simple, you'll need to factor in which connection is in use etc, but it should be possible to keep cross site caching.

Re:Python 3.11 in the Web Browser by colordrops on Saturday March 26, 2022 @07:02PM (#30816125)
Weren't the shared libraries used on countless sites though? How would this work?
Re:Python 3.11 in the Web Browser by modeless on Saturday March 26, 2022 @07:28PM (#30816274)
Yes but each site uses a lot of libraries too. The set of libraries and specific versions of those libraries used by a site is a pretty good fingerprint.
Re:Python 3.11 in the Web Browser by colordrops on Saturday March 26, 2022 @07:42PM (#30816353)
Still doesn't make sense - there is only a single set of libraries - the ones cached by a user's browser, and since each library in that set is used by thousands of sites, there's no way to know which site it was cached for. For each version, there are certainly thousands of sites using it. Since I'm still not getting it, perhaps you could explain how a particular set of libraries is fingerprinted?
Re:Python 3.11 in the Web Browser by dmurray on Saturday March 26, 2022 @08:25PM (#30816590)
The New York Times uses libraries (versions) A,B,C, and D. Wikileaks uses A,B,D and F. I see that you have A,B,D and F cached - that allows me to rule out the NYT and predict with some degree of confidence that you visited Wikileaks.

You can make up theoretical models for how many popular libraries there are, or how many sites, and say this should or shouldn't be possible. I haven't seen any such models, but advertisers were definitely using this technique in the wild so the models that say it's impossible are all wrong.

Adding noise to a small sample of requests doesn't buy you that much entropy - the signal is a little noisy anyway.

Re:Python 3.11 in the Web Browser by colordrops on Saturday March 26, 2022 @09:55PM (#30817063)
This would work if you only visited like 5 sites. If you visit thousands, and more like tens of thousands when you consider 3rd party embedded content, you can't figure out which sites a user visits, but rather only which ones they don't.
Re:Python 3.11 in the Web Browser by EwanToo on Sunday March 27, 2022 @04:22AM (#30818659)
It worked pretty effectively.

Think about the 10,000s of JavaScript libraries out there, and the 100s of versions of each.

Re:Python 3.11 in the Web Browser by madacol on Sunday March 27, 2022 @08:00AM (#30819583)
number of libraries * number of versions ~= bits of information to classify you

A good intuition is that although there's low certainty which site you have visited, there's high certainty which sites you HAVE NOT visited

I think is easier to see how you can fingerprint someone based on the set of sites they HAVE NOT visited

Edit: I'm not so sure anymore, I think that requires to test looots of libraries, it's not practical unless you are a really nasty ad company that tests hundreds of libraries in the background really sucking up your bandwidth

Re:Python 3.11 in the Web Browser by madacol on Sunday March 27, 2022 @08:13AM (#30819655)
I got a better idea

Imagine ad companies choose libraries that are roughly used by 50% of users, if they test you with 10 of those, they learn ~10bits of entropy to classify you, i.e. which of the 1024 classifications you belong

Re:Python 3.11 in the Web Browser by TOMDM on Saturday March 26, 2022 @07:06PM (#30816153)
Because you'd make your own library used exclusively for tracking, or check to see if another site specific set of resources had been loaded.
Re:Python 3.11 in the Web Browser by markdown on Saturday March 26, 2022 @07:57PM (#30816451)
How is that any privacy hole at all?

Millions of websites use vue (as an example) from the same CDN. There's no way to know which site it was cached from.

What a terrible thing they've done, making the internet slower for everyone on earth for no good reason.

Re:Python 3.11 in the Web Browser by dagenix on Saturday March 26, 2022 @08:15PM (#30816551)
Its pretty bold of you to assume that you know more about this problem than every browser developer.

Websites don't just "use Vue". They use some particular version of Vue along with particular versions of other libraries. My understanding is that once you put all of that together, this can create some significant privacy leaks.

Re:Python 3.11 in the Web Browser by ______-_-______ on Saturday March 26, 2022 @08:13PM (#30816538)
By "they" do you mean advertisers? If so, I agree
Re:Python 3.11 in the Web Browser by teddyh on Saturday March 26, 2022 @09:02PM (#30816777)
It was discussed here at the time: https://news.ycombinator.com/item?id=24894135
Re:Python 3.11 in the Web Browser by skybrian on Saturday March 26, 2022 @10:07PM (#30817119)
I wonder if a browser vendor could host a repository of common libraries? With a limited number of versions available that changes only at the same time as the browser, maybe it wouldn't leak much info. It would be almost like including the code in the browser.
Re:Python 3.11 in the Web Browser by bb88 on Saturday March 26, 2022 @11:43PM (#30817512)
Isn't that almost like all browsers including a language with the browser?
Re:Python 3.11 in the Web Browser by nine_k on Sunday March 27, 2022 @12:06AM (#30817613)
It is, except the feature is downloaded on demand.

Users need to trust the browser's producer anyway.

Re:Python 3.11 in the Web Browser by zodiakzz on Saturday March 26, 2022 @10:27PM (#30817215)
How could this go wrong - Bill Gates
Re:Python 3.11 in the Web Browser by cgb223 on Saturday March 26, 2022 @08:56PM (#30816745)
Couldn’t browsers theoretically “bake in” the python.org binary to the browser itself to avoid this?

Kind of like how macOS (used to) ship with python preinstalled?

Re:Python 3.11 in the Web Browser by toastal on Saturday March 26, 2022 @10:08PM (#30817125)
If browsers already have a multi-paradigm, dynamic/duck-typed, garbage-collected scripting language in JavaScript, why would they add another one--especially since JS is incredibly backwards-compatible to not break the web? In the broader scope of programming languages, Python and JS are the same thing. If their going to add a second language, the least they could do is make it interesting in comparison.
Re:Python 3.11 in the Web Browser by bb88 on Sunday March 27, 2022 @12:19AM (#30817672)
Javascript will be 30 years old in 3 years. It's been successful, sure, but it's also been controversial and a lot of language mistakes have had to be carried forward. The 5 minute "wat" talk still lingers in my head about those basic mistakes.

"Oh they fixed that in Typescript."

But they could have fixed it with practically any other language as well.

Re:Python 3.11 in the Web Browser by asiachick on Sunday March 27, 2022 @01:44AM (#30817993)
The Wat talk is mostly BS for laughs. It's hilarious but to someone familiar with the language it's a bunch of stuff you'd mostly never run into. Some are even outdated.

Like he makes fun of the fact that Array(16).toString() prints 15 commas. In the context of the talk it's funny but in reality, what would you expect. You made a array with 16 empty elements. Array.toString() calls toString() on each element and separates them by commas. Why is that unexpected?

He then shows Array(16).join("wat") which is the same as the previous except JS uses "wat" between elements instead of ","

"wat" + 1 is string + number coerced to string so string + string. string + is defined as concatenation

"wat" - 1. There is no override for - for a string so numeric minus tries to add a string to a number and returns NaN. Ok, why is that unexpected? When will this bite you. You shouldn't be adding numbers to string or strings to numbers. I've been programming JS for ~20 years, I don't remember running into any of these issues.

I've also never tries to add to arrays, add an object and an array, add an array and an object, nor add 2 objects. It's funny that the language does something but so what.

You wanna talk about a language that sucks try bash. Meanwhile I've had no problems shipping 100s of projects in JS. (also, C, C++, C#, perl, python, assembly, others)

Re:Python 3.11 in the Web Browser by lenkite on Sunday March 27, 2022 @09:49AM (#30820213)
> Javascript will be 30 years old in 3 years

Python is already >31 years old.. Python is even older than Java. It is so slow - can barely crawl compared to other languages. Maybe we should retire grand-daddy Python ?

Re:Python 3.11 in the Web Browser by bb88 on Sunday March 27, 2022 @04:12PM (#30823646)
Or maybe just have google invest resources to make it faster like they did with JS?
Re:Python 3.11 in the Web Browser by nine_k on Sunday March 27, 2022 @12:15AM (#30817659)
On top of it, JS is significantly faster.
Re:Python 3.11 in the Web Browser by bb88 on Sunday March 27, 2022 @12:20AM (#30817676)
Faster than what?

JS was considerably slow until Google decided to spend resources to make it faster.

Re:Python 3.11 in the Web Browser by nine_k on Sunday March 27, 2022 @02:13AM (#30818139)
Current standard JS runtimes (e.g. V8) are faster than current standard Python runtimes (such as CPython).

Not that Python can't be made faster (though many architectural decisions of the language resist it), but it hasn't been so far, so there's little incentive to include it to a browser. It gives too little new capabilities, on top of JS.

OTOH, say, WASM gave many new capabilities, and has been included.

Re:Python 3.11 in the Web Browser by kumarvvr on Saturday March 26, 2022 @09:47PM (#30817030)
Yes. It absolutely can. And it would be even more efficient than using WASM. However, I guess adding a new language would introduce a lot of security issues and what not.
Re:Python 3.11 in the Web Browser by liftm on Sunday March 27, 2022 @01:45AM (#30817997)
This is what https://decentraleyes.org/ does, right?
Re:Python 3.11 in the Web Browser by fnord123 on Sunday March 27, 2022 @07:02AM (#30819324)
While I get you point, I think it's of limited usefulness for Python. You would end up with Snekr.io using 3.11 and cheeseshoppr.ws using Python 3.8.4 and etc. You can get some packages for any Python3 but they are the smaller ones. The larger wheels like numpy and pandas have C code which needs to be compiled or there's a giant version dependent wheel.

Server side Python is often deployed in a venv which has the desired python version and all the dependencies copied with the code.

Re:Python 3.11 in the Web Browser by asah on Sunday March 27, 2022 @08:53AM (#30819844)
the caching sites would host a small number of versions and the publishers would be motivated to select from among them.
Re:Python 3.11 in the Web Browser by krapp on Saturday March 26, 2022 @07:53PM (#30816433)
That page says there's a model for shared libraries being considered, so maybe there's hope.
Re:Python 3.11 in the Web Browser by froh on Sunday March 27, 2022 @04:11AM (#30818607)
You'd need trusted providers, and a mechanism to 'import' a trusted something into your 'domain'.

What am I missing?

Re:Python 3.11 in the Web Browser by bitpow on Saturday March 26, 2022 @11:54PM (#30817558)
You’re basically describing the old Java plugin paradigm.