News for hackers. Stuff that matters.
Re:How to zero a buffer by tedunangst on Thursday September 04, 2014 @08:05PM (#8271482)
I'm not aware of any language that would be better. Most languages don't even let you touch memory to try to zero it.
Re:How to zero a buffer by userbinator on Friday September 05, 2014 @01:13AM (#8272426)
There's basically only one (or a family of) languages that have no optimisation at all, and enable complete control over what the machine does - Asm. The code you get is exactly the code you write, no matter how efficient or inefficient it is. This also enables much better the prevention of other attacks like timing/power analysis, since you can effectively insert dummy instructions as needed to keep the timing and power well-behaved.

The biggest downside I see is that it's non-portable, but the reality is that there's not all that many architectures out there to port to anyway (x86, ARM, MIPS probably covers 90%+) and for truly security-critical code having that level of control could be worth it. (This also avoids the "trusting the compiler" problem - an assembler is far easier to verify correctness of than even the simplest C compiler...)

Re:How to zero a buffer by dllthomas on Friday September 05, 2014 @01:43AM (#8272493)
"There's basically only one (or a family of) languages that have no optimisation at all"

... sort of. Chips themselves perform some optimizations.

Re:How to zero a buffer by schoen on Friday September 05, 2014 @12:30PM (#8274779)
I think I heard of a timing attack that was introduced by CPU optimizations, not in the underlying code at all! But I can't remember what research that was and maybe I'm confusing two different issues.
Re:How to zero a buffer by dllthomas on Friday September 05, 2014 @01:08PM (#8274993)
Certainly plausible. If the CPU optimizes one path but not another, in principle that's some information. In practice, gathering enough data to get that above the noise floor and turning it into something useful besides would certainly be difficult but maybe not too difficult.
Re:How to zero a buffer by schoen on Friday September 05, 2014 @03:30PM (#8275837)
I might be thinking of some of the cache timing issues about sharing physical hardware with other guest VMs. There were papers in the last two years showing circumstances in which another VM on the same device can learn about secrets in caches via timing experiments. But that's a cache issue rather than a general pipeline issue. So I still can't remember if there's something else that I'm thinking of or if I'm just confusing it with the cache stuff.

http://blog.cryptographyengineering.com/2012/10/attack-of-we...

More recent stuff in this vein:

https://eprint.iacr.org/2014/435.pdf

(Yikes!)

Re:How to zero a buffer by TheLoneWolfling on Friday September 05, 2014 @07:15PM (#8276800)
Well, the most obvious form of that is cache.

There's a entire class of timing attacks that rely on the CPU cache - they would not exist if CPUs didn't do the optimization of storing local copies of limited sections of RAM.

Re:How to zero a buffer by bunderbunder on Thursday September 04, 2014 @08:56PM (#8271728)
A language that wouldn't give you a way to zero out data wouldn't be appropriate for security-critical tasks either.

Just like how a language that doesn't do array bounds checking and permits pointer math (read: a language where buffer overflows are a damn feature) isn't appropriate for security critical tasks.

Just like how a language that must be actively fought using clever hacks in order to prevent it from undermining your attempts to guard against common exploit vectors isn't appropriate for security critical tasks.

Re:How to zero a buffer by ufo on Thursday September 04, 2014 @09:18PM (#8271813)
Zeroing out an array or struct field is not a C-specific feature.
Re:How to zero a buffer by tedunangst on Thursday September 04, 2014 @09:52PM (#8271925)
Dead store elision is not a C specific optimization.
Re:How to zero a buffer by jacksingleton on Thursday September 04, 2014 @11:39PM (#8272206)
This is what Mozilla is trying to create with Rust

http://www.rust-lang.org/

Re:How to zero a buffer by swift on Thursday September 04, 2014 @08:33PM (#8271638)
Many languages zero every allocation unless they can prove that you immediately write over that memory without reading it.
Re:How to zero a buffer by marvy on Thursday September 04, 2014 @08:48PM (#8271699)
Yes, but that's going the wrong direction. The situation here is that you've already written over it, and now wish to erase what you wrote.
Re:How to zero a buffer by tedunangst on Thursday September 04, 2014 @08:47PM (#8271690)
Which does nothing for memory which has been freed but not reallocated.
Re:How to zero a buffer by swift on Sunday September 07, 2014 @02:05AM (#8280453)
That's a great point; should've thought through that post a little better. Thanks.