8 ms·
Are passwords stored in memory safe?
- jayfuerstenberg 14y agoAll you can do if you don't trust the OS is to assemble the password at the point of use (each time) and erase the memory location directly afterwards. And even that is not 100% foolproof (the OS can detect it in between these two steps).
- mariusmg 14y agoOr keep it encrypted in memory
- ars 14y agoAnd how exactly would that work? You would need to decrypt it use it - but then you need to store the decryption key in memory. Gaining you exactly nothing.
- lucb1e 14y agoYou could store the decryption key on the disk, only loading it when needed, and possibly byte-by-byte. This is all hackable, especially when such techniques are used mainstream, but it increases the amount of work needed to hack something. In the end it's the OS's responsibility of course.
- ars 14y agoWhat's the point of that? If you are going to do that, just store the original key that way. Not that it helps in any way at all.
- biot 14y agoThe .NET framework has a SecureString class which does this. It mitigates the risk of sensitive information being discovered through running 'strings' on memory dumps and the like. It's meant to prevent trivial recovery, not stop an attacker with sufficient time and skill.
- mariusmg 14y agoHere is a concrete implementation : SecureString in .NET http://msdn.microsoft.com/en-us/library/system.security.securestring.aspx http://msdn.microsoft.com/en-us/library/system.security.secu... It's using DAPI which derives the encryption key from the user password.
- jayfuerstenberg 14y agoYou wouldn't need to encrypt it really. Just don't store it character for character the same as the password when used to authenticate the user. You could have the even characters in one array and the odd characters in another and this would make it a bit safer. I'm not sure every app needs to be this paranoid but I offer it as an idea that can be easily implemented for those that do.
- ibotty 14y agoand how should that help? if you can read ram you can for sure read the executable file.
- twelvechairs 14y ago> Just don't store it character for character the same... You've just described encryption here, whilst saying that its not encryption. The principle is right though. A simple obfuscation will deter most attacks.
- ibotty 14y agothat was good!
- Tichy 14y agoAlso, is there a way to erase specific memory locations, and a guarantee that in the meantime that memory location has not been cached somewhere else?
- InclinedPlane 14y agoIf you can't trust the OS you're screwed regardless. If you are concerned about physical access based attacks (like cold boot) then there are alternatives. Here's some interesting reading: http://en.wikipedia.org/wiki/TRESOR http://en.wikipedia.org/wiki/TRESOR
- zurn 14y agoIf the OS is actively plotting against you, it's a losing game, but if it's just security-oblivious then there may be some things you can do mitigate. Consider for example, an OS with a habit of writing out random parts of your process memory onto disk.
- derefr 14y agoHere's a question I've been pondering: suppose you are a program delivered from an origin (trusted) to a client machine (untrusted.) You start without any credentials, but you have the option of dialing out and asking the origin for a shared secret (e.g. a private key.) Is there any useful way for the origin to require that you, the delivered program, prove that the client machine you're running on can be trusted with the shared secret? If it's possible at all, I'm guessing it involves a "secure boot" with a TPM chip.
- kefka 14y agoWhy would I want a machine, which I own, trust someone else than the owner? And no, I do not trust the TPM in its current iteration. We mere owners are prevented from knowing its private key. Nor can we generate and store away a private key (or buy a known private keyed chip).
- derefr 14y agoSo you can, for example, participate in a distributed computing project where the results sent in by your machine can be trusted. (An online game that calculates physics client-side is a special case of a distributed computing project ;) It doesn't require you to give up ownership over your entire computer, mind you. If your own OS ran in a hypervisor that was in one TPM "domain" (you have the key to this domain), but then applications could request to be run directly on the hypervisor with a separate TPM domain (and thus keep keys your own OS wouldn't ever be able to touch), that'd be good enough to allow for any secure distributed computation you might want to do. At any time, you'd still be able to wipe out those domains (and thus kill the apps running in them)--but you wouldn't be able to otherwise introspect them. Basically, it's like the duality of "OS firmware" and "baseband firmware" on phones--except it would all be being handled on the same real CPU.
- thomas-st 14y agoIs it possible that a (non-privileged) process could read data of a process that has previously terminated by looking at uninitialized memory and gain access to sensitive information that way?
- FooBarWidget 14y agoMost operating systems clear the ram pages when the process exits, or when it requests a page, so no.
- deleted 14y ago[deleted]
- FooBarWidget 14y agoOne method that I've thought about in the past is hashing your password using bcrypt, then zero and free the original password, and check all future authentication attempts against the bcrypt hash. Nobody, not even you, knows the password now, just whether a given password is correct.
- Mahh 14y agoHashing passwords for storage is standard practice in all systems that involve password based authentication. Even then, the password must reside in memory at some point in order to compute the hash of your password [using bycrypt or whatever scheme], which is necessary for both generating the hash the first time AND generating the hash for authentication attempts. This is the issue described in the given link. http://en.wikipedia.org/wiki/Cryptographic_hash_function#Password_verification http://en.wikipedia.org/wiki/Cryptographic_hash_function#Pas...
- mappu 14y agoOf course. But just using hashes doesn't mean you're safe - watch out for pass-the-hash and replay attacks, as well as session hijacking and other possible side channels.
- ars 14y agoThe question is about storing the password for you to authenticate to somewhere else, not the reverse. Storing a hash doesn't help because the remote site won't accept it. And if it did then the hash is essentially the password and you've violated the goal.
- qompiler 14y agoFor this reason the Java JPasswordField getPassword() method returns an array with no other copies around. An array can also easily be zero'd out with fill(). http://docs.oracle.com/javase/tutorial/uiswing/components/passwordfield.html http://docs.oracle.com/javase/tutorial/uiswing/components/pa...
- viraptor 14y agoIsn't JRE using compacting GC which makes the "no copies" guarantee void anyway?
- TheAnimus 14y agoBeen a while since I've done java, but I'd assume it simply pins it?
- RyanZAG 14y agoThe char or int datatypes do not have their values stored as objects. When you change the value of a char inside a char[] array, that value is directly changed in ram. This will leave the "hello" in ram (subject to GC): String x = "hello" x = null; This will clear the "hello" from ram: char[] x = new char[]{'h','e','l','l','o'}; x[0] = '0'; x[1] = '0'; ... This will leave the "hello" in ram (subject to GC): char[] x = new char[]{'h','e','l','l','o'}; x = null;
- ygra 14y agoThe point was about the garbage collector compacting memory regions, thus moving objects around. If you don't pin your array it could leave "hello" somewhere in memory when it's moved before you zero it.
- DanBC 14y agoThere are attacks on passwords stored in RAM. There's an example against the Apple keychain. Root can run the software and it collects a bunch of passwords for logged in users (http://juusosalonen.com/post/30923743427/breaking-into-the-os-x-keychain http://juusosalonen.com/post/30923743427/breaking-into-the-o...) But there are best practices for passwords, and those reduce the risks; and most attacks need privileges and access to the machine, which again reduces the risk. If you're worried about stormtroopers kicking the door down and squirting liquid nitrogen on the RAM you probably have enough money to have very strong perimeter defences.
- StavrosK 14y agoWhat does liquid nitrogen on the RAM do? I was under the impression they plugged the computer into a UPS or something and took it.
- ygra 14y agoThe bits stored in DRAM remain readable for a time (sometimes minutes) even after the power is cut. In normal operation frequent refresh is needed to avoid decay the decay doesn't happen nearly as fast as the refresh cycles make it seem. Cooling the cells lengthens that time, from minutes up to hours (depending on the temperature), permitting an adversary to read them without much time pressure. Paper on that: http://citp.princeton.edu.nyud.net/pub/coldboot.pdf http://citp.princeton.edu.nyud.net/pub/coldboot.pdf
- StavrosK 14y agoI see, thank you very much.
- pfortuny 14y agoIt freezes the circuits and prevents them from being discharged. When removed from the fridge, the attackers have some extra time (while thawing) to read the status of the RAM.
- DanBC 14y ago
- Murk 14y agoAt the company I worked for previously we frequently used a firewire DMA attack such as inception (http://www.breaknenter.org/projects/inception/ http://www.breaknenter.org/projects/inception/) to gain access to computers, and dump ram to recover other passwords.
- mappu 14y agoI'm familiar with DMA attacks, but it's always shocking to see publicly available GPL code that just works against popular and recent versions of windows, OS X and linux. UEFI Secure Boot is no help if you signed a 1394 driver : ) Everyone should read the mitigation steps and caveats as appropriate. If you have physical access to an unlocked windows machine, i'd reach for mimikatz. Instant plaintext.
- icebraining 14y agoSmart cards can move the private key from the PC to a dedicated, self-contained and (supposedly) safer machine - the card itself.
- DanBC 14y agoI'm worried that the smart cards and their software is well designed, but then you have to rely on other vendors to do thier bit securely. Fravia said of dongles that they were often great, with nice libraries, but when software vendors implemented them they would use stupid methods. (http://home.scarlet.be/detten/tuts/dongle_zeezee.htm http://home.scarlet.be/detten/tuts/dongle_zeezee.htm) > Don't panic when you read all info about dongle security. They ARE secure. OK. You can't crack them unless they're done by complete idiots. OK. But you want to crack the application, NOT the dongle. When you read about RSA encryption, one-way functions and see in the API some interesting Question/Answer hashing functions, remember that it's only API. No one uses it. Only simple functions like Check/Serial Number/Read and sometimes Write are used.
- rdl 14y agoThe long-term solution is probably some kind of super-smartcard (essentially an HSM) which can put per-application logic inside the secure envelope. Things like rate limits on decryption requests, heuristics to require higher levels of authentication as transactions are more suspicious, etc. Combine that with per-application virtualization and various forms of user authentication (other than passwords), and public key cryptography, and you could probably start to build substantially more secure services. Same stuff on clients and servers. ARM's TrustZones are actually more interesting than TPMs on x86; you can essentially start the general purpose CPU as a trusted device and then partition off less-trusted pieces. If you're going to have a single processor, vs. a specialized security processor, this is probably how to do it, not the x86 + TPM + TXT way. Probably all meaningless until there's a framework as simple as Ruby on Rails was vs. everything else in 2005, or php, which makes doing things securely the easy default.
- amadvance 14y agoThere are well known attacks that allow to read memory, and even write, thought DMA. See for example: 0wned by an iPod - hacking by Firewire http://md.hudora.de/presentations/#firewire-pacsec http://md.hudora.de/presentations/#firewire-pacsec More papers are linked in the wikipedia page: http://en.wikipedia.org/wiki/DMA_attack http://en.wikipedia.org/wiki/DMA_attack
- eaxbin 14y agoRandom Access Memory Memory?
- RKearney 14y agoIt's where ATM Machines store their application code while running.
- FourthProtocol 14y agoReading comments here and on stackexchange I'm surprised that no mention is made of the Data Protection API (DPAPI) on Windows, which is designed specifically for this purpose. http://msdn.microsoft.com/en-us/library/ms995355.aspx http://msdn.microsoft.com/en-us/library/ms995355.aspx I've been using it for years, and while nothing is infallible, any sensitive plain text in my apps isn't there for more than it takes to encrypt and then destroy. I can't comment on Linux or OSX but would be surprised if the OS didn't offer a similar API tied to the principal to protect in-memory data.
- laumars 14y ago> Reading comments here and on stackexchange I'm surprised > that no mention is made of the Data Protection API (DPAPI) > on Windows, which is designed specifically for this purpose. It was mentioned and quickly dismissed as not being effective: 1) if it can be decrypted by the API, then it can be cracked by any process given enough time and resources. 2) further to point #1, the Data Protection API was reversed engineered in 2010. 3) security is only as strong as your weakest link, and that API doesn't address the "weakest link" of running malware locally. eg it's much easier to keylog passwords to begin with than to scan the RAM. I'm inclined to agree with those comments. While that API is a nice idea, I think it's a little ineffective in practice.
- FourthProtocol 14y agoCan't find anything online about a fix from Microsoft (didn't give it much effort - little pressed for time), but it seems that decryption is possible because the master key timestamp isn't protected by an HMAC mechanism (perpetuating access to the secret). Also, all the user's previous SHA1 hashes aren't salted. Both of those seem easy enough to fix, which I imagine Microsoft has done (the exploit was discovered 3 years ago). I'm going to do a little more research when I have time. Lastly, and importantly, this attack is an offline attack. I wasn't able to find anything that compromises in-memory data. Granted, nothing other than 2FA will protect anyone (or DPAPI) against key loggers, but that's true for all OSs. If local malware is the strength of the argument against DPAPI then I might as well go so far as to say that the most secure system is no system.
- wslh 14y agoNo, I found a password in the pagination file of an old Windows.
- surferbayarea 14y agoHere's what I do. The login page on my browser is sent to my phone which creates a https session with the remote website and then hands over the session back to the browser. The mechanics to do this are a bit tricky but like a few days of coding. The advantage: your password never ever enters your computer's RAM(or HDD/network)...take that keyloggers!
- alanctgardner2 14y agoWhat about phone malware? And what stops someone reusing the https session as you move it from your phone to your desktop?
- diminish 14y agohey security experts, are microprocessor registers or cache, subject to any security attacks?
- zokier 14y agoMaybe some timing attacks would be the closest thing to CPU cache based attack.
- dfox 14y agoIt depends on whether you consider attaching JTAG ICD and just reading whole state of CPU out an security attack. In some aspects just attaching an ICD to desktop CPU is simpler than attacks on physical security that involve freezing DRAM chips and reading their contents with patched BIOS or whatever. On the other hand it mostly requires attacker to have JTAG ICD that supports that particular CPU. Almost all x86 chips have some kind of ICD interface, usually very low-level and complete one. But because of low level nature of registers you see through it, JTAG register maps and so on are NDA-only and thus ICDs that support non-embedded CPUs tend to be very rare and in the realm of "you can't afford it if you have to ask the price". But they exist and buying one is more about the price than about any questions of the kind "why do you need that?". But because of rarity of these things most current research simply ignores this attack vector. Bottom line: there is no such thing like security against local attacks on almost any kind of commodity hardware (including TPMs, excluding devices explicitly designed to be reasonably secure like gaming consoles). When you need that you also need proper tamper-proof hardware.
- mje__ 14y agoPower analysis can also be used if you can force the CPU to do work on the key/password. It's been used to extract key material from smartcards edit: finish the sentence
- niggler 14y agoThis is why ssh-agent is awesome: they don't hold the passwords in memory (only the keys) so you minimize the number of times you type password and the number of places it is stored.
- _cbdev 14y agoA quick CTRL+F didn't find anything, so I might actually be the first to point out that "RAM memory" is a case of the RAS Syndrome :) http://en.wikipedia.org/wiki/RAS_syndrome http://en.wikipedia.org/wiki/RAS_syndrome
- deleted 14y ago[deleted]
- yxhuvud 14y agoSafety is a float - not a boolean. A more appropriate question would have been: 'How safe is it to store passwords in memory?'