6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Sep 28, 2024 9:26 am

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Tue Nov 15, 2016 8:38 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
An amusing security compromise is explained at
https://scarybeastsecurity.blogspot.co. ... sktop.html

The root cause is lazy and unsafe (or, high performance!) coding of banked ROM emulation in a NES emulator, which is, rather surprisingly, made widely available as part of a music playing library.

As noted in the article:
- 6502 is fun!
- there are many ways the risk could be removed or reduced by better system-level configuration choices
- there's really no need for such a niche capability to be installed so widely, especially based on a library known to be of indifferent quality
- the library need not have such unsafe coding in the first place

(via Kam-Yung Soh on gplus)


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 15, 2016 3:18 pm 
Offline

Joined: Thu Jun 04, 2015 3:43 pm
Posts: 42
Thanks for sharing, that's a really cool exploit.

The part at the end about 6502 code as a "scripting language" and the prevalence of various languages in all sorts of places you wouldn't expect makes one think. There has to be an enormous attack surface here that gets little scrutiny.

I wouldn't expect that security is the top priority for many people, and allowing one's language or bytecode to poke around in memory is something that probably gets added for debugging reasons whether the application needs it or not.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 15, 2016 3:59 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
I suspect security is the bottom priority!

I don't think the problem is usually that the scripting language intentionally gives too much access to the system - it's that when there is some tiny defect in the language or a library which allows even a single byte to be written when it shouldn't, it's the scripting language which gives the leverage to use the defect to make a full exploit.

How tiny a defect? Even a single character overflow, even if it's always just a '1', might be exploitable!
https://daniel.haxx.se/blog/2016/10/14/ ... n-exploit/


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 15, 2016 4:42 pm 
Offline

Joined: Thu Jun 04, 2015 3:43 pm
Posts: 42
Sounds interesting, I will check that out.

Since we're already off topic, my favorite is this clever attack against a Java VM that assumes no conventional write access at all:

Using Memory Errors to Attack a Virtual Machine (PDF, sorry)

It works by allocating lots of objects in a way that basically fills memory with special bit patterns, and then waits for an external event to cause a single-bit memory corruption which it can exploit to get general write access. In their experiments, they were able to make it work using heat:

Quote:
We found a gradual rise in temperature in the region of 80-100° Celsius would cause isolated, random, intermittent soft failures in the memory. As section 5 explains, we expected that if we can induce isolated errors, the probablility of a successful attack on the IBM JVM before the machine crashes is 71.4%.

This heat attack was successful against both the IBM and Sun JVMs. It takes about one minute to heat the memory in a successful exploit. In about 15 trials against the IBM JVM the proportion of successful attempts was approximately consistent with the predicted probability of 71%.


All typos mine. The entire thing is worth reading, the paper is written in a pretty clear style.


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 15, 2016 5:07 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
Ah, these days you don't even need heat! It turns out a lot of RAMs are vulnerable to bitflips caused by adjacent rows being flipped. It's called rowhammer. Even ECC doesn't save you - just makes it a bit harder. See for example
https://events.ccc.de/congress/2015/Fah ... /7197.html
where it turns out even a JavaScript program in your browser can provoke a disturbance and exploit it gain control of your machine. (Again, this is not a problem with JavaScript the language, or with the interpreter, rather it's a problem of leaky abstractions. Ideally your browser sandboxes each tab's activity, your OS implements protection between processes, and your memory acts like a memory ought to.)


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 15, 2016 5:58 pm 
Offline

Joined: Thu Jun 04, 2015 3:43 pm
Posts: 42
You don't need heat for the JVM attack either, that was just the mechanism they used to speed up the process; the shocking aspect of it is that in theory the same attack should work without any physical access or leaky abstractions if you can just leave it for long enough to have a stray cosmic ray do its thing. Or a more practical approach, spread the exploit code to lots of machines and let the 0.01% on which it succeeds report back.

Rowhammer certainly did come up a lot in the first twenty tries to find an URL for the JVM attack though! :-)


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 15, 2016 6:04 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
I do recall that JVM research - it was remarkable that a single random bitflip could be exploited. As you say, could be parallelised too. But rowhammer changes the game somewhat. I suppose, as you say, even if and when RAM production is much less vulnerable to that, there will always be subatomic upsets to deal with.


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 16, 2016 9:24 am 
Offline

Joined: Sun Apr 10, 2011 8:29 am
Posts: 597
Location: Norway/Japan
I wonder if an approach using a dual RAM setup would protect against this. Or ideally, triple RAM. Use the two RAM sections that agree with each other, if no agreement, handle as RAM error. Maybe there should also be subtle differences in how this is set up, with either different RAM technology, or RAM placed so that there would be significant temperature differences.


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 16, 2016 9:30 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10938
Location: England
I think the combination of ECC and more robust RAM technology should do it. I gather some brands and some models of RAM are (or were) more vulnerable to RowHammer. If ECC makes corruption one or two orders of magnitude less likely to be effective, that's significant.
I suppose it's also true that the application (or even OS) could add some checking code. (Indeed, I'm reminded of NetApp hard drives, which have (or had) custom firmware putting an extra CRC on every data block. In this case a sector holds 520 bytes.)
Defence in depth!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 33 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: