Security (protected memory)

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
disclaimer: I'll probably edit this later, but I wanted to write it out before I forget ;)

When a program is running, it is sitting somewhere in memory (ram, unless it got paged to disk). If memory wasn't protected, I could just read its data, and be done. However, with "protected" mode, I still think there is a security problem (at least the way I understand it).

The goal is to read each person's password as he logs in. For simplicity's sake, say init, login, and CThos_exploit are the only things running (plus whatever you would need to get another console for the victim to log in on). From one process it is impossible to address the memory of another process, in theory. CThos_exploit would allocate however much physical ram is available on the computer (just for simplicity. This might work with less, or more depending on how swap works). It then goes through and reads ALL of it, looking for where the login binary and data is loaded.

The first reaction is "you can't read login's memory". But I didn't. Assuming login is in physical ram at the time, it will get paged to disk assuming I poke around my own memory enough to make sure it stays in ram until a context switch. At that point, login is now on the disk, and the physical ram it USED to occupy is mine.

Since I read it in without overwriting that memory with my own data, I should be able to read in the login binary, and from there, determine relatively where its data is. Assuming it was within the same page, it should be trivial from there to read passwords as they are entered. If it was in a different page, this would be difficult (or impossible) since I don't know where that maps to in physical ram. I would guess, though, that login's other data (such as the string "login:" and "password:") would be in the same pait was in a different page, this would be difficult (or impossible) since I don't know where that maps to in physical ram. I would guess, though, that login's other data (such as the string "login:" and "password:") would be in the same page as the password buffer.ge as the password buffer.

What did I get wrong? Admittedly, doing this would be very slow (probably causing a noticeable slowdown in the victim system), and it is entirely possible (very likely) that some other app would overwrite the physical memory first, but that still does not make a system totally secure from such an attack.

edit: see how good it is knowing only half the story about a lot of stuff? ;)
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
It did occur to me that when you page something to disk, you could just zero-fill the physical memory, which would have a minimal performance hit relative to the disk I/O, but based on the fact that uninitialized int's in C dont start at zero, that doesn't appear to be the case (at least in windows)
 

Shalmanese

Platinum Member
Sep 29, 2000
2,157
0
0
Or you could just store the password as a hash in memory rather than plain text which makes this now a trivial problem.
 

Peter

Elite Member
Oct 15, 1999
9,640
1
0
The difficult part would be to identify the login binary and its data in that HUGE mess of unknown garbage. Hardly feasible, even if you know what login's memory footprint looks like, as the paging algorithm might have hacked it into tiny little pieces and scattered them all over the place.
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
Originally posted by: Peter
The difficult part would be to identify the login binary and its data in that HUGE mess of unknown garbage. Hardly feasible, even if you know what login's memory footprint looks like, as the paging algorithm might have hacked it into tiny little pieces and scattered them all over the place.

Agreed. But that doesn't mean it can't be done, right? I think it wouldn't work over 90% of the time, and would be extremely slow.

Shalmanese - I dont think so: as it is typed in, at SOME point it has to be plaintext. I mean, maybe you could MD5 as you go (I don't think you could - you cant add to it as you get each character), but there is a time between keypress and MD5 where the plaintext is available.

What kind of performance hit would it be to clear the physical memory when it gets paged to disk?