17 ms·
V8: A Year with Spectre
- rmbryan 8y agoThe original paper is extraordinary: https://arxiv.org/pdf/1902.05178.pdf https://arxiv.org/pdf/1902.05178.pdf
- mhandley 8y agoFrom their abstract: As a result of our work, we now believe that speculative vulnerabilities on today’s hardware defeat all language-enforced confidentiality with no known comprehensive software mitigations, as we have discovered that untrusted code can construct a universal read gadget to read all memory in the same address space through side-channels. In the face of this reality, we have shifted the security model of the Chrome web browser and V8 to process isolation. Processes are pretty heavyweight as a way to perform this sort of isolation. I can't help thinking that something like sthreads and tagged memory from Andrea Bittau's wedge system would be great OS primitives to have right now. http://www0.cs.ucl.ac.uk/staff/M.Handley/papers/wedge.pdf http://www0.cs.ucl.ac.uk/staff/M.Handley/papers/wedge.pdf RIP Andrea.
- Ono-Sendai 8y agoIsn't one possible solution to this problem just not to allow untrusted programs access to clocks and timer features?
- ufo 8y agoYou can do these things as a mitigation but it doesn't fully solve the problem because untrusted programs can try to get timing info from other sources. For example, incrementing a counter inside an infinite while loop can give you a good estimate of time, measured in cpu clock cycles .
- ynniv 8y agoThat might not be possible in a single threaded environment like JavaScript.
- Klathmon 8y agoIf that single-threaded process can talk to another process or system, can't it gather or exfiltrate timing information through that channel?
- stefan_ 8y agoIt was until they added background workers. There is a known simple mitigation. Don't JIT random JavaScript, back to interpretation. Of course that means there is no use for V8, which is why it's not in this paper.
- ufo 8y agoInterpreters aren't enough either. If the interpreter contains pieces of code that are vulnerable to spectre then it can still be exploited.
- Klathmon 8y agoV8 has a JIT-free mode now, and it's still pretty damn fast in real world situations. It looks like in synthetic benchmarks they saw up to 80% decrease in performance, but in real-world applications they saw as little as a 6% decrease. https://v8.dev/blog/jitless https://v8.dev/blog/jitless But even an interpreted language can still be vulnerable to Spectre attacks.
- phire 8y agoAn attacker could probably use a remote server and mesure the timing differences between http packets. It doesn't matter if your timing source is high noise with lots of jitter, the attacker can repeat the mesurements over and over again and filter everything out. Even if the attacker can only pull out a few bytes per second, that might be enough to leak something critical like and encryption key or an ASLR offset.
- 8y ago
- mhandley 8y agoThe article discusses why this is insufficient.
- deleted 8y ago[deleted]
- bartread 8y agoThere are going to be use cases that would break, for example with the Web Audio APIs, because it would make it impossible to precisely time or trigger events.
- amenghra 8y agoYou should read “Fantastic Timers and Where to Find Them: High-Resolution Microarchitectural Attacks in JavaScript” (https://gruss.cc/files/fantastictimers.pdf$ https://gruss.cc/files/fantastictimers.pdf$
- Ono-Sendai 8y agoYeah some pretty interesting stuff there. The counting thread achieves 2ns resolution :)
- kllrnohj 8y ago> Processes are pretty heavyweight as a way to perform this sort of isolation. How do you figure? Processes on some OS's, such as Linux, are pretty cheap. So what are you considering heavy? And how do you imagine a "process switching in userspace" type thing to not just have the same weight as real processes? What's the expensive thing you're trying to eliminate?
- kccqzy 8y ago> Processes are pretty heavyweight as a way to perform this sort of isolation. I'm really thinking that, we don't really need all the features offered by processes. My current understanding is that we just need a different address space. Why can't we, for example, switch from one set of pages to another when we switch from running trusted browser code to running JIT-ed untrusted code? (Leaving of course a small piece of trampoline code mapped, like KPTI.) On a simple level, this could just be calling mprotect() at certain key locations that result in flipping a few bits in the kernel-maintained page tables. With some good design, perhaps the address for untrusted code and data can be so far away from trusted code and data that maybe just one bit flip is needed in a PML4E.
- mhandley 8y agoThe wedge work did pretty much this - it allowed multiple page tables to be used within one process, and memory tags indicated which regions should be accessible to each "sthread". In this case, an sthread would run the JITed untrusted code. There are a lot of details to get right though, such as callgates between untrusted and trusted code so it's possible to call OS or process support functions. Anyway, although wedge was not intended to guard against spectre, it should do so nicely. Andrea had all this working in Linux.
- glenrivard 8y agoBe curious if Fuchsia and Google doing a custom SoC could be a solution.
- samth 8y agoLike many with a background in programming languages and their implementations, the idea that safe languages enforce a proper abstraction boundary, not allowing well-typed programs to read arbitrary memory, has been a guarantee upon which our mental models have been built. It is a depressing conclusion that our models were wrong — this guarantee is not true on today’s hardware. Of course, we still believe that safe languages have great engineering benefits and will continue to be the basis for the future, but… on today’s hardware they leak a little. We should all be more angry at chip makers for this. Intel isn't willing to admit that they broke things because then they'd have to fix it, but we shouldn't accept that kind of approach.
- TheSoftwareGuy 8y agoEverybody who studied even a little bit about processor hardware new about speculative execution. And it was never just intel that was using it, (they all were). Until Spectre that technology was not considered controversial. the crazy thing is that nobody saw this until recently.
- samth 8y ago"Until event X, doing <thing that X demonstrated was bad> was not considered controversial" is an explanation of behavior, but not really a defense.
- marcoperaza 8y agoNegligence, recklessness, knowledge, or purposefulness are probably the only way actions can be wrongful. To have acted negligently, you at least ought to have known that it carried an unacceptable risk. So you need a story on how it was at least negligent and why they ought to have known the risk before releasing the product.[0] Mere causation can’t get you there. E.g. when a car hits a pedestrian, the driver and pedestrian equally “caused” the accident. It is only by way of characterizing their behaviors in one of the ways above that we can identify wrongdoing. Perhaps the driver wasn’t paying attention (negligent or reckless) and ran a red light. Or perhaps the pedestrian was intentionally throwing themselves in front of traffic. Etc. [0] Products liability law on its surface does eschew the moral-wrongdoing requirement in favor of strict liability for some kinds of product defects. But that has to do with economic incentives, practical ability to prove claims, etc.
- supermatt 8y agoIt is sad that the solution is to cripple the software. I hope that these workarounds will be relegated to compatibility issues in the future as the underlying hardware is eventually fixed.
- supermatt 8y agoNot sure why i got downvoted for this. Anyone care to enlighten me?
- deleted 8y ago[deleted]
- MiroF 8y agoAny solution requires "crippling the software" - process isolation increases overhead through kernel context switches
- supermatt 8y agoI suppose this is where I realise I don't actually understand the underlying issue. If it is a software issue, why is there so much blame directed to the hardware vendors?
- MiroF 8y agoIt's a hardware issue - ie. it is caused by compromises hardware made to speed up execution times. Because we're stuck with the hardware we have, we can make software fixes - however they are going to require either slowing down or removing certain features until we get a hardware fix for the issue.
- supermatt 8y agothank you. I read in another comment that this isn't an issue with process isolation of memory (which I originally thought), its an issue with the isolation of memory within the process - would you say that is a good summarisation? i.e. the hardware is working as designed, but the software is expecting guarantees that the hardware never promised?
- bithavoc 8y ago> Thus Chrome’s security model no longer assumes language-enforced confidentiality within a renderer process. So V8 never was and never will be a silver bullet for running JS/WASM without isolation. I wonder what Edge CDN such as Cloudflare[0] and Flastly[1] are doing to isolate their functions. [0]https://blog.cloudflare.com/cloud-computing-without-containers/ https://blog.cloudflare.com/cloud-computing-without-containe... [1]https://www.fastly.com/blog/announcing-lucet-fastly-native-webassembly-compiler-runtime https://www.fastly.com/blog/announcing-lucet-fastly-native-w...
- 0815test 8y agoRunning them on in-order, speculation-free hardware would be quite sufficient, and come with additional benefits in power efficiency. The thing about Spectre or Meltdown is that there's really no case for the sorts of out-of-order cpus that raise these issues, unless you're truly bound by compute or memory bandwidth on some single-threaded task - which will never be the case for typical JS/WASM workloads on the "edge".
- bartread 8y ago> which will never be the case for typical JS/WASM workloads on the "edge". Yeah, but it's the atypical workloads that get you, and in every place I've worked there's always been at least the odd atypical workload regardless of system, product, platform, technology, target market (including internal and external).
- zzzcpan 8y agoSo, small in-order CPUs will be the future of commodity distributed computing after all? I doubt they will resort to that though. They can do other tricks, since they control the infrastructure, like turning on process isolation automatically for suspiciously behaving code.
- phire 8y ago> Running them on in-order, speculation-free hardware would be quite sufficient. In-order isn't a magic bullet against Spectre, they still do spectulative execution after predicting branches and they can still be vunerable. ARM have listed at least one of their in-order cores as vunerable. To be free of all speculation you have to go back to the 486, which didn't even have branch prediction. Besides, if you are making custom CPUs there are other options to avoid Spectre that don't require eliminating all spectulative execution.
- jnordwick 8y agoAnd still to this date not single spectre attack shown to work under real world conditions. This had been the most overt blown security topic I've ever seen. All the POCs required higher help from the code being attacked: eg, known memory locations, nothing else running on the system. There still has not been a single real world exploit developed for Spectre: eg somebody attack a running server. But yet all this time and effort has gone into a theoretical toy. It is so incredibly difficult to pull this off, that is should be one of the lowest priorities. I guess it gets ink because it pushes the security issues past all the software foul ups and lets people hate on Intel. Developers gotta develop I guess. Edit: down to -3 already for expressing an opinion, and nobody really responded except for a variation of the precautionary principle. I wish more people understood that spectre isn't the bogeyman that we need to give up 5 to 15% of our CPU for (and meltdown was more of a bug and when easily patched is no worse than Spectre). Maybe I should put an encryption key in a sandboxed system and play $1000 if anybody can use Spectre to recover it? Even then it probably would shut everybody up.
- mxschumacher 8y ago> And still to this date not single spectre attack shown to work under real world conditions. I find statements like yours difficult. Can we know that something did not happen just because nobody talked about it? A vulnerability as deep and far reaching as Spectre is extremely interesting to nation-state level hacking groups as a means of warfare, we should not assume that we know about everything these actors are up to.
- gmueckl 8y agoBut if you treat well funded actors as essentially omnipotent entities, you might just as well lie down and give up. The reality is that although we don't know everything, there cannot be all that much activity, either, or we would see many more installations of well crafted exploits and rootkits than what currently gets reported. And I would expect blackhats to go for some reliable 0 day hack with small code size rather than relying on a complex attack that first needs to read memory locations in a roundabout way to get anywhere.
- willvarfar 8y agoIf they are going with isolation instead, can we have the high-res timers and shared buffers back?
- readittwice 8y agoaren't they already back?
- markdeloura 8y agoUsing Chrome 73 I was getting pretty wildly variable results back from performance.now() a week ago. Was near useless when trying to profile some game code. Apparently the timing results you get back in devtool perf tools are reliable, but that's not useful for in-game performance dashes or real-time profiling.
- 0x0 8y agoThe linked paper contains a quote and a reference to Microsoft Singularity that really is an interesting thought experiment. Imagine we were all running next-gen systems designed like Singularity by now, which relies on type safety and managed code instead of memory protection to provide application level security. Spectre would have been a lot more devastating then, if we couldn't have hardware-assisted virtual memory protection separating processes from each other? https://en.wikipedia.org/wiki/Singularity_(operating_system) https://en.wikipedia.org/wiki/Singularity_(operating_system)
- monocasa 8y agoSingularity also let you use hardware protection in addition to SIPs. Basically it let you map a set of SIPs to a hardware domain.
- milkey_mouse 8y agoSingularity heavily relies on capabilities. What if accessing the current wall clock time was a zealously guarded capability? I wonder what percentage of apps could function with no access to (real time) timers at all, or an extremely granular one? I can't find a link at the moment, but I recall a paper showing even a very granular clock will suffice for Spectre exploits, albeit with lower bandwidth. Also, something else would need to be done about multithreading, as an application could always just spin up another thread counting as fast as it can to make a poor man's timer.
- Legogris 8y ago> I can't find a link at the moment, but I recall a paper showing even a very granular clock will suffice for Spectre exploits, albeit with lower bandwidth. The linked article mentions this and the linked paper gives some references: https://gruss.cc/files/fantastictimers.pdf https://gruss.cc/files/fantastictimers.pdf
- Klathmon 8y agoI may be wrong, but isn't there an almost unlimited amount of ways that you could determine wallclock time? Any kind of networking access can get it (with enough samples, you can get some crazy precision over even the most inconsistent networks), and really any kind of I/O could be abused when combined with another exploits. And if your permissions system doesn't allow I/O, is there really a lot that your program can do?
- Ragib_Zaman 8y agoPeople sometimes talk about waiting for a Spectre "fix" at a hardware or software level, but it seems that the only fix is to lose Speculative execution entirely (and with it, its performance gains). On my Haswell CPU, the performance hit was about 5% in various benchmarks, although newer architectures suffer less. Given that Spectre attacks still appear to be very difficult to perform in practice, I wonder if we will start to see Speculative execution at the hardware level brought back as an option for high performance and closed environment settings.
- nicoburns 8y agoI wonder whether you could mitigate by speculatively executing all/both branches, or somehow making it constant time...
- jnordwick 8y agoThe issue is more that you are causing a calculated cache line to be fetched and then the timing difference between the L1 cache and L3 or MM fetch shows what the calculated value was. The only way to make those appear at the same speed is to slow L1 down on a speculative fetch to MM speed. It isn't like a simple branch with two possible values. The cache line could be one of 256 (if scanning a byte at a time).
- microcolonel 8y agoI don't think you are actually disabling speculative execution on your Haswell.
- Ragib_Zaman 8y agoPerhaps not at the hardware level, I'm not sure. I downloaded InSpectre (a windows application) which informs me that I had been protected against Spectre and Meltdown attacks through Windows updates. I also used the option to disable the protection, which is how I figured out how much of a performance hit I was taking.
- jcranmer 8y agoWhen Spectre first came out, my prediction was basically that the only effective mitigation would be to move the untrusted code into another address space. This post reinforces that they have exhausted all other options: > Our research reached the conclusion that, in principle, untrusted code can read a process’s entire address space using Spectre and side channels. Software mitigations reduce the effectiveness of many potential gadgets, but are not efficient or comprehensive. The only effective mitigation is to move sensitive data out of the process’s address space. Probably the most effective hardware mitigation would be to shift the isolation to a page-level granularity, so that you could say that speculation is disabled for memory in specific pages.
- zzzcpan 8y agoNote, they talk about retrofitting mitigations into the web browser running javascript, not in general. It's hard to find a reason why software mitigations wouldn't work for a language and a compiler designed from scratch for it.
- reubenmorais 8y agoMitigating Spectre only makes sense if you’re doing it in a VM (e.g. operating system, web browser, processor), a system that loads and executes untrusted code. Not in a language or a compiler. If your language/compiler doesn’t allow the coder to exploit Spectre, they’ll just use another language/compiler.
- zzzcpan 8y agoThe problem is much bigger than that. Today pretty much all mainstream languages rely on untrusted modules ecosystems, untrusted github projects, etc. If we were to create language level boundaries to address those problems, we would need to deal with Spectre as well. Either way, my point was that it's absolutely possible to fully mitigate Spectre in software. A particular group of people just found it too hard to do for the things they work on. Doesn't mean the same applies to anything else.
- 8y ago
- CzechTech 8y agoAm I the only one who just does not care? I mean, there are so many 0day vulnerabilities... and most of the really useful ones are not even shared publicly. I just don't believe that Spectre represents any kind of "above standard" vulnerability to the computers of regular people (and even most IT professionals)... I understand the concern if we're talking about internet-facing network services/servers, but forcing these performance degrading "fixes" on people with Windows and stuff... is a massive overreaction. All these patches should be opt-in.
- omnifischer 8y agoofftopic: Kudos to the author for having simple and fast loading page without any js or complicated CSS. Loads blazing fast. No tracking too.
- mathias 8y agoThanks :) Glad to see people appreciate simplicity (and the performance that comes with it).
- eitland 8y agoOne thing that would reduce the attack surface massively is if we stopped pretending it is OK for every website under the sun to run any code they want for as long as they want just because I am reading their webpage. Yep, you could say I'm talking about "crippling" web pages, but I'd rather phrase it as "pruning" or "removing the worst abuses". Those who read carefully might have noticed I didn't say "kill Javascript with fire" or anything like that, and I think we could get far just by having the browsers limiting (by default) Javascript run time to 3 seconds: start at 20 seconds this summer and aim for 3 seconds next summer, because who seriously thinks web pages should need to run scripts for minutes after they have loaded? I realize there are a couple of problems with the simplified approach above, so let me try to defuse the ones I see right away: - This will break a number of sites: Yep. But if we really wanted and we got all browser vendors behind it we it wouldn't take long before all mainstream sites would be optimizing their js like crazy to make sure it loaded withing 20, then 19 seconds etc. That said: Good luck getting all browser vendors on board with this. (And, in my defense: I didn't say it would be easy, or even possible, only that I think it would be a good idea to do.) - Some pages need Javascript because they load content using JS: We can reset the counter to something reasonable for certain types of user input. - Some web pages needs Javascript for <reasons>: let them have a popup like the ones they get for location sharing etc.
- jensvdh 8y agoDo you want to go back to doing everything on the server again like the early 2000s? Because that's what you'll end up with.
- AWildC182 8y agoIf we're going to do that, why don't we just go back to the 90s where everything is static and the points don't matter?
- eitland 8y agoI call strawman, although I guess it is not intentional: I'm quite clear in the comment you replied to that I don't want to remove all possibilities for JavaScript. I want to reduce attack surface significantly and as a nice bonus create a better browsing experience for everyone. Even I realize Javascript has its place for now at least: - autocomplete - client side validation - complex browser side apps, including games What I want to curb is websites that keep exercising my CPU for no good reason (for me as a user) because they: - are poorly written - are busily loading and reloading ads and trackers - etc I don't see how you go from removing the worst abuses i.e. to "everything on the server again like the early 2000s"
- Causality1 8y agoSpectre is a great example of what effect public perception has on software development. After it's disclosure the industry absolutely scrambled to patch it because mainstream news outlets declared the sky was falling. A year in, and we have hundreds of thousands of slightly older computers with a 20% performance drop and even modern machines with a 5-10% performance drop to address a purely hypothetical threat. Compare this to the various Intel Management Engine exploits from the past couple years which received no media attention and thus no industry attention.
- eclipseo76 8y agoDoes anyone know if SELinux can mitigate some of these vulnerabilities?
- monocasa 8y agoIt does not.
- antientropic 8y ago> Like many with a background in programming languages and their implementations, the idea that safe languages enforce a proper abstraction boundary, not allowing well-typed programs to read arbitrary memory, has been a guarantee upon which our mental models have been built. As an aside, the notion that it's very risky to rely only on the type system to enforce security boundaries is not new. In 2003, Govindavajhala and Appel [1] showed that you can break the security of the JVM through memory errors. Basically, an untrusted attacker fills memory with a specially formatted data structure such that in case of a random bit flip, with high probability, you get an integer field and a pointer field aliasing each other, allowing you to do pointer arithmetic. By contrast, it's extremely unlikely that a random bit flip allows (say) an unprivileged Unix process to get root access. [1] https://www.cs.princeton.edu/~appel/papers/memerr.pdf https://www.cs.princeton.edu/~appel/papers/memerr.pdf
- wyldfire 8y ago> we productionized and deployed site isolation for as many platforms as possible by May 2018. Is there a way to determine whether site isolation is available/enabled on my chrome platform?
- bogomipz 8y agoThe article states: >Extract the hidden state to recover the inaccessible data. For this, the attacker needs a clock of sufficient precision. (Surprisingly low-resolution clocks can be sufficient, especially with techniques such as edge thresholding.) Might anyone have some good resources or links they could share on this "edge thresholding" technique?
- MichaelMoser123 8y agocouldn't Intel add a per thread option to enable/disable speculative execution? This option could be disabled once a thread is about to execute just in time compiled code, Javascript would then run slower - but without the specter of Spectre..
- norswap 8y agoSmall question: how can they know that it's a mispredicted branch that is being executed (so that they can set the poison appropriately)? If they have this knowledge, couldn't they simply drop the execution since it's a misprediction?