News for hackers. Stuff that matters.
Re:Reading privileged memory with a side-channel by jhallenworld on Wednesday January 03, 2018 @07:02PM (#16066710)
"Meltdown" is an Intel bug.

"Spectre" is very bad news and affects all modern CPUs. Mitigation is to insert mfence instructions throughout jit generated sandboxed code making it very slow, ugh. Otherwise assume that the entire process with jit generated code is open to reading by that code.

Any system which keeps data from multiple customers (or whatever) in the same process is going to be highly vulnerable.

Re:Reading privileged memory with a side-channel by kibwen on Wednesday January 03, 2018 @07:19PM (#16066810)
> Mitigation is to insert mfence instructions throughout jit generated sandboxed code making it very slow, ugh.

Here's the synchronized announcement from Chrome/Chromium: https://sites.google.com/a/chromium.org/dev/Home/chromium-se...

"Chrome's JavaScript engine, V8, will include mitigations starting with Chrome 64, which will be released on or around January 23rd 2018. Future Chrome releases will include additional mitigations and hardening measures which will further reduce the impact of this class of attack. The mitigations may incur a performance penalty."

Chrome 64 will be hitting stable this month, which means that it ought to be possible to benchmark the performance penalty via testing in Chrome beta. Anybody tried yet?

Re:Reading privileged memory with a side-channel by dannyw on Wednesday January 03, 2018 @07:40PM (#16066928)
The mitigations are to disable SharedArrayBuffer and severely round performance.now(). Not good that there aren’t other less intrusive ways to mitigate.
Re:Reading privileged memory with a side-channel by kibwen on Wednesday January 03, 2018 @07:46PM (#16066957)
I don't get the impression that those are the full extent of the changes though; I think those two were called out only because they're API changes rather than implementation details. Haven't checked the code so I could be wrong, of course.
Re:Reading privileged memory with a side-channel by mirashii on Wednesday January 03, 2018 @09:04PM (#16067400)
A little bit more info can be found here [1]. In particular, site isolation [2] will also assist in protecting against this vulnerability.

[1] https://support.google.com/faqs/answer/7622138#chrome [2] http://www.chromium.org/Home/chromium-security/site-isolatio...

Re:Reading privileged memory with a side-channel by DannyDaemonic on Thursday January 04, 2018 @01:01AM (#16068371)
Would it be practical to run each javascript VM in it's own sandbox?

Edit: Apparently you can already do something like this. Seems to be an option for Chrome starting with 63. (Which was an October release I believe?

http://www.chromium.org/Home/chromium-security/site-isolatio...

Re:Reading privileged memory with a side-channel by aidenn0 on Wednesday January 03, 2018 @08:18PM (#16067160)
That can't be right because they already round performance.now() so the Spectre attack didn't use it (it instead used a webworker with a tight-loop incrementing a counter)
Re:Reading privileged memory with a side-channel by olliej on Wednesday January 03, 2018 @09:07PM (#16067417)
the tight loop iteration used a shared array buffer to provide a high resolution timer, specifically to deal with the obvious fix of truncating precision of performance.now().

The reason for /further/ truncating performance.now() is that the relative cost in this attack means that you don't need as much precision as was needed for the original (page table? I think) attack.

A SAB timer just needs to increment a counter in one thread and read it in the host thread and the granularity is however long it takes to get through a for-loop.

Re:Reading privileged memory with a side-channel by aidenn0 on Wednesday January 03, 2018 @10:52PM (#16067910)
Thanks, I missed how important SAB was to their webworker timer.
Re:Reading privileged memory with a side-channel by jchw on Wednesday January 03, 2018 @08:10PM (#16067116)
> ...severely round performance.now().

This sucks, and is a side-effect that I didn't even think about. I guess it's probably pretty effective, but it will make benchmarking a lot harder, since you'll probably now have to do a lot more runs.

Re:Reading privileged memory with a side-channel by gchadwick on Thursday January 04, 2018 @05:25AM (#16069225)
If it was a big issue you can always introduce a 'benchmark mode' switch that allows you to put resolution back into the counter when you want to run a benchmark. Display a 'WARNING BROWSER INSECURE IN THIS MODE' banner for good measure.
Re:Reading privileged memory with a side-channel by user5994461 on Thursday January 04, 2018 @02:12AM (#16068579)
Doubt that. The Firefox news said they will round to 20 us.

That's much more accurate than necessary to benchmark any software code.

Re:Reading privileged memory with a side-channel by londons_explore on Thursday January 04, 2018 @07:55AM (#16069960)
Those are the mitigations firefox is doing. Is chrome doing the same?
Re:Reading privileged memory with a side-channel by mschuetz on Thursday January 04, 2018 @06:45AM (#16069615)
For some reason, performance.now() and even the performance profiler are capped at 1 milisecond precision on my machine, which make both pretty much useles. Can only get better for me. :|
Re:Reading privileged memory with a side-channel by simion314 on Wednesday January 03, 2018 @07:12PM (#16066772)
From the article it seems that is not 100% sure AMD and ARM are not affected by metldown, only that they could not trigger the issue, but authors mention this

"However, for both ARM and AMD, the toy example as described in Section 3 works reliably, indicating that out-of-order execution generally occurs and instructions past illegal memory accesses are also performed."

Re:Reading privileged memory with a side-channel by jhallenworld on Wednesday January 03, 2018 @07:47PM (#16066970)
I would think that any sane implementation would not transmit privileged data to waiting instructions.

Look at their Listing 2: Instructions 5 - 7 will be waiting for the privileged data from line 4 (they are not speculatively executed since they have a data dependency on line 4).

So why is Intel releasing the privileged data to the waiting instructions? An answer could be that violation checking is delayed until retire, but other implementations are possible.

Anyway, so it could be that AMD and ARM are vulnerable, but it's possible that they are not.

Re:Reading privileged memory with a side-channel by olliej on Wednesday January 03, 2018 @08:05PM (#16067088)
There are two different issues.

1. Intel only (so far) is related to prefetching privileged memory 2. More or less everyone: Speculatively executing code that has variable execution time.

Re:Reading privileged memory with a side-channel by bonzini on Thursday January 04, 2018 @03:34AM (#16068802)
> I would think that any sane implementation would not transmit privileged data to waiting instructions.

The point of VIPT caches is exactly to use data before all the checks are completed.

It's easy to judge the sanity of things ex post, but maybe it's not that easy if it took 20 years to find the issue.

Re:Reading privileged memory with a side-channel by contrarian_ on Thursday January 04, 2018 @06:11AM (#16069426)
I don't believe for a second that nobody came up with this idea before. I believe that nobody until now had the motivation to spend the time actually trying to confirm that it's a problem by developing a PoC. Most people would have given up on the idea simply because CPU vendors are not expected to make such a fundamental mistake.
Re:Reading privileged memory with a side-channel by londons_explore on Thursday January 04, 2018 @07:59AM (#16069988)
The mistake is clear from the design - thats why all CPU vendors are vulnerable to variants of the same bugs.

Previously side channel attacks like this have been seen by the security community as unreliable things which only work in very specific cases and have to be averaged over millions of runs.

This attack shows a side channel which is general purpose, reliable, and fast.

Re:Reading privileged memory with a side-channel by contrarian_ on Thursday January 04, 2018 @08:51AM (#16070280)
> The mistake is clear from the design

There is no fundamental reason why speculative instructions should be allowed to mutate the cache.

OTOH the contention-based side channel attack on speculation has been public knowledge for over a decade. [1]

[1] Z. Wang and R. B. Lee, "Covert and Side Channels Due to Processor Architecture," 2006 22nd Annual Computer Security Applications Conference (ACSAC'06), Miami Beach, FL, 2006, pp. 473-482. doi: 10.1109/ACSAC.2006.20

Re:Reading privileged memory with a side-channel by bonzini on Friday January 05, 2018 @03:10PM (#16081242)
> There is no fundamental reason why speculative instructions should be allowed to mutate the cache.

There is: hundreds of instructions can be in flight speculatively at the same time, especially if you take hyperthreading into account. Good luck rolling them all back.

The question is not whether the cache should be mutated during speculative execution. It's what kinds of speculative execution are allowed, and in some cases it's not even clear if fences should be placed by the programmer (whack-a-mole style), the compiler (not sure how) or the processor (probably not). It's non-obvious enough that how to solve it is to some extent a research problem.

Re:Reading privileged memory with a side-channel by wilun on Friday January 05, 2018 @10:48PM (#16083733)
About Meltdown, it was well known since even before that speculative execution has to stop at security boundaries.
Re:Reading privileged memory with a side-channel by asveikau on Thursday January 04, 2018 @01:41AM (#16068500)
> Mitigation is to insert mfence instructions throughout jit generated sandboxed code making it very slow, ugh. Otherwise assume that the entire process with jit generated code is open to reading by that code.

It seems like keeping untrusted code in a separate address space would be a suitable workaround? A lot of comments here seem to be implying that meltdown-style reading of separate address spaces is possible via Spectre, and my read is that it wouldn't.

Re:Reading privileged memory with a side-channel by valleyer on Thursday January 04, 2018 @03:37AM (#16068814)
No, the Spectre paper discusses cross-process attacks too. First, you use BTB poisoning to coerce the victim process to branch-mispredict to code of your choice (a "gadget"). You can get that code to load memory of your choice, which can be the code of shared libraries (which are usually loaded only once into physical memory for all processes). Then you can do timing attacks using the last-level cache to determine whether that memory is in cache.

It's certainly not easy, but it's doable.

Re:Reading privileged memory with a side-channel by rtpg on Thursday January 04, 2018 @07:19AM (#16069781)
This is mitigatable if the attacker process can't send a memory address to the victim process, right? Even if you can poke at the memory for cache prediciton misses, if you can't control what the victim process accesses, it seems harder to exploit.

We're all talking about how Spectre is this magic "get access to any memory from any process". But it looks to me like it's a new class of attack, that still requires specific entry points for the software you're trying to attack.

I'd like to be proven wrong on this, but it _feels_ like this is more of a software thing like other timing bugs. In theory you can write software that isn't vulnerable

EDIT: my reading of the "JS Spectre implementation" is "JIT code runs in the process of the browser + you can write JS code to read the process's own memory". I can imagine messiness with extensions (1Password in particular).

Re:Reading privileged memory with a side-channel by stupidcar on Thursday January 04, 2018 @08:55AM (#16070301)
I don't think so. My understanding from the paper is that you don't need to explicitly send a memory address to the victim, you just need a way to communicate with it (e.g. via a socket or some other API) in a way that causes it to do a branch.

Before you trigger the victim process, you perform some steps in your own, hostile, process that teaches the branch predictor where a particular branching operation will likely go. Then you trigger the victim process in the way you know will cause a very similar branching operation.

Even though it's operating within an entirely different process, the branch predictor uses what it learnt in the hostile process to predict the branch result in the victim process. It jumps to the address the hostile process taught it, and starts to speculatively execute code there. Eventually, it figures out it guessed wrong, but by then it's too late, and the information has leaked via a side-channel in a way that the hostile process can detect.

So, essentially, you're use the branch predictor's cache to send the memory address. And you're not sending it to the victim process, you're sending it directly to the CPU. The victim process will never even know it's been attacked, because when the branch predictor hides the consequences of its incorrect guess from being detected by conventional means.

Re:Reading privileged memory with a side-channel by rtpg on Thursday January 04, 2018 @09:32AM (#16070530)
this still seems off to me.

I get that the victim process' branch prediction can be messed with. But if my victim process is:

   password = "password"
   secret = "magic BTC wallet secret key"
   while True:
       password_attempt = input()
       if constant_time_compare(password, password_attempt):
           print(secret)
And my input is something like:

   result = ""
   while sys.stdin.peek() not in ['\n', EOF]:
      result += sys.stdin.get()
Then at no point is the victim program really exposing any pointer logic, so not even the victim process will be accessing the `secret` during execution, let alone the hostile process.

The examples given all include arrays provided by the hostile program, and some indexing into the arrays. I definitely see this being an issue in syscalls, but if that's the scope of this, I wouldn't call Spectre a "hardware bug" any more than other timing attacks would be hardware bugs.

Re:Reading privileged memory with a side-channel by stupidcar on Thursday January 04, 2018 @10:44AM (#16071159)
The victim code doesn't need to have some explicit pointer arithmetic, it just has to have some sequence of bytes, somewhere in its address space (the "gadget"), that can be used to read a memory address based on a value stored in a register that can be affected by input supplied from the hostile process. The branch prediction is used to speculatively execute that code. The "Example Implementation on Windows" section in the Spectre paper goes into more detail about this.
Re:Reading privileged memory with a side-channel by Certhas on Wednesday January 03, 2018 @07:17PM (#16066799)
After skimming the articles it sounds like a lot hinges on just how hard Spectre is to pull off in practice/in the wild. Anyone have any insights on that?
Re:Reading privileged memory with a side-channel by labster on Wednesday January 03, 2018 @09:16PM (#16067452)
I don't know much about this particular flaw, but I imagine it'll be pretty hard until someone releases an exploit kit, and then pretty easy after that.
Re:Reading privileged memory with a side-channel by contrarian_ on Thursday January 04, 2018 @06:13AM (#16069440)
It's an arms race, there will always be new ways of exploiting this flaw in unexpected ways unless speculation is disabled entirely on existing CPUs.
Re:Reading privileged memory with a side-channel by user5994461 on Thursday January 04, 2018 @02:16AM (#16068595)
They say they can reliably read memory around 120kB/s with one vulnerability and 1kB/s with the other. It just works, all the time. Some of the PoC takes a few minutes to initialize.

I'd say difficulty level is easy.

Re:Reading privileged memory with a side-channel by Certhas on Thursday January 04, 2018 @07:00AM (#16069681)
However, only one of the PoCs runs on AMD, and that doesn't cross process boundaries.

So how easy is it to turn that PoC into something I should worry about? Seems like browsers are the most affected by this scenario, but that also means harden the browser (separate process per page) and it might be difficult to exploit.

Re:Reading privileged memory with a side-channel by lrem on Thursday January 04, 2018 @07:52AM (#16069946)
As a general rule of thumb, if everyone already has a PoC, you should assume someone has been doing targeted practical attacks for a while.
Re:Reading privileged memory with a side-channel by Avamander on Thursday January 04, 2018 @06:08AM (#16069412)
Difficulty to exploit is easy once you have the exploit running. Writing a new exploit is really hard, otherwise we wouldn't be starting 2018 with these news.
Re:Reading privileged memory with a side-channel by FranOntanaya on Wednesday January 03, 2018 @09:45PM (#16067588)
It doesn't look that hard, and in any case, we will suffer the mitigation consequences either way.
Re:Reading privileged memory with a side-channel by contrarian_ on Thursday January 04, 2018 @06:13AM (#16069445)
Worse, no mitigation will ever be complete against Spectre, unless flat out disabling speculation across memory loads.
Re:Reading privileged memory with a side-channel by wilun on Friday January 05, 2018 @11:28PM (#16083853)
With the right new instructions inserted at the right place, assisted by a good type system, and a processor that does not share its resources like crazy in highly uncontrolled ways, this seems fixable.

Sadly, I feel the only part that won't happen will be the programming language part, but who knows.

Re:Reading privileged memory with a side-channel by olliej on Thursday January 04, 2018 @12:11AM (#16068207)
it isn't. There have been a few PoC referenced on twitter, and the spectre paper itself reference a PoC in browser hosted javascript (e.g. random ad can scan memory)

it's obviously not a free + zero time activity, but I'm going to assume someone making an ad to scan memory isn't super concerned about end user cpu usage or battery life..

Re:Reading privileged memory with a side-channel by binarycrusader on Wednesday January 03, 2018 @10:27PM (#16067807)
"Spectre" is very bad news and affects all modern CPUs

It's not yet clear whether it affects all modern CPUs, notably I have yet to see any mention of modern POWER/MIPS/SPARC-based designs. If someone has pointers, those particular cases would probably be quite interesting.

Re:Reading privileged memory with a side-channel by cthalupa on Wednesday January 03, 2018 @10:58PM (#16067936)
https://access.redhat.com/security/vulnerabilities/speculati...

Additional exploits for other architectures are also known to exist. These include IBM System Z, POWER8 (Big Endian and Little Endian), and POWER9 (Little Endian).

Re:Reading privileged memory with a side-channel by pizlonator on Wednesday January 03, 2018 @10:39PM (#16067859)
It affects CPUs that do speculative execution. Pretty sure some powers do.
Re:Reading privileged memory with a side-channel by binarycrusader on Wednesday January 03, 2018 @11:17PM (#16067998)
I wonder to what degree some systems are affected. I believe Solaris already uses separate address spaces on SPARC for user and kernel. I haven’t looked over the SPARC architecture manual to see if they allow speculative execution beyond privilege boundaries.
Re:Reading privileged memory with a side-channel by olliej on Thursday January 04, 2018 @12:08AM (#16068188)
That only prevent reading over higher privilege (the meltdown vulnerability) it doesn't protect the arbitrary user land reads from spectre.