The worse is that this error only happens because we are trying to save 4 bytes. If all arrays would also store their own size we could eradicate this bug with a limited memory impact.
What!? Size of the array is always known to the programmer in C. In fact, if the programmer wants to get rid of that information, he/she must deliberately do so. Once one does that, the array becomes useless. You also haven't explained how would that size information, which we already have, magically solve the problem.
How security flaws work: the buffer overflow
21–30 of 48 posts
Re: How security flaws work: the buffer overflow
#22One of the best explanations ever written is the now classic "Cult of the Dead Cow issue #351 - The Tao of Windows [NT|95|98] Buffer Overflow" @ http://www.cultdeadcow.com/cDc_files/cDc-351/
20 years later and we're still using C++. I hope Rust takes off. The status quo today is terrible.
Re: How security flaws work: the buffer overflow
#23Earlier quoted context omitted.
You have overlooked the CPU cost. Given that most memory objects already have at least an over-approximate size somewhere , and how we are more than happy to annotate stacks with canaries, I really don't think anyone is as concerned with the memory cost of adding a size to every array as the CPU cost of adding a read and compare to every array access.
Intel is adding hardware array bounds checking called MPX in skylake, so this could become a reality.
Re: How security flaws work: the buffer overflow
#24Are "buffer overflows" possible in systems without without virtual memory? I know how I would answer this question but I am curious how others would answer it. EDIT: s/possible/known to occur
Re: How security flaws work: the buffer overflow
#25Earlier quoted context omitted.
You have overlooked the CPU cost. Given that most memory objects already have at least an over-approximate size somewhere , and how we are more than happy to annotate stacks with canaries, I really don't think anyone is as concerned with the memory cost of adding a size to every array as the CPU cost of adding a read and compare to every array access.
I think that the CPU cost could be reduced if the CPU had some kind of instruction for array access: if you 'hardcode' that an 'array' has its address stored in register Rx and its length stored in Rx+1, you can easily have an instruction " checked_load Ry " this instruction can have a latency similar to a normal load instruction as it could check the value of the index with Rx+1 in parallel to the load (1). And if y…
When I was in school, my professor for CPU Architecture had a good saying: "If you're going down to NAND gates to debug your software you're doing something wrong".
I think another issue is that arrays, trees, and other structures are a complete abstraction. The CPU doesn't need to know a thing about them for them to work, because all it actually sees is addresses and instructions (I get that I'm grossly oversimplifying things), and so introducing that type of "check" at the hardware level is pushing the abstraction down, and I don't think that's a good idea either.
But I do think that's one of the great reasons for using a higher level language, where there are array bounds checks, etc.
To me, C/C++ is like "pretty" assemby language (Now with new features like Undefined Behavior!!!), and I like that about it. But I'm not sure how other people feel.
Anyways, that's just my take on it, take it with a grain of salt.
Re: How security flaws work: the buffer overflow
#26One of the best explanations ever written is the now classic "Cult of the Dead Cow issue #351 - The Tao of Windows [NT|95|98] Buffer Overflow" @ http://www.cultdeadcow.com/cDc_files/cDc-351/
>but if you don't have automatic bounds checking like Java, I guarantee you that those 'A's are going somewhere unfortunate. 20 years later and we're still using C++. I hope Rust takes off. The status quo today is terrible.
Re: How security flaws work: the buffer overflow
#27There were so many critical vulnerabilities attributed to that... and in spite of putting tons of measures this is still potential danger. I knew projects decided to use Java instead of C++ (which got array boundary checks) mostly to limit security surface. Maybe if we could start CPU architecture from scratch, array with sizes would make more sense? Maybe even we could done it so memory segmentation would no longer…
Rust is obviously a great example. So is Go. Bounds checked arrays in languages that compile to native is not a new thing.
Re: How security flaws work: the buffer overflow
#28Are "buffer overflows" possible in systems without without virtual memory? I know how I would answer this question but I am curious how others would answer it. EDIT: s/possible/known to occur
As long as you have the ability to address memory directly, I would say that it's possible. I'm not 100% sure about how memory is allocated though. Outside of virtual memory, are the actual chunks of memory sequential, or would overflowing an offset get you a chunk of another process? (I imagine the answer might be implementation dependent)
Re: How security flaws work: the buffer overflow
#29Re: How security flaws work: the buffer overflow
#30Alternatively (just the concept, this should not work as outlined on modern systems): http://phrack.org/issues/49/14.html
Not the best data point, but showed pretty quickly who had a self-taught (and usually practical) understanding of security vulnerabilities vs an academic understanding.