Slashdot Mirror


Are Buffer Overflow Sploits Intel's Fault?

Bruce Perens submitted a story he wrote for his website on overflows and who's fault they are. I'm pretty skeptical of almost every point raised in this story, but it's an interesting read. [Updated 21:13 by t] As Sea Monkey points out, Bruce has now taken down the article, with a brief note: "I've withdrawn this article after enough people convinced me that I didn't know what I was talking about. It happens sometimes. Thanks." What if everyone displayed such grace?

269 comments

  1. Re:Its not intel's fault(history) by mikpos · · Score: 1

    People could very well start using segmentation again without so many horrors. The problem before was that the segments had a size of 64kB, whereas the total RAM was measured in the megabytes. With the 386, the address space of the segments was the same as the address space of the entire machine. So using segments isn't terribly different from just using straight pages. You need 15MB on the stack? Not really a big problem. Therefore, there should be no worries about changing segments all the time, because all your data is in one segment.

  2. Re:Why do people still program in C? by Zurk · · Score: 1

    I normally code in Java..but for Linux/UNIX coding you *have* to use C. why ? because C doesnt require overhead (support files for VMs etc like Java). C programs are standalone. C can be recompiled for any architecture. C is FAST. C is SMALL. C can use 100% of your CPU and memory without bothering about overhead. C can manipulate strings faster than any other language. Allocation of arrays and storage space in C is trivial. Looping thru arrays is blazingly fast. C has curses based screen manipulation. C can have inline assembly for those REALLY tight ops.
    In short - Performance, Portability, Control, Simplicity.

  3. Wrong on almost all accounts. by bkosse · · Score: 1

    Please don't moderate up his post despite sounding good. It's almost entirely wrong.

    Doesn't matter how many times I recompile, bud. Sorry. That's kindof a moot point. Look at all the different distributions which use different compiler sets and different optimization parameters and all of them end up getting bit by the same bug. A recompile, if you're lucky, will prevent some exploits from being effective, but that's because of bad exploit writing.

    There's also nothing to prevent the MacOS from executing a buffer overflow. You have relocatable code, just like everyone else. Almost all successful exploits rely on offsets, not absolute addresses (because those can change on a reboot, not even a recompile).

    Finally, internal datatypes and bare pointers are neither necessary nor sufficient for buffer overflows. For starters, there are languages and platforms without internal datatypes and with bare pointers that can't (assuming you don't trip a bug in the language itself) result in an exploitable buffer overflow because of other protection systems. Second, there is always the possibility to trip a bug in the compiler/interpreter which results in an executable buffer overflow in a language where it shouldn't be possible.

    I will agree that it will, almost entirely, go away if we used pointer-free languages, but unfortunately, in many cases (i.e. an OS kernel) that isn't particularly attractive to do.

    --

    --
    Ben Kosse
    Remember Ed Curry!
  4. spelling by The+Step+Child · · Score: 1

    Bruce Perens submitted a story he wrote for his website on overflows and who's fault they are.

    "Who's" is possessive. It should be spelled "whose"

  5. Re:Blame the CHIP? Blame the LANGUAGE? Pfah! by Raven667 · · Score: 3

    I disagree with this, making it the developers responsibility to write bounds checking code every time they deal with input is why we are in this mess today. Not a week goes by without annother buffer overflow sob story on Bugtraq. Asking software developers never to make any mistakes, ever, is not a realistic solution and assigning blame isn't going to make the problem go away.

    There are a few possible solutions, none of them really easy.

    1. Change the libraries to always do bounds checking on all functions. This would break most current software and still wouldn't solve problems inherent in language. It would still be possible to write insecure code if you decided to shoot yourself in the foot, or the libraries were used in new and unusual ways.
    2. Change the language to one that is type safe. This probably won't realistically happen any time soon but Java is making some inroads in popularity. Other languages, especially the LISPy ones, will probably never be popular, but who knows? Still doesn't fix old software, or programmers who refuse to learn.
    3. Change the OS with something like StackGuard. Will break much existing software and OS implementations, and there are still many ways around it for creative programmers. This is just a patch that doesn't solve the inherent problems of writing insecure code.
    4. Change the hardware platform. Certain platforms make it much easier to create safe code, and protect you from some nastiness. This might work, and for legacy, current and future software but isn't an area I am much familiar with so I don't know all the implications. It should be pretty hard to get around hardware restrictions but backwards compatibility features might provide a way to run old, insecure, code in old insecure ways.
    5. Buffer overflows and other common security problems have been with us for over thirty years and still aren't in the "solved problems" bin. This is inexcusable. If people are going to rely on computers in their daily lives, the computer have to be reliable and having the possibility of security comprimise using 30 year old techniques does not a reliable computer make.

    --
    -- Remember: Wherever you go, there you are!
  6. Re:Blame the Language by QuoteMstr · · Score: 2

    Hrm, interesting. Do you have a *real* Deja link?

    At least gcc's features are open --- If people are worried about gcc accepting non-standards-conforming code, why not hack it into -pedantic or -ansi themselves and release a patch?

  7. I'm stupid and careless by jetson123 · · Score: 3
    Oh, you found me out: I'm stupid and careless. And there are a lot more people like me around, at Microsoft, Sun, and even some (I hear) in the free software community.

    And to help half-wits like us still do something useful with software, it might be nice to give us tools we don't hurt ourselves with too much. You know, scissors instead of a Samurai sword. A Toyota Camry instead of a Formula 1 race car. 110V household current instead of 50KV "professional" power.

    The fact is, C/C++ is too powerful for me. Oh, I understand it just fine, and with enough time and effort, I can make something work semi-reliably in it. But what's the benefit I get for that self-flagellation? Should I spend all that extra time because finding the bugs "hurts so good"?

    The fact is: writing code in C/C++ is a lot of unnecessary work. The only reason why people put up with it is because everybody else does it, so it's the path of least resistance if you want to use the "standard" compiler on your platform, use a language other people are likely to understand, and use other people's C/C++ libraries. But make no mistake about it: C/C++ is successful these days in spite of its cumbersome design, not because of it.

  8. Re:Bull Pucky by mikpos · · Score: 1

    No, you don't need to put in bounds checking manually. Bounds checking is a property of the *compiler*, not the *language*. There are many C interpreters (and even many C compilers) which will implement bounds checking.

  9. Re:Blame the Language by LucVdB · · Score: 1

    Hello? Funny? Didn't you mean 'insightful', moderator?

  10. Re:C++ IS NOT TYPE SAFE! by mikpos · · Score: 1

    Yes it was what I meant. I always thought "type safety" was kind of a continuum. There's complete type unsafety (perhaps not unlike machine language); there's complete type safety (of a language unknown to me), and then there's all that in between. In order to do inheritance and stuff like that in C, you have to use generic pointers, which means that your compiler can not easily (though it is still possible) to catch type errors. So in that respect, C++ is "type safer" than C is, though I agree it is definitely not completely safe.

  11. Re:strict code/data sections by jetson123 · · Score: 2

    And in such systems, you pay a lot of overhead if you try to generate code at runtime, because it always involves a system call. That may be fine for 1960's style COBOL and C/C++ code, but it is not acceptable for 2000's style languages and programming.

  12. The OS'es fault (and language's) by VAXman · · Score: 2

    Buffer exploits can be be solved by more liberal use of segments. You can have one segment for VM from 0-2G, which is Ex/Re, and another for VM from 2-4G, which is Re/Wr. The problem is that OS'es like Windows and Linux are very primitive, and just use four segments, code and data flat selectors for each privilege level. If this scheme was used, buffer overflow exploits would be literally impossible, but it requires advanced OS'es which have not been developed yet.

    It is also the fault of the language. For its first 10 years (when it did not have C), there was literally never a buffer overflow bug on any program in VMS. For example, the internet worm exploited only Unix hosts, and couldn't do anything to VMS hosts. However, in the last 10 years, VMS has adopted more C programs, and the number of buffer overflow exploits has risen from 0 to a siliar amount on Unix. The string and array methodologies under C are incredibly fragile and primitive (as well as very low performance - you need to access byte at a time, which is VERY SLOW on modern architectures), and more advanced languages have much more high performance and more secure methodologies of dealing with data.

    1. Re:The OS'es fault (and language's) by Tony-A · · Score: 1

      >>requires advanced OS'es which have not been developed yet.

      You mean like Multics? Or the old Burroughs mainframes?

    2. Re:The OS'es fault (and language's) by VAXman · · Score: 1

      You indeed have a point. I would love to see a Multic's like OS (or any PDP-10 OS) ported to the PC. Heck, I'd like to see VMS ported to the PC! Yes, this technology has been around forever, but was displaced by a certain evil operating system.

  13. Re:C++ IS NOT TYPE SAFE! by QuoteMstr · · Score: 2

    C++ is type safe unless you use constructs which make it non-typesafe. As long as you don't use those constructs, like casting, it's a typesafe language.

  14. Re:"new" vs. "old" programmers by mikpos · · Score: 1

    You have a very narrow view of "bugs". Remember the old system() bugs? I don't know if Java has a direct analogue to system(), but it would still be possible either way. I'm talking about logic errors, not "programmatic" (for lack of a better term) errors. Every language or standard library that allows you some control (e.g. all current programming languages that I'm aware of) is going to give you the possibility to grant crackers root.

  15. Re:Blame the Language by sigwinch · · Score: 1
    GCC is an aggressive 'embrace and extend' language. It puts Microsoft's Java to shame.

    This is misleading -- verging on FUD -- as GCC will happily build ANSI-compliant code (AFAIK). Furthermore, most of the extensions can be easily removed to port to other compilers. True, the Linux kernel makes heavy use of extensions and would be difficult to port to something other than GCC, but that's a *very* special case.

    Here's some of the extensions I find useful, so you can judge their evilness for yourself:

    • Varargs macros. (Makes it easy to wrap varargs functions (e.g., printf) in macros.)
    • Zero-length arrays. (Put one at the end of a struct, and growing the struct becomes trivial.)
    • Argument type checking for printf/scanf-style functions. (Compiler warns if you read a '%lf' into an 'int *'. Catching this at run time is a royal PITA.)

    Maybe *you* want your languages handed down from the mighty and revered standards committee. That's fine, but don't try to keep me from using neat, helpful features.

    --

    --
    Kuro5hin.org: where the good times never end. ;-)

  16. Re:Blame the Language by mikpos · · Score: 1

    Old archives (prior to 2000 it seems) are currently not existent on Deja. Anyway I don't see the problem with some GNU extensions and functions not being able to be disabled, maybe because I already have an understanding as to what's standard and what's not. Oh well.

  17. Re:Blame the Language by mikpos · · Score: 1

    fgets

  18. safe assembly language by Tom7 · · Score: 3

    '' Oh? I'm fairly sure machine code is /also/ "unsafe", and that's what your pretty source code ends up as. How do you prove that your oh-so-wonderful language is still safe when rendered into raw machine code? ''

    I'm sure you're thinking that you've got me beat, but in fact this is a great question!

    The old, less-satisfying answer is that compilers are less likely to have bugs than the programs they're given. This is probably true (I don't recall any exploits due to compiler bugs, though to be fair I do recall some Java VM exploits).

    The new exciting answer is: We use a type-safe subset of the target machine's assembly code.

    In our TILT compiler for instance, we take ML code and put it through a series of transformations. At each transformation or optimization we also translate the types (a static proof that the program can't crash) until we get to machine language. This catches a lot of compiler bugs, and helps propagate safety properties to the raw code.

    The result is that we have machine language which can pretty easily be checked for type-safety. This allows us to do some other cool things, like ship the proof along with the raw machine code, to be executed on someone else's machine. They don't have to trust us (just the proof), and it doesn't suffer sandboxing costs like java. Wow! Read about Proof Carrying Code .

    The second answer isn't really usable today, except in theory. The first is absolutely practical, though. (even if it fails due to compiler bugs, we'd still cut down on a high percentage of errors -- and we'd only need to fix bugs in one place).

    1. Re:safe assembly language by jason_aw · · Score: 1

      > this is a great question
      Why, thankyou :-p

      I wasn't trying to "win", I was interested in what the answer was... I'll go off and have a read of that sometime.

  19. Re:Blame the Language by Tom7 · · Score: 1


    What part of what I'm saying is hard to believe? Though we can translate Java or other safe languages to C, and the resulting C program is "safe", we aren't able to verify that about the C program unless we have around the Java program as well. (or we avoid using some unsafe C features).

    You're certainly right about the compiler doing work for you, and really that's at the root of my point. Though it's possible to write safe C code, why not let the compiler verify (and indeed, prove) that your code is safe? (Clearly C programmers still make the kinds of mistakes we think are easy to not make...)

  20. Re:Bull Pucky by Tony-A · · Score: 1

    Arggh.
    If the Code Segment is not marked readable, you cannot read the code.
    You can't jump into the stack. You can jump to a "far return address" that is stored in the stack. You can jump to an address in the Code Segment which just happens to be coincident with something in the Stack Segment.

    With NO CONTEXT SWITCHES, there are 8000+ local code spaces, 8000+ global code spaces, 8000+ local data spaces, 8000+ global data spaces, 8000+ local stack spaces, 8000+ global stack spaces. All these code and data spaces. All independent. All in the same context. But the OS has to handle them. No OS wants to bother. They all effectively point code, data, and stack to the same memory with bounds set to all of memory.
    There are four protection levels, but only Multics that I am aware of has ever used more than two levels.
    The hardware design of the 80386 is targeted at a Multics-like OS. Current i386 code is using separate code data and stack spaces, with bounds checking on all references to memory. Unfortunately, code, data, and stack point to the same memory with the bounds being all of memory.

    Speed. Loading a segment register is comparable to integer multiply, the instruction, not the addressing shortcut.

    Unless Operating Systems, Language designers, and programmers are willing to give up the nice flat 32-bit address space and go back to the old 8086 DOS segments and offsets as a programming paradigm, things are not going to improve. The problem with the old DOS is that segments were used to break the 64k barrier in a flat address space rather than used as segments. With the 386 architecture, segments are no longer limited to 64k, and there is no correlation between segment number and physical address.

  21. Re:Blame the Language by Tony-A · · Score: 1

    Actually type safety has everything to do with buffer flows. The problem is that the types available are either unsafe or unchecked.
    What is the type of a pointer to a 120 character buffer? If the effective type is a pointer to max 64k bytes starting here, then it is unsafe.
    Strongly typed languages are easier to write programs in that do not have certain kinds of bugs. They are harder to write programs in that are buggy and seem to work OK.
    Will things get any better? No. There are too many buggy programs that sorta work well enough that will be stopped dead by anything that enforces safety. What I'd love to see is a good free production-quality Algol68 compiler. The 68 stands for the year 1968. Progress? nah. :(

  22. Re:Why do people still program in C? by jetson123 · · Score: 2

    The same is true for Modula-3, Oberon, Sather, Eiffel, and other languages. Yes, they don't have the support or user community that C has, but on technical grounds alone, they are fast, small, have no overhead, etc.

  23. Re:Blame the programmer by Remote · · Score: 2

    Very interesting post this one of yours, I could agree with you 100% in the first line, and gradually go down to 0% on the last line.

    If I read you correctly, the burden to avoid buffer overflows should be put on the programmer, not on the hardware or on the machine. Then you start advocating that the compiler/library should take care of this! Isn't that like just laying the safety net a couple feet higher?

    As a general rule, I think dumb tasks should be left for the machine, the noble ones for the programmer. Checking whether a given input validation is a potential door for an exploit is the programmer's responsibility.

    Another thing that you seem to suggest is that quick and dirty test code should be the basis for production code, thus holes could migrate to the final product. I think the ideal solution is to discard test code altogether and start from scratch, but who does that, right? One other approach, which I actually use and believe many do, is to check for errors (at least return values) from the very beginning, so as those parts which will inevitably be cut and pasted to the production source are structured in a way that adding extra checks would be much easier (favouring using heap memory, encasing calls in try/catch blocks in C++, for example)

    Just my $0,02

  24. Post withdrawn! by Trracer · · Score: 1

    See subject..;)
    Altho, I would have LOVED to see what he wrote!
    Anyone mirrored?

    --
    English is not my first language, so cut me some slack -: Om du kan lasa det har sa kan du Svenska :-
    1. Re:Post withdrawn! by Tony-A · · Score: 1

      Sorry, no mirror, but I did read most of it.
      Not bad really, but he was aproaching the Intel architecture from a Unix/VAX perspective rather than a Multics or Old Burroughs perspective.
      Overall probably better than the average of the decent /. posts. The problem is very real. He was looking for a magic bullet, with maybe a few ideas of his own. The problem has been solved, probably before he was born, and the solvers are mostly dead and buried. Nothing to be ashamed about. He should have left the thing up, with maybe a followup and a link to /.

  25. Re:"new" vs. "old" programmers by jgennick · · Score: 1
    Buffer overflows are NOT just gets and scanf. Those are impossible to secure
    It's been a long while since I've written C, but I remember being frustrated by library functions such as this that were "almost useful" but for some major flaw. Why do they even exist if they can't be secured?
  26. Re:Bull Pucky by Tom7 · · Score: 1


    A language can certainly stipulate that bounds checking is performed on an array (as ML and Java do), making it a property of the language. A compiler or interpreter is just an implementation of a language spec.

    It's good that there's a way to run C code safely. But interpreted C code is certainly going to be orders of magnitude slower than compiled ML or Java code. Probably unacceptable.

    Regardless of the bounds checking a compiler might insert automatically (GCC certainly doesn't), C remains an unsafe language (casts and pointer arithmetic being the main troublemakers). This is not just an impediment to security, but to debugging (ever tried to debug a malloc/free error? ouch).

  27. Interesting Theory by phUnBalanced · · Score: 1

    This is quite interesting in my opinion. I've often wondered the same thing.

    Although it may be disagreeable to side with faulty software manufacturers <co>microsoft<ugh> it is possible that if buffer overflows were cut off at the hardware level, we wouldn't have to worry about the idiots writing bad code.

    1. Re:Interesting Theory by Tony-A · · Score: 1

      On the Linux side, the exploits discovered, exposed and maybe even fixed.
      On the Microsoft side, the exploits discovered and put into a private cache for a rainy day. Not exposed. Not fixed.
      Remember the ZDnet crack-this-box thingy. After the very well-done expose of the Linux crack, if I did have a crack on the Microsoft box, there is no way I would have tried to follow him. Besides, there is too much risk of the Microsoft target being behind a well-crafted BSD firewall.

    2. Re:Interesting Theory by Salamander · · Score: 1

      >Just put your buffer in it's own segment, and give it a certain length, and then if it goes over, a segment fault is generated, and it can allocate more buffers. That's how windoze works.

      Simply incorrect. Windoze also uses pages. Doing what you suggest would increase memory demand and page faults while decreasing TLB hits, with disastrous effects on performance.

      --
      Slashdot - News for Herds. Stuff that Splatters.
    3. Re:Interesting Theory by jfern · · Score: 1

      Just put your buffer in it's own segment, and give it a certain length, and then if it goes over, a segment fault is generated, and it can allocate more buffers. That's how windoze works. Unix uses pages.

  28. Re:Blame the Language by locust · · Score: 2
    C++ is "of course" not a good language? Why? You can do everything you can do in C in C++, and then some. If you don't like templates, don't use them. If you don't like operator overloading, don't use it. Unlike certain other languages *cough*Java*cough*, it doesn't force any particular paradigm on you.

    You can write object oriented code in any language you like. You can write procedural code in any language you like. Object oriented langauges simply facilitate the use of object orientation by providing you with tools that take advantage of it. You can write oo basic, and you can write procedural java (just make everything static and put it in your main class). The paradigm is not being forced on you. You simply ignore some of the features. But don't take my word for it, look at the tour if C++ in Starstroup's The C++ Programming Language.

    Polymorphism, encapsulation, and inheritance are simply properties that fall out of the OO paradigm and are implemented to take advantage of it of its implications. Ultimately the right tool for the job in any given case may or may not implement these.

    --locust

  29. Bull Pucky by nweaver · · Score: 4

    Buffer overflows are the fault of the LANGUAGE. Important system utilities need to be written in bounds-checked languages. Some compilers, no matter the architecture, will write executable code on the stack: "trampolines". Unfortunatly, this is common enough that the OS can't blindly turn off the executable bit on the stack pages. And non-executable stack pages don't stop all buffer overflow attacks, they just require a 2 part attack: A heap buffer to write the code, and a stack buffer to overwrite the return address. The heap buffer doesn't necessarily even need to be overflown, the attacker just needs to be able to deduce the address. And one can't set heap-addresses to be nonexecutable, simply because there are MANY language environments which do create code at runtime, such as interpreters, JITs, etc etc etc.


    Nicholas C Weaver
    nweaver@cs.berkeley.edu

    --
    Test your net with Netalyzr
    1. Re:Bull Pucky by Tony-A · · Score: 1

      On Intel hardware, all addresses are bounds checked during run-time by the hardware. The problem is that code, data, and stack all point to the same memory with the bounds set to all of memory. The basic problem is using the nice flat 32-bit memory space rather than the messy segment pointers. Since Multics died and Unix survived (Windoze seems even worse), it will be a long time before things get better. There is too much of a horse race mentality. The winner is whoever is faster by a nose.

    2. Re:Bull Pucky by slashdude · · Score: 1

      Doing a bit of search I found a good article abour rgis at buffer overflow it details how no exec stacks can be used to allow data to stay where it belongs and the actual stuff to be execed to always be kept in memory.
      It does make it a bit harder to program at the OS level but it would provide a good tradeoff in security and save all the buffer overflow attacks in programs which I think everyone would be thankful for!

      --
      I'm a big flaming gay nigger
    3. Re:Bull Pucky by Xman · · Score: 1

      No, buffer overflows are the fault of the _programmer_. The language makes no real difference. All code in all languages ultimately gets crunched to machine language, so they are, a few twists and turns aside, equivalent. Granted, each makes different tradeoffs in terms of what it does the best from a dev-time/performance point of view, but if you can overflow-safe it in one langauge, you can overflow-safe it in another.

      It's reasonable (but wrong) to say that the hardware is to blame, and it's reasonable to say that the programmer is to blame, but to blame the langauge is off-base. That's like claiming the directions your uncle gave you were wrong because he gave them to you in English. "If only he'd used German, I would have got on I-280N instead of I-101S!"

    4. Re:Bull Pucky by nweaver · · Score: 2

      Unfortunatly, the semantics of C do not allow easy general bounds checking, since arrays are semantically defined as pointer arithmatic, eg foo[i] is equivelent to *(foo + i). There is no actual array type in C!

      A C-compiler can attempt to funge things to try some bounds-checking like operations, or hacks like stackguard which detect a class of misoperations or purify which does the same thing in a different manner, but the language itself semantically doesn't allow bounds-checking in general, due to how arrays and pointers are typed, without going through serious hacks like what Purify does. Of course, Purify ends up costing more then the bounds checking in a proper language would cost.


      Nicholas C Weaver
      nweaver@cs.berkeley.edu

      --
      Test your net with Netalyzr
    5. Re:Bull Pucky by mikpos · · Score: 1

      First off, I think malloc()/free() debugging is grossly exaggerated. I had problems with it at first before I knew what was certain things in the language meant, and before I became familiar with my debugger.

      C interpreters give something very valuable to C, though. You can make them as slow and bloated and pedantic as you like. Maybe they run 500x slower than compiled C code. All you have to do is run it through there once, though, before you can be assured (as assured as you can ever be when dealing with software) that it is safe, you can take the *exact* same code and compile it with a compiler. You get safety and performance: the best of both worlds. Mind you there aren't decent C interpreters available for every language :).

      But anyway, in case you haven't guessed, I really like C. It's simple enough and such a widely supported language (arguably the first real cross-platform language, and it's only gained portably and acceptance since then) that you can do whatever you like with it without much trouble.

    6. Re:Bull Pucky by mikpos · · Score: 2

      First of all, yes, C does have an array type. Arrays are not pointers, and pointers are not arrays. Arrays have a nasty habit of decaying on you, but the second you forget and treat them as pointers is the second you run into trouble.

      From the view-point of dealing with stack smashes specifically, this can be helpful. Arrays, like any other statically or automatically allocated objects, are declared on the stack, whereas dynamically allocated "arrays" (the target of pointers usually) are declared on the heap. Of course getting rid of stack smashes isn't quite as interesting as getting rid of buffer overruns altogether (both stack smashes and "heap" smashes), but the difference can be useful.

      As I mentioned in another post, though, you can interpret C as much as you want. There's no reason for a C implementation to have a compiler, and even a human being can (in silly situations) be considered a compliant implementation. If you interpret the hell out of it, so that for everreference to an object, you trace its history throughout the program, you can be fairly safe. It might take an hour just to go through a single instruction; "hello world" might take six years to run on the fastest Cray, but it will give you everything you ever wanted to know. Of course these are silly examples: usually C interpreters only slow things down by a magnitude of a few hundred times (or less) when compared to compiled code. But you only have to interpret once and get an "everything is OK" before you can take that same code, turn around, and compile it.

      This is, of course, possible with other languages. There are political and legal obstacles with Java, I think. But for all complex languages (of which I'm saying C is not), making your own interpreter is too much trouble for such little reward.

    7. Re:Bull Pucky by Zurk · · Score: 1

      yes java is a proper language. its about the same as C, BASIC, C++, Modula, Smalltalk or any other language. it allows you to compile programs and execute them. all languages which do that can be defined as languages. how is java similar to C++ ? how are my arguments idiotic ? or are you just whining for the sake of whining ?
      For the clueless :
      1] Smashing stackguard :
      http://phrack.infonexus.com/search.phtml?view&ar ticle=p56-5
      2] Buffer overflowing C++ :
      http://phrack.infonexus.com/search.phtml?view&ar ticle=p56-8
      3] Even more Buffer overflows with *safe* C calls :
      http://phrack.infonexus.com/search.phtml?view&ar ticle=p56-14

      Yup. all from the guys who brought you phrack. i may not be an expert but IMHO, if there is anything better than sandboxes/rules and VMs for providing security in a language, ive never seen it. Java can provide all 3.
      And no, im not looking for a job. thanks.

    8. Re:Bull Pucky by Zurk · · Score: 1

      stackguard cant protect ALL code and you can get around it. its a hack. a proper language like Java has bounds checking. it IS a fault of the language..no matter how much you may argue, a sandboxed virtual machine with garbage collector and bounds checking built in IS the right approach...even if speed is lost as a result.

    9. Re:Bull Pucky by Salamander · · Score: 2

      >Some compilers, no matter the architecture, will write executable code on the stack: "trampolines".

      I don't think this is "no matter the architecture". The need for trampolines is chip-architecture dependent, and any compiler writer who uses trampolines where they're not absolutely forced to should be shot.

      --
      Slashdot - News for Herds. Stuff that Splatters.
    10. Re:Bull Pucky by QuoteMstr · · Score: 1

      The problem is that buffer-checked languages, by definition, can be slower than non-buffer-checked languages because they must check the buffer. It may not make a difference for small things, but for something like Apache, which regularly manipulates large quantities of text, it could have a drastic effect.

    11. Re:Bull Pucky by Stephen+Samuel · · Score: 2

      Some languages have the length of a buffer coded into the buffer and simply won't allow you to put more into a buffer than it has available (either that or they'll re-allocate for more space). With languages like that -- unless the implementation code is buggy, or you do direct system-call hacks that overwrite the internal structures -- it isn't possible to overrun buffers.

      --
      Free Software: Like love, it grows best when given away.
    12. Re:Bull Pucky by nweaver · · Score: 1

      Except that if one is caring about security, one is using the bounds-checking versions of all the functions anyway, a proper compiler should be hoisting the checks outside of inner loops when possible, and other such factors means the overhead is far less than you would expect.

      And finally, if you wish to build a reasonably secure system, you just have to accept the penalty. Which would you rather have: A web server which loses 10% of its performance to bounds-checking (be it automatic or programmer-derived), or a web server with lord-knows-what security holes in it?


      Nicholas C Weaver
      nweaver@cs.berkeley.edu

      --
      Test your net with Netalyzr
    13. Re:Bull Pucky by QuoteMstr · · Score: 2

      The former, of course, but just because some of the buffer overflows are fixed in the former doen't mean it is invunerable to attack. Better to fix the latter so as to keep both performance *and* security.

    14. Re:Bull Pucky by mikpos · · Score: 1

      It is not the fault of the language; it is the fault of stupid people. Anybody with either: (a) skill, time, patience and experience; or (b) lclint will *not* have buffer overflows. Seriously, though, all you have to do is run your favourite program through lclint and it'll point them out to you: "buffer overflow possibility over there. Oh, there's another one".

    15. Re:Bull Pucky by fgodfrey · · Score: 1

      Err, hmm. Someone care to point me at something that'll explain segment registers? I am apparently a lot more clueless on this subject than I thought :)

      --
      Go Badgers! -- #include "std/disclaimer.h"
    16. Re:Bull Pucky by Tony-A · · Score: 1

      Er,
      What is an array type in C?
      I can do an array declaration which does not allocate memory.
      I can do an array definition which does allocate memory.
      I can access the array as array[i] where i is outside the legal limits.
      I can also access the array as i[array] or *(i+array).
      If I pass an array to a subroutine, how is that subroutine prevented from accessing memory before or after the extents of the array?

    17. Re:Bull Pucky by Vanders · · Score: 1

      Try the Intel site, where they have documentation on almost everything, including segment register use etc. But be warned, this stuff is scary, and will give you headaches and nightmares :)

    18. Re:Bull Pucky by Stephen+Samuel · · Score: 2
      Sure, you can blindly turn off the executable bit on stack pages. It simply requires that the program turn it off if they're doing on the fly code or self-modifying code.

      It could also be done as a compile-time switch. This would prevent breaking random code that doesn't know that the rules have changed.

      A 'dumb' question -- given that I've never bothered to program Intel assembler (I looked at the 8086 model and got sick to my stomach!).
      The stack, data and code segments are logically separate, aren't they? wouldn't it be possible to make them disjoint spaces so that you simply couldn't jump to the stack? -- kinda like security by obscurity.
      Stack and Data may want to share code space, but why share the spaces for data and code, unless you're doing self modifying code. If you need modifiable code space you would do a call to tell malloc to give you some dual-mapped memory. Once you were done modifying it you could unmap it from the data space

      The backwards-compatible model would be: Any segment address would map to the same real address if it maps. It would not, however, necessarily map to all (or any) memory spaces.

      --
      Free Software: Like love, it grows best when given away.
    19. Re:Bull Pucky by fgodfrey · · Score: 1
      That won't help on Intel. There's no way to make it so you can't jump to the stack unless the stack is not executable. The way a lot of these buffer overflows work is that they trick the program into corrupting its own stack and rewriting the return address so that instead of returning to where it should (some address in the code segment) it "returns" to some arbitrary address on the stack that contains the code to execute. Just because the segments aren't run right together in memory (actually, they aren't this way now) doesn't prevent a jump from one to the other as long as they share the same address space. Unless you are suggesting that they *not* share the same address space. That would require (if you could even make it work) a *very* large number of context switches which would hurt performance a *lot* more than just doing the right thing which is to not read data from an untrusted source without checking it to make sure it's sane.

      You *can* flip off the execute bit on processors that have one, however, Intel x86 doesn't. On Intel, read==execute.

      --
      Go Badgers! -- #include "std/disclaimer.h"
    20. Re:Bull Pucky by Biff+Cool · · Score: 1

      If security is a serious issue then the programmer

      should be responsible enough to use the bounds-checking versions of functions. You shouldn't expect the compiler to assume that it knows the purpose of your application.

      Conscience is the inner voice which warns us that someone may be looking.

      --

      Conscience is the inner voice which warns us that someone may be looking.
      -- H. L. Mencken

    21. Re:Bull Pucky by Tom7 · · Score: 1

      '' Seriously, though, all you have to do is run your favourite program through lclint and it'll point them out to you: "buffer overflow possibility over there. Oh, there's another one". ''

      And then you have to go and insert bounds checking manually. It's true that we can write safe code in C with patience ... but who wants to do that? Obviously not everyone, since we continue to see buffer overflows in security-critical code (wu_ftpd, netscape's JPEG code, Quake 3, etc...) =(

    22. Re:Bull Pucky by Biff+Cool · · Score: 1
      Well I guess I should have bounds checked my huh

      Conscience is the inner voice which warns us that someone may be looking.

      --

      Conscience is the inner voice which warns us that someone may be looking.
      -- H. L. Mencken

  30. Re:StackGuard by Tom7 · · Score: 1


    An AC posits:

    "That demonstrates a flaw in the StackGuard compiler then, not a fundamental shortcoming of the C or C++ languages."

    I say:

    Can you clarify?

    C and C++ are fundamentally unsafe languages, and it will always be possible to write C code with buffer overflows (and other kinds of bugs avoided in a safe language). It is possible to limit the scope of buffer overflows to disallow executing arbitrary code, and maybe stackguard techniques could do it.

  31. i386 is fine, just make smart programs by Limecron · · Score: 1

    I think these "holes" could also be called versatility. Trying to prevent these attack through hardware means, ruins versatility.

    Also complaining that it's the i386's fault, doesn't accomplish much since everyone and their grandmother has 5 already.

    I'm not so sure about having a compilier that fills these security holes, but I'm all for having a complier warning saying, "Stack securtiy comprimised (line: xxx)". This doesn't seem as if it would be all that difficult to implement, either...

    1. Re:i386 is fine, just make smart programs by Tony-A · · Score: 1

      To check against bounds you must have the bounds to check against.
      The semantics of memory allocation need to be considered. I think almost all forms return a pointer to somewhere within the heap. Clever or inadvertent messing with pointer[-n] should be capable of doing some wierd or disastrous things.
      There is help possible from the intel hardware. The OS could return a 16-bit segment register capable of referencing exactly the allocated memory. Unfortunately, there are only some 8000+ available possibilities for the return value.

    2. Re:i386 is fine, just make smart programs by TrixX · · Score: 1

      This is a language-level problem...
      A warning like this in a C compiler should appear every time you do an array access, unless the array size and the index are constants.
      A compiler could implement bound-checks, but I guess a lot of code will stop working, because some programs use "off-buffer access" as a feature.

  32. Re:"new" vs. "old" programmers by rpk · · Score: 1

    An innocent question: what is the safe version of sprintf ?

  33. Re:Blame the Language by Biff+Cool · · Score: 1
    But to say that doing bounds checking safely in C is impossible, but since Java or ML do it for you it's going to work perfectly doesn't make sense. They both translate to machine code therefore it can be done. All it takes is one "bound-safe" library with some #ifdefs and you've got the same thing.

    Conscience is the inner voice which warns us that someone may be looking.

    --

    Conscience is the inner voice which warns us that someone may be looking.
    -- H. L. Mencken

  34. Re:Why MacOS doesn't get 'sploited and why it matt by disarray · · Score: 1
    That's utter, utter bullshit. If the Mac OS wasn't vulnerable to buffer overflows, why does this list contain several entries like:

    1998-04-07: AppleShare IP Mail Server Buffer Overflow Vulnerability

    --ian

  35. Re:Blame the Language by jacobm · · Score: 2

    Not if you want to parse command lines, for example, or use many of the C library functions (e.g., printf). Of course, in your own, 100% new code, you can use STL and stuff like that, but when you're interfacing with existing code or trying to use (a few of) the language's features, you have to use the unsafe constructs at least a little. That's particularly true when it comes to user input, which is (naturally) where buffer overflows come from.
    --
    -jacob

    --
    -jacob
  36. Re:Why do people still program in C? by Malc · · Score: 2

    Everything that you said about C applies to C++ (except for being forced to use it under UNIX!)

    A lot of (bad?) programmers do a lot of unnecessary work with their strings because they don't know whether they need to be copied or not, so they always do it. C++ offers string classes that make this irrelevant. Reference counting leading to copy-on-write ensures much greater simplicity and often better performance. A decent string class implemented using a bridge pattern will only be 4 bytes (same as a char*) - it will just consist of a pointer to its implementation and so it can passed around on the stack very quickly. They also have the benefit of being guaranteed '\0' termination. Much easier to handle embedded NULs too.

  37. The market doesn't want exception handling by rpk · · Score: 1
    ...you can blame this on C, too.

    Other languages considered integer overflow to be an exception. Once C took over the world, there was no reason for new (post-VAX) architectures to support this. As a result, it's more inefficient to do safe arithmetic on modern architectures now, even though we have cycles and cycles enough to spare.

    1. Re:The market doesn't want exception handling by Tony-A · · Score: 1

      Quick, what is 0xffff + 0xffff?
      If they are signed integers, the answer is -2.
      If they are unsigned integers, the answer is overflow.
      VAX and x86 distinguish between signed and unsigned by testing the condition codes. They have one add instruction used for both signed and unsigned arithmetic. They do not have the required information to know if it is an overflow condition or not.
      IBM/360 distinguishes between signed and unsigned by using different opcodes, so it can and does generate overflow exceptions.
      For fun, consider adding a signed integer to an unsigned integer and storing result into a signed integer and an unsigned integer respectively.

      Curiously, the only direct caryovers from the PDP11 to the VAX were the condition codes.

  38. Re:Blame the Language by Andy_R · · Score: 1
    Educate the programmer on *why* things like sprintf, strcpy, etc. are Bad Things...

    not why, but *when*. If you are knocking up a one time program for your own use, use whatever gets the job done. If you are writing an in-house app for an urgent problem, take the risk that your loyal staff won't be trying to cause buffer overflows. If you are writing for a wider audience, *then* you need to be careful.

    Surely the performance hit (and often, more importantly, developer time hit) isn't worth the effort.

    --
    A pizza of radius z and thickness a has a volume of pi z z a
  39. Why MacOS doesn't get 'sploited and why it matters by b1t+r0t · · Score: 2

    First, it's not because of the CPU. Hell, the first well-known stack 'sploit was in the RTM worm, which worked for two flavors of Unix on a VAX cpu.

    It's because MacOS uses one big-ass shared memory space to run everything in that it's safe from being taken over by buffer overflows. Well, gee, if it's all unprotected, why is it so safe? Because while you can still crash a program with a buffer overflow, you can't predict the stack address. And the critical part of a stack overflow exploit is to get the program counter pointing to the exploit code on the stack.

    And even if you could, what would you do with it? There's no shell (at least not until OS X, but that's a completely different OS) to give commands, and no root privs to exploit (actually you are "root" at all times!)

    Intel is relatively low on the fault scale here. A bigger problem is the number of people running Linux distros with the same binaries in them. If you compile your own code, the stack addresses will be less predictable (though not completely unpredicatable), and you'll be in the same boat as MacOS: without a predictable stack address, there's no way to run the 'sploit code!

    If we simply had more people compile code their own binaries, the problem would be reduced.

    But at heart, the fault is one of languages that let you stick things into memory without any sort of range checking. Get too much data or lose the null terminator from a C string and your stack is toast.

    And most of these problems happen inside of a library routine. But you can't blame the library routine when it has no way to know the size of the destination buffer. The best it can do is know where the frame pointer is and to not write past it.

    If C strings were more than just bare buffers with only a lone null to save you from oblivion, the library routines could be smart enough to save your ass. So I blame C and its strings as the primary problem causing buffer overflow exploits.

    Use a language with internally checked datatypes and no bare pointers like Java or Perl, and this type of exploit will go away.

    --

    --
    "Open source is good." - Steve Jobs
    "Open source is evil." - Microsoft
  40. Re:Blame the Language by Broccolist · · Score: 1
    Where am I forced to use an array or raw string in C++? I can use STL containers and std::string, respectively. They are *much* safer.

    Well, almost any C++ program needs to use some sort of OS API, which is usually C-style and forces you to muck around with arrays and other repulsive constructs :).

    Also, the C++ standard library is often just too slow. I was writing some code that parsed text with the standard string class, and every time I wanted to pass as argument a part of a string (rather than an entire string), I had to create a whole new string object with substr()! My program became ridiculously slow (something like 10 seconds to parse 4000 lines). Finally I gave up and replaced everything with char*s.

    Anyway, I still agree with your point in general. IIRC, Stroustrup once said something like "I find almost every use of the term 'C/C++' to be indicative of ignorance."

  41. Article withdrawn by fence · · Score: 1

    Update from B. Perens' website:
    I've withdrawn this article after enough people convinced me that I didn't know what I was talking about. It happens sometimes.

    Thanks

    Bruce


    Note to self: idea for new article->Blame programmers for buffer overflow security exploits.
    ---
    Interested in the Colorado Lottery?

    --
    Interested in the Colorado Lottery or Powerball games?
    check out http://colotto.com
  42. LINT for checking code security by 3r33t+h4x0r · · Score: 1

    It's already been done and it's called (strangely enough) SLINT. Unfortunately, it's not available to the public. Perhaps some polite inquiries could persuade them to release it? Or maybe not. Anyway, it's there.

  43. Re:Blame the Language by The_Messenger · · Score: 1
    . . . or even Java.

    Don't push it, friend. You don't want to incur the wrath of the Java Defenders' Flame Brigade, now would you? :)

    ---------///----------
    All generalizations are false.

    --

    --
    I like to watch.

  44. Re:This is a very old debate.... by slashdude · · Score: 1

    Doing a bit of search I found a good article abour rgis at buffer overflow it details how no exec stacks can be used to allow data to stay where it belongs and the actual stuff to be execed to always be kept in memory.
    It does make it a bit harder to program at the OS level but it would provide a good tradeoff in security and save all the buffer overflow attacks in programs which I think everyone would be thankful for!

    --
    I'm a big flaming gay nigger
  45. ..... by phUnBalanced · · Score: 1

    Ok So maybe I'm not always right, but I DON'T hide behind AC. I take pride in my mistakes. If I didn't make them, I wouldn't learn. And I work for an NT hosting company, I have 50+ hour a week experience with BS microsoft puts into their software. I know what's there that's no good. I run linux at home and have a very secure network that has thwarted the numerous cracking attempts it's been met with... thank you very much.

    1. Re:..... by Tony-A · · Score: 1

      Yep. I wonder how insecure NT really is. It has the feel of an accident looking for a place to happen. Of course whoever really knows is not talking. There would have to be an enormous amount of satisfaction from finding and plugging the _last_ security hole in linux. With two exploits in Outlook published in the same week, I feel safer ignoring it and watching /. for the fix for the next one that gets loose in the wild without a prior announcement. Worked for the Love Bug. It took Microsoft three days for a search for I LOVE YOU to show anything on their web site.

  46. Re:Efnet #Linux "Secure Linux" by Leto2 · · Score: 1

    Uhuh.

    How many backdoors did you put in that RPM?

    --
    <grub> Reading /. at -1 is like driving through Cracktown in a convertible that is stuck in 1st
  47. Re:You simply cannot charge for the GPL by Roger_Wilco · · Score: 1

    Actually, RMS encourages people to charge as much as possible for free software. The money acquired in this way, he reasons, can be used to develop more software. You can charge for a GPL'd program, you just cannot stop whoever buys it from distributing it, and must make the code available.

  48. Re:Why MacOS doesn't get 'sploited and why it matt by blakestah · · Score: 2

    If C strings were more than just bare buffers with only a lone null to save you from oblivion, the library routines could be smart enough to save your ass. So I blame C and its strings as the primary problem causing buffer overflow exploits.

    Use a language with internally checked datatypes and no bare pointers like Java or Perl, and this type of exploit will go away.


    Programmers writing SUID programs should also be capable of using pointers without creating buffer overflow exploits.

    Or do you think the problems with buffer overflows outweigh the potential gain from using pointers in the first place ??

    I strongly prefer the additional power of constructs in C that are provided by pointers. I do not think that a higher level language is likely to be any safer. Sure, the language may conceptually be without overflows, but the increased size of the compilers/interpreters makes those much more difficult to check, and still prone to overflow.

  49. Re:Blame the Language by FigWig · · Score: 1

    But you need references/pointers to do polymorphism, so there is some limit.

    --
    Scuttlemonkey is a troll
  50. Re:Why do people still program in C? by TrixX · · Score: 1

    I haven't ever written/read/used programs in FORTRAN, but I've done somo programming in Eiffel, and programs look a little Eiffel-like...
    That shouldn't be surprising, because it's intended to give C programmers some Eiffel-like features.

  51. Are they giving away free crack with compilers? by ErikTheRed · · Score: 1
    There's this feature included in most modern software development system called Exception Handling. Let's all say it together: Ex-cep-tion Han-dling. Now, if, for the sake of agrument, I was developing some piece of software for anything other than a trivial bit that I was going to use once or twice myself, I would make sure that it properly handled its errors and did a reasonably good job cleaning up its mess. I can't imagine the mentality of someone who writes an app that accepts data from another app or system that doesn't check the hell out of every aspect of that data. And please don't tell me I'm the only person left that allocates their buffers dynamically. People who use C/C++/whatever and fill their code with things like

    • char cBuffer[128];
    need to be severely beaten over the head with their copy of The C++ Programming Language, Third Edition and forced to use Visual Basic for MS Office for the rest of their lives.

    Just my $.02
    --

    Help save the critically endangered Blue Iguana
    1. Re:Are they giving away free crack with compilers? by Paradise_Pete · · Score: 1

      Nice example of why you don't need the compiler to help, he said sarcastically, while looking at the line cBuffer[ch] = /0;

  52. VM tricks are so much fun. by Tony-A · · Score: 1

    If you actually _use_ the intel segment structure, you aim a read/write data segment at exactly the extent of code you need to modify, not the standard bit of CS:12345 being the same byte as DS:12345 being the same byte as SS:12345.
    With byte granularity, the segment can precisely delimit up to 1 Megabyte of code. With 4k granularity, the limit is 4G.
    For non-trivial security, I think Intel did it right, only none of the OS's follows through. Somethink like it works better to control the keys than to control the locks.
    There seems to be too much all or nothing, user or kernel. Anything legitimate has to be more complicated than that.

    If you have 12 guests and room for 10 chairs on your property, you just put 2 chairs on you neighbors property. Chances are your neighbor neither knows nor cares. Everybody is happy ... until ...

  53. Re:This is a very old debate.... by soellman · · Score: 1

    Sure, but if you're willing to have a bit more 'crap' in the kernel, you reduce the chance of being cracked. If creating an exploit for a kernel with the stack-exec patch is more of a task, there will be fewer exploits that do so. In applying that patch, you'd successfully be lowering your chances of being cracked.

    I don't see that as a bad thing.

  54. Somebody once said... by xaniamud · · Score: 1

    A poor workman always blames his tools. 'nuf said.

  55. Re:C++ IS NOT TYPE SAFE! by 0xdeadbeef · · Score: 1

    That's a bizarre definition of "type safe". How do you accomplish anything at a system level without pointers, etc.? Even in Java it is necessary to downcast things. C++ is just as safe if you use dynamic_cast.

    Please explain how one can do anything in a strongly typed, inheritance-based language without casts? The concept of type safety does not include the impossibly that programs may crash when one ignores or misuses those very features that guarantee type safety.

  56. Please re-moderate the above message by IGnatius+T+Foobar · · Score: 1

    The above message was moderated down in error. It should not be "-1, Troll" but rather "2, Funny"

    Thank you.
    --

    --
    Tired of FB/Google censorship? Visit UNCENSORED!
  57. To answer timothy's question: by jacobm · · Score: 1

    If everybody showed such grace, Slashdot would get a maximum of three replies to every story.

    :)

    --
    -jacob

    --
    -jacob
  58. legacy C library functions by Tom7 · · Score: 1


    They exist for ANSI C compatibility (who would ship a compiler that's not ANSI compliant?) and compatibility with old source.

    There are a number of man pages which quite cutely remind you not to use certain functions (sometimes not for securtity reasons):

    man strtok
    ...
    BUGS
    Never use this function.
    ...

  59. Re:Buffer Overflows by fm6 · · Score: 1

    It's not so much like going out with too many guys. That the normal state of the web. It's more like letting some of these guys scope out your house for broken door...

  60. Re:C++ IS NOT TYPE SAFE! by Tom7 · · Score: 1


    What is the point of calling something "type safe" then?

    That's like saying a wu_ftpd is secure, except for the remote root exploits.

  61. Re:Blame the CHIP? Blame the LANGUAGE? Pfah! by Frodo · · Score: 1

    It's only slow if you don't bother to learn what code a C++ compiler generates, using lots of mechanisms without realizing it.

    Yes. But this stems from C++ being descendant of C, which is basically assembler on steroids. To effectively program in C, you should know your processor, your OS and your operative environment to the tiniest guts. Which means, you spend too much time on this, so or you lose your programming effectiveness, or you tell "heck with that" and make program uneffective, but meet the deadline and not get fired.

    So, the thing you need is compiler that know to optimize (and hint about) your constructions. After all, compiler si written once, why not invest in it maximal system knowledge? And you, ideally, should just tell it "I want to do so&so". Obviously, that's not C++ or C, and neither Java. Some scripting languages are closer to this, but hardly enough.

    Language should make easy to program efficiently and hard to program inefficiently. Current languages fail to do this, they are mostly just high-level assemblers. That's pretty bad - in 30 years people could invent something better.

    --
    -- Si hoc legere scis nimium eruditionis habes.
  62. Re:C++ IS NOT TYPE SAFE! by Tom7 · · Score: 1

    An AC flames:

    "Do you not know C++? he specifically mentioned dynamic_cast which will throw an runtime type exception for unsafe casts (this is where java lifted the idea). Your criticisms stem from ignorance. "

    I say:

    I fully understand dynamic_cast. The presense of safe features does not make a language type safe -- only the complete lack of unsafe "features" can.

    Java is type safe because it does not have an unsafe cast. (Nor pointer arithmetic, manual memory management, or non-checked array access).

    C++ is not type-safe because even though you can do a lot of the same dynamic checks as in Java, there are features of the language which let you do undefined things.

  63. Re:Blame the Language by Perdig · · Score: 1

    Should we blame the language? Should we blame the programmers? Should we blame Intel? No! Blame Canada! :)

    --
    ---- Email is reversed
  64. Your Really Bad Solution by Tom7 · · Score: 2


    An AC says:

    "duh, this one is really easy to solve. wrap delete with an inline function that checks if the pointer is NULL, deletes, then sets it to null.

    no more multi delete problems. (of course, you really should fix the bug that causes you to delete the pointer twice, but you can't really blame the language for your own ineptitude...) "

    I boggle, and respond:

    Wow, now THERE is a severely misinformed post.

    #1. I'm contending that we use more advanced languages because they make life easier for both good and bad programmers, not merely compensate for "ineptitude".

    #2. Your solution is 100% wrong.

    C * a = new C();
    C * b = a;
    delete a;
    delete b;

    'b' is a different memory location, which isn't set 0 when 'a' is deleted. Unless you're implicitly suggesting that we move to memory handles (which is going to give you MUCH worse performance than modern languages which just don't let you write this kind of program), your solution doesn't solve anything at all.

  65. snprintf by Tom7 · · Score: 1


    Always use snprintf:

    char buffer[256];

    snprintf(buffer, 255, "Hello %s, how are you?", name);

    (or just use a language which has type safety and bounds checking).

    1. Re:snprintf by mikpos · · Score: 1

      You don't *always* need to use sprintf(). Actually more often than not, I know the length of target string before sprintf()ing (especially when working with strings). snprintf is still handy, though.

    2. Re:snprintf by rpk · · Score: 1

      But how to do you know you know the length of the final result (I think "target" is not the right word) string ? Unless there is some way to prove it, the destination buffer could, in theory, overflow. For example, even if one of the formatting arguments is a char[LENGTH], where LENGTH is a constant, it could be missing a null terminator ! snprintf will guard against that case.

    3. Re:snprintf by mikpos · · Score: 1

      Because often times, if the target buffer is just a concatenation of other strings, e.g.: sprintf(foo, "hello %s, happy %s-%s, %s", ...), 'foo' is a dynamically allocated buffer, and the length of that buffer was calculated by the strlen()s of the strings that are going into it.

      Even when dealing with numbers (%d, etc.), if it's a constant format string, you can determine the length of the string. The expressions for calculating that can get complicated, but they should be calculated at compile-time and so won't be expensive. If you're using field-with dealies (e.g. %05d), it's even easier :).

      The point is that it's usually very easy to calculate the length of the string needed. For strings, use strlen() unless you know the length of the string at compile-time. For numbers, a bit of math is needed. These will usually be much faster than a corresponding snprintf() call.

  66. by the way... by Tom7 · · Score: 1


    It's practically impossible to avoid new and delete, which also make the language unsafe. (try deleting a pointer twice).

    1. Re:by the way... by lpontiac · · Score: 1

      Actually, the C compiler will parse and translate that code just fine. At which point you, the moron that wrote such broken code, have the problem.

    2. Re:by the way... by Tony-A · · Score: 1

      Even better:
      Allocate A;
      Free A;
      Allocate B;
      Free A;
      Allocate C;
      Store into B;
      Betcha C has got some problems.

    3. Re:by the way... by Tom7 · · Score: 1


      " Actually, the C compiler will parse and translate that code just fine. At which point you, the moron that wrote such broken code, have the problem. "

      That's exactly the point he was making! Except it might not just be you with the problem, it might be the people who download and use your program.

      Refer to the original claim: C/C++ are not appropriate for security-critical work.

  67. Re:"new" vs. "old" programmers by Tom7 · · Score: 1


    An AC says,

    >

    I say:

    This is a pretty good point; dumb people will always be doing dumb things.

    But I think that if everyone were using a type safe language, there would be fewer security holes. The reason is this: With a type safe language, no matter how dumb (or extremely clever) you are -- it's impossible to invoke "undefined behavior" and start executing code that wasn't part of the original program.

    I think the most common thing would be unescaped user input with shell metacharacters included as part of a command. (how many perl mail scripts have we seen with remote exploits?) I actually believe type systems could probably keep people from doing that accidentally -- but even if they didn't, we still would never see a (now) very common class of exploits.

  68. OO Basic! by invenustus · · Score: 1

    Shhhh! Don't mention OO Basic near my university's Comp Sci department... they'll do anything to inconvenience students!

    In all seriousness, however, how DO you write OO Basic? I am a big fan of the OO paradigm, but I owe the creators of BASIC for instilling a love of coding in me at a young age. Has this actually been done?

    --
    grep -ri 'should work' /usr/src/linux | wc -l
    1. Re:OO Basic! by locust · · Score: 2
      In all seriousness, however, how DO you write OO Basic?

      Lets say you have three variables that define the properties of some object and you have two operations (methods) on those three variables that are then done to/performed on that object. You then stipulate that no access will be made to those properties, except through your two methods. Now when you write the rest of the code you think of these three properties and two methods as one thing.

      This is a not as precise an answer as I would prefer to give. The problem being that it all has to do with what's going on in your head as the programmer.

      --locust

  69. arrays vs pointers by Tom7 · · Score: 1


    Arrays are not the same as pointers, but that doesn't have any bearing on the argument.

    Arrays are just const pointers.

    1. Re:arrays vs pointers by mustermark · · Score: 1

      You can also do some nice, efficient array transformations with common blocks. For example, you can turn a 100x100 array into a 10000x1 array inside a subroutine. This helps the mind and the compiler. It also allows some flexibility with what you have in memory, since you know everything in the common block will be put together in memory. This eliminates the need for pointers, per se.

    2. Re:arrays vs pointers by Tony-A · · Score: 1

      By const pointer, I assume your mean that the value of the pointer does not change.
      What constrains the value of the index into the array?
      You can do pointer arithmetic in Fortran by using indexes and a single carefully placed array.

      Array A[10], B[10]
      Unless there is something that prevents me from accessing B[3] by means of A[13], including indirectly via subroutines, .... I forgot, what was the argument anyway?

    3. Re:arrays vs pointers by Tom7 · · Score: 1


      Right, the value of the pointer can't change.

      Nothing constrains using it as a pointer (doing pointer arithmetic and dereferencing), other than that you can't assign to its pointer value. That's why the fact that pointers are not the same as arrays is a pedantic aside rather than an important part of the discussion.

    4. Re:arrays vs pointers by mikpos · · Score: 1

      While kind of cute, it's not strictly true. Arrays act as constant pointers in many respects, but there are some instances (most notably with the sizeof operator) where they act very different from pointers.

  70. Re:Obligatory Poll Mastah Poll by The_Messenger · · Score: 1
    Hmmm...

    Regarding #1: Ha ha ha.

    Regarding #2: Programmers are often at the mercy of the compiler author and OS code. Not all buffer-overflow expoits are the fault of the programmer.

    Regarding #3: Wow, thanks for giving thousands of /. script kiddies a weekend project

    Regarding #4: To the contary, I think that it's valuable protection against unskilled (but malicious) users and lazy sysadmins.

    Regarding #5: Most crackers lack either the knowledge or dedication to bother with anything like that. They'll have to wait until someone codes a tool for them. :)

    Regarding #6: Well, I agree in principle. This story was both Overrated and Flamebait. At least it's not another crappy anime story, eh Taco? Don't get me wrong; I love a few anime series, but I prefer computer-oriented stories. (Yeah yeah, Lain, we know.) And while I could block the topic in my user preferences, I'm not always logged in. But now I'm just whining.

    My own offtopic note: anyone else notice that Slashdot recently aquired the "slashdot.com" domian? Wow, Rob has really dumbed this place down since that Washington Post article.

    ---------///----------
    All generalizations are false.

    --

    --
    I like to watch.

  71. Re:definitely the language by Tony-A · · Score: 1

    Open range is faster and easier than dealing with well-tended fences. Unfortunately benchmarks measure what they can measure and the victor wins by shirking safeguards.
    Buffer overflows have been solved long ago, and the solvers are dead. IBM 1401, Burroughs.
    The worst is that the buffer overflow exploits, like the web defacements, are minor nuisances. The effect of storing the 11th element of a 10 element array can be rather damaging.
    The language is the right place to attack the problem, but the language exists at many different levels. There is also a problem in that there may be several different ways to interpret a set of bits in memory. There is also a problem in that it is much easier to point to something than to precisely delimit the extents. Language is the key, and it needs to be a box not a point. Not easy, not backwards compatible. Much that is running today is broken but nobody realizes it. When the buffer overflows, et. al. are handled, these programs will not run because they are in fact broken. Closed source or too lazy, you cannot fix the buffer overflow problem. Open source, just maybe.

  72. Re:C++ IS NOT TYPE SAFE! by Tom7 · · Score: 1


    Dead Beef proclaims:

    "That's a bizarre definition of "type safe". How do you accomplish anything at a system level without pointers, etc.?"

    This is the only definition of "type safe" I know of, and I read a lot of programming language journals and would have expected to come upon the "right" one if I had it wrong.

    Java is type safe. Though it is dynamically typed (you can get run-time type exceptions, and unfortunately it must make run-time type checks), you can't make it start executing abitrary code. That is, there aren't any undefined situations in Java.

    "Please explain how one can do anything in a strongly typed, inheritance-based language without casts?"

    (properly checked) casts can be safe, as they are in java. It's tragically clear, though, that you've never stepped outside the Object-oriented paradigm - ML, for instance, is a functional language which has static typing (no runtime casting or type errors) and real type safety (my definition: programs can't crash, no matter what).

    There are in fact extensions to ML which allow system-level programming (they wrote a network stack, for instance). But most applications that compromise security are network apps, not system apps -- fingerd, sendmail, apache, ftpd don't need pointer arithmetic. They could all be rewritten in a modern language.

  73. Re:Blame the programmer by Cowardly+Anonymous · · Score: 1

    Sure you could blame the programmer, calling him a bad programmer, but seriously how many programs have bufferoverruns and similar problems?
    I bet most of the more advanced programs you are running have or have had such problems. I bet programs like Apache have or have had them (don't blame me if it doesn't, it was just an example =))!
    Why? Well I wouldn't say because of bad programmers, rather because of a language that allows buffer overruns to happen easily. I mean even the best programmers makes mistakes. Mistakes of this kind are easy to make.

    Languages like Java have checking against overruns but the main argument why not to use Java seems to be speed.
    Sure checking for Exploits of this kind makes the programs slower but it's worth it!

    I heard rumors that Ericsson have started using Java despite it is slower than C, why?

    First because it takes less time to write a program because lots of code is already written, which saves money.

    Secondly because it is easier to debug, you are less likely to make errors (easier syntax, etc), which saves money.

    They are just 2 examples, in a big project they can save lots of money, which means that they can by a faster computer that makes up for the fact that Java i slower than C.

    Sure Java isn't a perfect language for everyone and every program but it's an alternative one should consider when starting to make a program.

    --
    There are two types of dirt: One dark kind that sticks to light objects and one light kind that sticks to dark objec
  74. Re:C++ IS NOT TYPE SAFE! by gaw · · Score: 1

    That's a pretty pathetic argument. Firstly, that's like saying guns aren't capable of killing people, as long as you don't use them. That they can kill people, regardless of whether they are used or not, is an inheirant potential in them. So saying C++ is typesafe by telling people not to use any unsafe operations is similarly incorrect.

    Secondly, it is possible to crash C++ programs even if you never use any unsafe constructs. For example,

    int* foo;
    std::cout << foo[0] << std::endl;

    Oops, I segfaulted. Okay, so I used a pointer, let me give you another example:

    vector<int> foo;
    std::cout << foo[10] << std::endl;

    Segfault, you lose.

  75. And here's the real beauty... by Chris+Burke · · Score: 2

    So having separate address spaces for code and data might cause problems. self-modifying code still exists, etc.

    But the cool thing is -- you can just make the page tables regarding the code address spaces point at the same pages as the data (and vice versa), and do this at page granularity. So you can make an 8k buffer that is read/write/execute (but accessed with different linear addresses when used as code or data) for your genetic programming, but keep the rest of your program safe.

    VM tricks are so much fun. ^_^

    --

    The enemies of Democracy are
  76. Re:C++ IS NOT TYPE SAFE! by Tom7 · · Score: 1


    mikpos says,

    "... there's complete type safety (of a language unknown to me) ..."

    Here are three examples of completely type safe languages: Java, ML, Haskell.

    I'll agree that there's such a thing as incremental improvements in the amount of typing. Programming in C is a little easier than assembly, and C++ a little easier than C. This has a lot to do with the type system (also a lot to do with syntax).

    But there's something really nice about programming in what you call "completely" type-safe: No matter what, you know that your bugs aren't those weird Heisenbugs you get when you accidentally write over malloc's bookkeeping, toast your return address, or free something twice. You don't get this in a "mostly" type-safe language.

  77. What a great great man -thanks Timothy by gad_zuki! · · Score: 4

    What if everyone displayed such grace?

    Or what if everyone bothered to do some research before writing and self-promoting some inane rant.

  78. Re:Its not intel's fault(history) by Stephen+Samuel · · Score: 5
    When intel came out with the 808[68], they wanted to make it as compatible with the 8085 as possible. It really was 16-bit. The data code and stack segments were 64K wide. Segment registers that gave you overlapping segments with a 16 byte granularity.

    If you used the segment registers, the result was basically a highly non-linear address space. In a lot of ways, it was an 8 bit processor with 16 bit registers and hardware bank switching (for those of you that remember bank switching).

    as a result, there were a few 'standard' memory models that programmers used:

    • Small address space: All segment registers the same. don't touch them. This gave you a flat 16bit (64k)address space, turning the machine into a glorified 8085/Z80 -- almost completely source code (assembler!) compatible. It also gave a slight speed advantage, since all pointers and integers were 16 bits wide.
    • Intermediate address space: segment registers point to disjoint spaces. not too much difference but you get some breathing space since the code and data don't share the same (tiny!) 64K address space.. pointers are still 16 bits, but you now have to remember which segment you're talking to.
    • 'large' address space: all pointers are 32 bits wide. (include both segment registers and then pointers within the segments). This gives you access to the full 1M address space. (the 640K limit was because 380K was reserved for I/O space).

      SERIOUS performance hit. If you allow arrays >64K then just about every array access requires you to calculate and load the segment register. address math sucks because if you have two 32 bit addresses A and B, A != B does not necessarily mean that they don't point to the same memory, and *X++ can require some serious work to do the exepected thing.

    The 80286 allowed people to break the 1M barrier without doing bank switching (EMS?), but it turned the segment register/pointer problem into a serious horror story. Unless you were seriously masochistic (or just plain desperate) you just made it look like an 8086 that ran a bit faster.

    When they came out with the '386 you now had segments of 4GB each. This was at a time when a 2GB ram module could have been camouflaged as a desk and would have required a 15KW watt power supply.

    Most programmers and OS designers just set all the segment registers the same (the '386 equivalent of the 'small memory model', and forget about them (I called this traumatic amnesia).

    So, yes: Intel has a Segment model that could be used to provide security, but few people are brave/stupid enough to risk the horror stories/ flashbacks that enabling it might entail.

    Intel: Just short of intelligent.

    --
    Free Software: Like love, it grows best when given away.
  79. Re:Stack Overflows and Stack Direction by leob · · Score: 1

    The implementations with the stack growing toward higher addresses is somewhat less efficient. Here's why: a called function only gets the current value of stack pointer (that is usually assigned to a frame pointer register). When the stack grows toward smaller addresses, it already points to the beginning of the arguments, and (in case the arguments are of different sizes) it is enough to figure out the size of an argument to find the stack location of the next.
    <-stack grows/FP-points->| a |b| c ...
    If 'a' can tell us its size, we can find the address of 'b', etc. Not so if we simply store arguments backwards into the forward-growing stack - to obtain the address we need to know the size of the argument the pointer to which we're trying to obtain:
    | c |b| a |SP-> grows, points
    (no way to find where 'a' starts without additional info) Therefore we have to pass the old value of SP (or the total size of all arguments) to the function on the top of the stack or in an additional register, to achieve this:
    FP->| a |b| c |SP->

  80. Re:This is a very old debate.... by Royster · · Score: 1

    Doing a bit of search I found a good article abour rgis at buffer overflow it details how no exec stacks can be used to allow data to stay where it belongs and the actual stuff to be execed to always be kept in memory.

    Why don't you do some more research and discover why the poster to whom you replied said that unexecutable stack dosn't prevent buffer overflows from being possible.

    Learn what a trampoline is (and why the poster mentioned it) and why the bandaid you propose dosn't stop the patient from bleeding.

    --
    I have discovered a truly marvelous sig, unfortunately the sig limit is too small to contain i
  81. Re:It's the industry as a whole. by jetson123 · · Score: 2
    Well, first of all, you seem to agree as far as C is concerned since you advocate wrapping all those unsafe C interfaces into better C++ interfaces.

    Yes, C++ is somewhat better than C because it does allow you to build abstractions that perform more checking and automatic resource management. But even if you do that C++ is fundamentally unsafe. Why?

    C++ still uses the C pointer model and adds a similar reference model. And C++ still uses manual memory management for dynamic allocation. You cannot, in general, address those problems by creating safe abstractions. If you try, you end up severely limiting language semantics, and as soon as you face any outside library, you have to convert to raw pointers anyway.

    And C++ still does not guarantee fault isolation among modules or any way of determining from the source code of a module whether that module is safe or not. That is, any piece of code you link with can cause arbitrary problems in any other piece of code, and you have no way of telling. Perhaps you think that's inevitable, but it is not. None of the other languages that I mentioned have that misfeature.

    Arguing that one should not bother fixing those problems because there are lots of other ways in which people can make mistakes is wrong. The problems C/C++ creates for programmers are easily avoided, without performance penalty or other drawbacks. A day lost trying to chase some avoidable pointer bug in a C/C++ program is a day that could have been spent on testing and fixing some conceptual security bug.

    I have been using C for 20 years and C++ since before its first public release (nearly 15 years?). I still use them a lot because that's what interfaces best with the software that's out there. At the time, they were reasonably good tradeoffs. But this is the year 2000, and tradeoffs that were good then are not good anymore.

  82. There is no programming panacea! by Dougan · · Score: 1

    Tom,

    You're definitely in danger of becoming a one-trick pony here: in almost every post I've seen you make this summer, you've been raving about this ML stuff. I'm afraid your closeness to the project is limiting your objectivity on this issue.

    Type-safe languages (and ML in particular) are not a programming panacea: they have neat features (and I particularily like ML, especially functors which are quite a great deal more elegant than C++ templates), but they have their drawbacks: you do get nice things like type-safety, bounds checking, (in ML/Haskell/et alia) functions as first-order variables, generic programming done right......but your language features don't come for free.

    ML is never going to be as fast as C (and I know that you can optimize more aggressively because of pervasive strong typing and lack of aliasing issues, and it's an interesting research area), since the lambda calculus is not the natural paradigm on a von Neumann machine.

    Plus, performance aside, sometimes you want to use pointers, because that's the most expressive tool for what you're doing -- experienced C programmers often feel hamstrung when programming in stricter languages like Java. I like ML, I also like C, and Scheme, and Pascal, and Perl, and ..... ML doesn't necessarily work for everything.

    Blatant jingoism alert: It's like safety scissors: not going to poke your eye out, but a clumsy tool for someone who really knows how to cut paper. ;)

    Cheers,
    Greg

  83. Re:Why do people still program in C? by Requiem · · Score: 1

    Java's a great language. It was used in my first year computer science classes, which were an introduction to programming in general, and object-orientated programming specifically. If it had an ncurses-style library, I'd use it for my current project (a roguelike). But since stuff like that is against the whole idea of Java, I'm using C++ instead.

    When I said "lower level", I meant "lower level compared to the languages I just listed". C's not low level, but people shouldn't go calling it high level either.

  84. Re:Blame the Language by Kanasta · · Score: 1

    Yes, you /could/ educate the programmer, and they /could/ write a tight program in C/C++ (or even assembly).

    The point is, for each programmer that does it right, there will be hundreds of non-educated programmers doing it the wrong way.

    Why risk your business on your programmer knowing enough of their stuff. Why not just use a safer language?

    Sure, C++ programmers are tough, don't need no bounds checking, don't need to comment/indent code, but what's the price to pay when someone didn't have enough sleep on the weekend and slips in an overflow vulnerability in there?


    ---

  85. Re:Why do people still program in C? by mustermark · · Score: 1

    C is not fast. After conversion to the intermediate language, all high-level languages are indistinguishable, and that's just a tenth of the compile process. What you mean is the _compilers_ for C make fast code. C in no way lends itself to speed, with its generous use of pointers. Fortran may suck for OS programming, but it's faster than C for number crunching b/c the compilers are better and there are no weird constructs (like pointers).

    As for inline assembly and blazing loops, I doubt that many people could hand code a bit of assembly that runs faster than the compiled version. Give the compiler a straightforward loop or something, and it often knows best. You could eventually get a better optimization by hand, but the trouble is almost never worth it.

    C is small, though. But it's not like memory is a limiting factor anymore. The only time it matters is when the entire program exceeds the the CPU cache, and memory fetches start hurting you.

  86. C interpreters by Tom7 · · Score: 1

    >

    You mean, run it through the interpreter and give it every possible input it might see? Buffer overflows don't happen every time a program is run; they happen (obviously) when a malicious user supplies bad data. C interpreters can help track down bugs which happen all the time, but I don't see how they help track down the bug in question here.

    I like C too. I just think it's an inappropriate language for big programs or (especially) security-critical programs.

    1. Re:C interpreters by mikpos · · Score: 1

      Hmm that's a good point. I suppose that's where a code checker would be much more useful than an interpreter, e.g. it can draw trees of which variables get where, where they get casted into what, etc. lclint is kind of a mess, but making a backend for gcc to do this sort of thing could be worthwhile.

      I'll concede, though, that type-safe languages are well-suited for security-critical applications.

  87. Buffer Overflows by Britney+Spears · · Score: 2

    Hey dudes! I'm kinda new to this slashdot thingy here, but could some sweet, loving guy please explain the buffer overflow to me. It seems like a pretty cool idea, is it like sorta like going out with too many guys or something? help me please!

    1. Re:Buffer Overflows by Britney+Spears · · Score: 1

      Okay! You can rub me, at the next concert I have, which I believe is in New York on the 31st, you can come backstage, the codeword is "sharp-twenty". Hope we have fun!

    2. Re:Buffer Overflows by electricmonk · · Score: 4
      is it like sorta like going out with too many guys or something?

      No, I think that's more akin to what a packet sniffer does. But close!

      --
      Friends don't let friends use multiple inheritance.
  88. Re:C++ IS NOT TYPE SAFE! by jetson123 · · Score: 2
    Other potentially unsafe constructs in C/C++ are pointer dereferencing, calling a function pointer, array subscripting, and call-by-reference. Even for casts, neither a compiler nor a reader can tell whether the cast is safe or not.

    So, if you don't use pointers, address-of, array subscripting, call-by-reference, or any library functions that do, yes, then you can write type-safe C++ programs. Too bad that you also can't do much in that subset of C++.

    There is no problem with providing those unsafe constructs in a systems programming language. In fact, lots of languages do, just like C/C++. The problem with C/C++ is that the safe constructs and the unsafe constructs are indistinguishable, and that means that even the 99.9% of a program that can be written nicely with the safe constructs use the unsafe ones, and as a result are much more likely to crash.

  89. Re:Its not intel's fault by fm6 · · Score: 1
    OK, I'm a little weak on arch issues. But isn't a flat address space pretty standard on every microP except the Intel line? Which is why Linux uses a single code/data segment -- to simulate the non-segmented architecture that's considered mandatory for modern implmentations of Unix. Or so I've been told.

    Do non-intel/non-linux Unix boxes have the buffer overrun hole? If not, why not?

    I always thought that the purpose of segmented arch was to simulate the 64K address space of older processors/and or speed up pointer operations on small-scale programs. But what do I know...

  90. Re:Blame the Language by fland00r · · Score: 1

    Maybe *you* want your languages handed down from the mighty and revered standards committee. That's fine, but don't try to keep me from using neat, helpful features. Whether or not the features may come in handy

  91. Re:You wonder about the stuff they do give us.. by Tony-A · · Score: 1

    Because it is actually fixed on the Intel architecture and broken on the VAX. It's really the OS's that are broken, limiting the Intel to being only a bad version of a VAX.

  92. Re:Blame the Language by fland00r · · Score: 1

    Oops. I was -going- to say that while the features may be handy, compiling with the -pedantic and -ansi switches should provide notification for -all- non-compliant code.

  93. Re:C++ IS NOT TYPE SAFE! by 0xdeadbeef · · Score: 1

    Heheh, at first I thought he was talking to me.

    But, like I said, that is a rather pedantic definition of type safe. I don't see what pointer arithmetic, memory management, or lack of bounds checking have to do with type checking. They might encourage logic errors, but not type errors.

    Although... gcc does let me pass an array of one static length to a function that expects a different length, but that is a type error only if you consider char[3] and char[4] to be different types. I just think of them as "arrays of char", the length itself has nothing to do with the type.

    And it looks like Java does not let one assign a length to an array type, that's always an attribute assigned at run-time.

  94. Non-C distribution? by Acy+James+Stapp · · Score: 1

    Is there a Linux or *BSD distribution that does away with C programs as much as possible? I would feel more secure having the services I want to be up (httpd, ftpd, dns, proxy, etc.) if they were written in a safer language.

    I would really like a language which had and extended perl's notion of "taint"; this would probably double the security of the system by making it very difficult to do something bad.

    --
    -- Too lazy to get a lower UID.
  95. It's the industry as a whole. by jetson123 · · Score: 4
    Buffer overflow exploits don't necessarily require you to be able to run code from the stack segment. Often, it's sufficient just to change the return address (which necessarily is stored on the stack) to some useful routine, or to change a bunch of bits that are used for a security check.

    The underlying problem is that C/C++/Objective-C do not have mechanisms to protect against these kinds of problems. In fact, it's impossible to write substantial programs in those languages that use only "safe" constructs. This is a peculiar and fundamental bug in the C-family language design.

    There are excellent alternatives around. Modula-3, Oberon, Ada, Sather, and Eiffel all have efficient, free, open source implementations around, they all provide access to unsafe features when needed, and one of them should satisfy anybody's programming needs. Java is an excellent applications and server programming language, although it has a bit more overhead and no access to low-level features.

    So, folks, get with the program and stop writing servers and other applications in C/C++.

    1. Re:It's the industry as a whole. by jetson123 · · Score: 2
      Can you name any significantly large piece of software written in [Modula-3 or Ada] that I could examine?

      For Modula-3, go to www.m3.org and follow the links (a whole operating system with various network services has been written at it and is still in use at U. Washington). For Ada, you'll have to talk to your local defense contractor; lots of real-time military systems are written in it, so it definitely gets the performance (Ada is a bit too pedestrian for my taste, so I don't follow it much). For Oberon, the entire Oberon operating system, drivers, compiler, web browser, and other things are written in it, and they are open source.

      you must be talking about run-time fault-tolerance and correction. When you need to do this sort of thing, then people most certainly break things down into modules seperated by process lines. A dataabase server or the TCP stack are both great examples of this.

      If you haven't noticed, relational database performance on UNIX sucks. It takes milliseconds to get any data out of the damned thing, which is why everybody is using stored procedures, which means they put code back into a single process. I have not seen any TCP/IP stack under UNIX systems that is "split up along process lines"; if the Linux or SystemV TCP/IP stack crashes, so does the whole kernel. Both of these examples make my point.

      Although it can be done to some degree, it would of course be incredibly difficult to create a class of smart pointers for each and every type of pointer use. Also, as you note, you would have to use those pointer types everywhere, which is another big strike against them. This kind of wrapping is not what I'm talking about.

      But it's the kind of wrapping I'm talking about, and it's the kind of wrapping that is necessary to make C++ a safe language.

      The claim was that you can have other pointer models and not sacrifice any speed. I'm having a hard time imagining this, as "the C pointer model" mirrors the hardware very closely. I'm very, very willing to be corrected.

      The problem with C/C++ pointers is not that they model the hardware very closely. The problem is that they aren't typed sufficiently finely: heap and stack allocated arrays, displaced arrays, references to stack variables, references to locations in data structures, heap allocated data structures, etc. are all represented by a single type, a "pointer". Other languages use different static types to represent those different constructs. And those constructs are different because they are associated with different object lifetimes and different opportunities for (optional) runtime error checking.

      Adding those extra static types to distinguish the different meanings of "pointers" has no runtime overhead at all. And if you (for some reason) need to convert among the different static types, a call to "unsafe::convert_..." would do the trick, again, with no overhead, and would indicate that something funny was going on.

      The way it is in C/C++ right now, the compiler just doesn't have the information to give meaningful compile time warnings or errors. It also doesn't have enough information to insert efficient runtime error checks if the programmer wants that for debugging. Ultimately, the lack of static type information is even counterproductive for generating efficient code on upcoming architectures.

    2. Re:It's the industry as a whole. by FooBarson · · Score: 2

      The underlying problem is that C/C++/Objective-C do not have mechanisms to protect against these kinds of problems. In fact, it's impossible to write substantial programs in those languages that use only "safe" constructs.

      I should note that the above use of the word "impossible" is misinform{ed,ing}, and bias{ed,ing}.

      Management of buffers is a low-level detail that only needs to be taken care of once. Hiding details such as this is something that a good C++ programmer can do with elegance.

      If you write a C++ application that uses intelligent string classes such as the STL's std::string, then it becomes very possible to write buffer-safe programs. In fact, it's kind of hard to use std::string in such a way that it does break. (Of course, you have to deal with the fact that all the syscalls use char[]'s rather than string objects, but most of those syscalls should also probably be wrapped in classes -- See the ACE lib).

      As mentioned in other posts, it's often just as easy to create security problems (and other data-integrity-destroying bugs) in other languages.

      If there is a "fundamental bug" that causes thesee problems, it's the low standard that we currently hold software to. Not even bringing in certain high-profile/buggy pieces of software into the picture, I can speak from personal experience on this one. Quality is a distant second to rapid deployment in many domains. Well-written and bug-free code is a subtle thing to enjoy, but one that I think will eventually come into greater popularity.

      So if we could all, as engineers, begin to refuse to produce sloppy code in the face of deadlines and such, I think this type of situation will eventually fix itself.

      Just my thirty pieces of silver's worth.

    3. Re:It's the industry as a whole. by FooBarson · · Score: 2

      Well, first of all, you seem to agree as far as C is concerned since you advocate wrapping all those unsafe C interfaces into better C++ interfaces.

      Yeah, pretty much so. Well-written C is attainable, of course, but the benefits of C++ are certainly worth switching.

      C++ still uses the C pointer model and adds a similar reference model. And C++ still uses manual memory management for dynamic allocation. You cannot, in general, address those problems by creating safe abstractions. If you try, you end up severely limiting language semantics, and as soon as you face any outside library, you have to convert to raw pointers anyway.

      Both the "C pointer model" and the manual memory management are easily wrappable. "Initialization is resource acquisition" is elegant and easy to stick to. You can also easily wrap the interfaces to the other libraries, as I said before. It can all be done very safely if you keep direct pointer operations to a minimum and thoroughly check them as you do. I feel that this extra bit of planning can be worth the power that is gained.

      Using string manipulation as a specific example, exactly what about std::string "severely limits language semantics"?

      And C++ still does not guarantee fault isolation among modules or any way of determining from the source code of a module whether that module is safe or not. That is, any piece of code you link with can cause arbitrary problems in any other piece of code, and you have no way of telling. Perhaps you think that's inevitable, but it is not. None of the other languages that I mentioned have that misfeature.

      Sure there is. See man 2 fork, or CORBA

      Arguing that one should not bother fixing those problems because there are lots of other ways in which people can make mistakes is wrong. The problems C/C++ creates for programmers are easily avoided, without performance penalty or other drawbacks. A day lost trying to chase some avoidable pointer bug in a C/C++ program is a day that could have been spent on testing and fixing some conceptual security bug.

      No, good programming practices are what prevents bugs. IMHO there isn't much difference between the various type-safe languages in bug prevention, but there is a huge difference between the various programming practices and quality standards. I have talked with plenty of folks who claim that there's "no performance penalty or other drawbacks" to not having the power of C/C++'s low-level control, but I haven't seen anyone back that up with proof. I would really enjoy for someone, anyone, to prove otherwise.

    4. Re:It's the industry as a whole. by jetson123 · · Score: 2
      Both the "C pointer model" and the manual memory management are easily wrappable.

      They are wrappable only in special cases. They are not wrappable in general.

      For example, you can't "wrap" call-by-reference or the address-of operator because smart pointers aren't really pointers--inheritance gets screwed up.

      Using string manipulation as a specific example, exactly what about std::string "severely limits language semantics"?

      You can make strings reasonably safe, but strings are probably the easiest case. The hard part is data structures that refer to each other.

      Sure there is [a way to achieve fault isolation in C++]. See man 2 fork, or CORBA

      That's not fault isolation in C++, it's fault isolation in the operating system. That kind of approach has a lot of overhead. That's why programs like Netscape or Emacs are multi-megabyte executables composed of dozens of libraries, rather than a bunch of small, communicating, separate processes.

      It also doesn't help a lot, since even running in separate processes, it's really easy for a process to corrupt (e.g., array index error) the data it then sends on to another process via CORBA; you still can't tell who did it in C++.

      Whether you believe me or not that fault isolation through processes can't be used in many cases, the fact is that people don't use it, and that alone is indication enough that we need a different mechanism.

      No, good programming practices are what prevents bugs. IMHO there isn't much difference between the various type-safe languages in bug prevention, but there is a huge difference between the various programming practices and quality standards.

      There isn't much difference among the various type safe languages in terms of bug prevention, but there is a huge difference between them and C/C++.

      I have talked with plenty of folks who claim that there's "no performance penalty or other drawbacks" to not having the power of C/C++'s low-level control, but I haven't seen anyone back that up with proof. I would really enjoy for someone, anyone, to prove otherwise.

      Go use Modula-3 or Ada or any of the other languages. If you want to, you can write code in them that is identical to C++, including all the unsafe constructs you want: C++ constructs translate one-to-one into those languages.

      The difference is that those languages have a well-defined, safe subset that people can use to write programs in.

      Of course, the compilers and tools for those languages are inferior to C++--because of their smaller user community. Many Modula-3 compilers don't do cross-module inlining, for example, so they will look worse on benchmarks. But that's a chicken-and-egg problem: because of the small user communities, they compilers don't get better, so everybody keeps suffering with C++.

    5. Re:It's the industry as a whole. by SEAL · · Score: 1
      No, good programming practices are what prevents bugs. IMHO there isn't much difference between the various type-safe languages in bug prevention, but there is a huge difference between the various programming practices and quality standards. I have talked with plenty of folks who claim that there's "no performance penalty or other drawbacks" to not having the power of C/C++'s low-level control, but I haven't seen anyone back that up with proof. I would really enjoy for someone, anyone, to prove otherwise.

      Amen to that. I write games for a living, and I eat, live, and breathe C++. Even as low as our 3D engine code, we've written our own "safe" versions of many troublemakers. Our replacement might be a macro or might be a complete class.

      But I actually like this because seeing these macros every day makes our coders aware of what's a potential hole and what's not. And that makes them better programmers.

      You'd be surprised how many vulnerable perl-based cgi scripts I saw in my ex-sysadmin days. People think just because it's Perl they are totally safe.

      Now obviously as a game coder, C/C++ has many performance advantages for me. But I strongly believe that meticulous attention to detail, especially in a team environment, produces some of the most reliable code.

      I can't directly disprove the claim that there's "no performance penalty or other drawbacks" in the type safe languages. But from my experience, I'll tell you a couple areas C/C++ shines for games:

      • Networking. TCP/IP is kindof losing favor with games nowadays. UDP has some advantages but it only really shines after quite a bit of work. IP networking code has much more history in C than anything else. Working in C/C++ pays off here when making in-depth modifications and looking for good examples. Bottom line: better game network performance.
      • Low level 3D functions. Handling a moderately large BSP tree can start to hit your performance in a hurry if you're not careful. C/C++ are good for handling this.
      • 3rd party support. If we want to, say, enhance performance by supporting the new Intel instructions, we pretty much have to write in C/C++ and use their compiler.
      • Memory management. In a game, calling new / delete gets expensive pretty quickly. It also fragments memory. We tend to get around this using free lists and other tricks. Some of this stuff is possible because we know -exactly- what's going on with memory management. In a language where this stuff is abstracted away from you, it would become problematic.

      Phew. Hope that wasn't too wordy. I'm not a language bigot - I believe there's a proper place for each one. But C/C++ often gets a bad rap because of inexperienced programmers using it, or people using it in a place it's not well suited.

      Best regards,

      SEAL

    6. Re:It's the industry as a whole. by FooBarson · · Score: 1

      Both the "C pointer model" and the manual memory management are easily wrappable.

      They are wrappable only in special cases. They are not wrappable in general. For example, you can't "wrap" call-by-reference or the address-of operator because smart pointers aren't really pointers--inheritance gets screwed up.

      We are talking about two different kinds of wrapping here.

      Although it can be done to some degree, it would of course be incredibly difficult to create a class of smart pointers for each and every type of pointer use. Also, as you note, you would have to use those pointer types everywhere, which is another big strike against them. This kind of wrapping is not what I'm talking about.

      I'm talking about doing responsible things like making the management of a given resource and the pointer to that resource a task of an object. I would say that this is not only something that can be done, but is something that should be done in almost every single circumstance. You get all the power but not nearly as many bugs.

      Using string manipulation as a specific example, exactly what about std::string "severely limits language semantics"?

      You can make strings reasonably safe, but strings are probably the easiest case. The hard part is data structures that refer to each other.

      Of course, strings are probably the most common source of buffer overflow problems. This is why I brought up this specific example. There are a lorge number of generic classes in the STL that can manage resources well, like std::vector, std::list, and so on, none of which "limit language semantics".

      But I do agree that here are times when it is tricky to do this sort of thing generically, and it is in these circumstances that you create a non-generic class to deal with it.

      Sure there is [a way to achieve fault isolation in C++]. See man 2 fork, or CORBA

      That's not fault isolation in C++, it's fault isolation in the operating system. That kind of approach has a lot of overhead. That's why programs like Netscape or Emacs are multi-megabyte executables composed of dozens of libraries, rather than a bunch of small, communicating, separate processes.

      It also doesn't help a lot, since even running in separate processes, it's really easy for a process to corrupt (e.g., array index error) the data it then sends on to another process via CORBA; you still can't tell who did it in C++.

      Whether you believe me or not that fault isolation through processes can't be used in many cases, the fact is that people don't use it, and that alone is indication enough that we need a different mechanism.

      Are you asking how do we do an autopsy on the situation? That's easy... single process and one core dump. You can't be meaning that... you must be talking about run-time fault-tolerance and correction. When you need to do this sort of thing, then people most certainly break things down into modules seperated by process lines. A dataabase server or the TCP stack are both great examples of this.

      No, good programming practices are what prevents bugs. IMHO there isn't much difference between the various type-safe languages in bug prevention, but there is a huge difference between the various programming practices and quality standards.

      There isn't much difference among the various type safe languages in terms of bug prevention, but there is a huge difference between them and C/C++.

      Just because type safety *can* be violated by wacky uses of objects doesn't mean that it isn't type safe. If people on a project are going to abuse the language, they're going to do it regardless of what language is going to be used.

      [ Snipped talk about Ada and Modula-3 ]

      Can you name any significantly large piece of software written in either of these two languages that I could examine?

      The claim was that you can have other pointer models and not sacrifice any speed. I'm having a hard time imagining this, as "the C pointer model" mirrors the hardware very closely. I'm very, very willing to be corrected.

  96. This is a very old debate.... by tytso · · Score: 3

    This is a very old debate, and it's been raised on the kernel list several times. The problem is that it seems pretty clear that given a buffer overrun attack which can be exploitable without the stack-exec patch, it's possible to transform that attack into an exploit which will work with the stack-exec patch present.

    It may require more work to create the exploit, but it's the sort of thing which only one person needs to do and then share with 100,000 of his best friends on some cracker web site. Hence, such a patch only provides the illusion of security, and it adds crap to the kernel. (There's all sorts of kludges you have to put in there to make sure that trampoline code doesn't break, etc., etc.)

  97. Re:Why do people still program in C? by The_Messenger · · Score: 1
    I mostly agree.

    Yet there are cases where C or C++ should be used:

    1. Task is low-level and any other language would be missing the needed speed/power/freedom/whatever.
    2. The task is part of an existing project, which is written in C or C++.
    3. Company already has too much invested in third-party C/C++ libraries.
    4. Company already has too much invested in C/C++ programmers. Retraining involves money, time, and some not-so-optimal code being produced while the programmer masters the new langauge
    5. No Java environment available for your platform

    Having said that, I think that all C++ programmers should seriously look into learning at least the fundamentals of Java (most of which, as C++ guys, you already know). I also think that if you're choosing a language in which to implement a new project, think twice before just jumping into C++. Yes, I'm a Java zealot.

    And I hate to nit-pick, but C is not really low-level. I instead think of it as the only "medium-level" language, and this is part of why it's so useful. You can't write a device driver in VB, and you can't (reasonably) write an office suite in x86 assembly, but you can do both in C. Yes, Java does place more restrictions on you (although if you're an OOP nut like me, you don't really mind). This is why Java is the ideal language to teach OOP, because even if you think in strutured or procedural programming terms, you are forced to implement them in OOP constructs. C++ allows you to go with either way, and some people enjoy that freedom.

    ---------///----------
    All generalizations are false.

    --

    --
    I like to watch.

  98. Java by Tom7 · · Score: 1


    Tee hee. I've encountered the JDFB before. ;)

    Java compiled to machine code would be a very appropriate way to implement the network daemons that are so often the "root" (so to speak) of security problems in unix.

    I'm not a big Java fan (it has its weaknesses) but here the important issue is type safety, which Java definitely has. It also has name recognition and a familiar paradigm.

  99. Its not intel's fault by bored · · Score: 5

    The problem isn't Intels fault because the arch has an execute bit in the segments. The original idea was you put your code in a separate code segment from your stack and data segments. The real problem is OS designers who for various reasons decide that the x86 arch's segmentation should be ignored and set the code segments equal in size to the data segments and stack segments. It then becomes a simple matter to just jump into the data or stack segment and begin executing code.

    Of course since most of the OS's don't properly use the protection mechanisms Intel has provided, I guess it becomes Intels fault if they don't extend the arch to support a feature and potentially break downward compatibility with other OS's using the current paging system.

    1. Re:Its not intel's fault by jovlinger · · Score: 2

      Now this is an interesting topic. Are pointersafe languages more or less safe from a hacking perspective?

      Normally, the easy answer is more safe, in a paretro-optimal sense of the word. However, there is always the urge to go from the [presumably expensive] address-space switching architecture to the [presumably cheaper] thread switching architecture when you go pointer safe.

      You can do this because you trust the compiler, so separate applications will be unable to access each other's memory.

      Of course, if it turns out that the compiler was untrustworthy, then you have a real problem on your hands. Now I don't mean that the compiler is compromised (a-la the wonderful gcc/login hack), but rather that a bug in its overflow protection code enables malicious explioits.

      Since compilers are difficult to write, and typically not (?) audited for security, I'd be interested if anyone had had any experiences along these lines?

    2. Re:Its not intel's fault by Tony-A · · Score: 1

      Except for hardware designed to run Multics, a flat address space is probably the only possibility.
      Any system that allows "coloring outside the lines" will be susceptible to buffer overruns or worse. And they all do with possible exceptions of such as Ada, Algol68, LISP, or some of the modern languages.
      I think the purpose of the segmented arch was to allow some degree of separation of different things into different logical segments, but it turned into a mess of segment address arithmetic to turn 48-bit pointers (16-bit segment+32-bit offset) into a 20-bit (real mode, to break the 64k barrier) or 32-bit (protected mode) pointer.
      To protect against buffer overruns (character string to character string), there is probably nothing since to equal the IBM 1401 machine language. Move A to B where A is longer than B and B is NOT overrun. Used word marks and record marks in addition to the 8 data bits.

    3. Re:Its not intel's fault by tzanger · · Score: 1

      Almost every 386+ OS has not used segments the way Intel intended. So yes, they've had quite a few years (more than a decade) to add an execute bit, if they actually cared.

      Intel processors do have an execute bit for each selector. Or did you eman something else?

    4. Re:Its not intel's fault by Greg+Lindahl · · Score: 3


      Almost every 386+ OS has not used segments the way Intel intended. So yes, they've had quite a few years (more than a decade) to add an execute bit, if they actually cared.

    5. Re:Its not intel's fault by Schnedt+McWapt · · Score: 1

      For some reason, the 80386 Programmer's Reference Manual is one of the documents that has almost completely disappeared from availability. Try to find a copy of it you can download anywhere. I did for quite some time. Eventually I got luck when my department moved and some older software engineers threw away their paper copies.

      Why doesn't Intel want that book to be available? Is it deprecated?

    6. Re:Its not intel's fault by Tony-A · · Score: 3

      This is from an Intel 80386 Programmer's Reference manual, a bit dated, but should be still valid.
      There are 4 privilege levels. Does anything other than Multics use more than 2?
      Code, Stack, and Data exist in completely seperable address spaces.
      A running process has access to some 8000+ local 32-bit address spaces and some 8000+ global 32-bit address spaces.
      A selector can specify a buffer to byte granularity.
      Basically, the problem is that in current systems, CS, SS, and DS all point to the same nice linear 32-bit address space. Away with segmentation. It's a bit more complicated than that, but in general, most code can be read and written, most data can be executable.
      The problem has been solved many times. I think some of the old Burroughs computers did some neat things. Unfortunately the good ones die because of a 5 or 10% performance lag, or they refuse to run certain bugs without complaint.

      Executable code on the stack??? Seems like a very bad idea.
      Null terminated strings. Nice trick, but miss a \0 or try to handle raw binary, and you have severe problems.

      Will anything get solved? Probably not. Any solution will break existing code, or more realistically, discover that the existing code was already broken, only nothin knew or cared about the consequences.

  100. Re:C++ IS NOT TYPE SAFE! by jetson123 · · Score: 2
    The problem is not the presence of unsafe constructs in C++, the problem is that the unsafe constructs are indistinguishable from the safe constructs.

    In C++, this might look like:


    char *p = unsafe::allocate(char,100);
    char c = unsafe::ref(p,10);
    float f = unsafe::castref(float,p,0);

    Of course, C++ would also need to eliminate the unsafe constructs it has outside namespace "unsafe", and in some cases add safe constructs to replace them. Then, you could limit the use of unsafe constructs to only the few places where you actually need them. That greatly reduces the probability of making errors. Languages that do this exist: Modula-3, Oberon, and others. There are no such languages in widespread use yet that look like C or C++, unfortunately.

  101. Blame the Language by Tom7 · · Score: 5

    Blame the language! C and C++ continue to be inappropriate for security-critical work.

    Aside from speed-critical stuff like kernels and Quake 3, I don't see the need to write programs in C and C++ any more.

    Let's start using modern languages with type safety. They're easier to write programs in (because debugging is easier) and not that slow.

    I know that I'd gladly take the 2x speed hit on my security-critical apps (mail daemon, web server, ssh, etc.) to know that they cannot have this kind of bug in them, because they were written in a language like ML, Eiffel, Haskell, or even Java.

    1. Re:Blame the Language by jason_aw · · Score: 1

      > The compiler doesn't produce random machine code

      Neither do most programmers. (I know a few that do, but that's besides the point)

      The point is, saying it's "impossible" to show that a program written in C is blatantly not true.

    2. Re:Blame the Language by pod · · Score: 1

      You can't practically write OO code in languages that do not directly support it. Sure, your nifty templated C++ gets turned into assembly somewhere along the line (in fact a friend of mine developed a simple OO based utility (mini-os actually) in 68k assembly) but how much time are you spending. I think what is meant here is that you can write OO-like programs... encapsulation being the biggest part here, and a lot of discipline. After you've programmed something like C for a few years you almost can't help but do things this way, it's too hard to debug otherwise.

      --
      "Hot lesbian witches! It's fucking genius!"
    3. Re:Blame the Language by jkorty · · Score: 1
      Educate the programmer on *why* things like sprintf, strcpy, etc. are Bad Things

      sprintf isn't so bad if one uses something like %.20s instead of %s.

    4. Re:Blame the Language by Salamander · · Score: 2

      >There is a new breed of C programmers, though. They don't assume Unicisms, PDPisms or TheirPlatformisms,

      Instead, they have their very own set of blind spots and biases and bad habits. Non-viable mutants are a "new breed" too, but that doesn't mean they're an improvement.

      --
      Slashdot - News for Herds. Stuff that Splatters.
    5. Re:Blame the Language by Salamander · · Score: 2

      >You can't practically write OO code in languages that do not directly support it.

      Totally wrong. I and thousands of others have been doing this for years, and it seems quite "practical" to us. Languages that directly support OO are only marginally more convenient than non-OO languages such as C; the OO languages' advantages have more to do with standardization of notation than with actually enabling an OO code structure.

      --
      Slashdot - News for Herds. Stuff that Splatters.
    6. Re:Blame the Language by Phil+Gregory · · Score: 1

      Hmm. What browser are you using? Strictly speaking, that's incorrect behaviour, since these are (according to the HTML spec) SGML character references. An SGML character reference is defined as an ampersand followed by a alphabetic string, optionally terminated by a semicolon. ("Optionally" because any non-alphabetic character implicitly terminates the reference.) Thus, '&ltI' is a valid SGML character reference. For an HTML rendering agent, however, there is no defined 'ltI' character reference (there are, in fact, no other references beginning with 'lt'), and it is understandable behaviour to assume a semicolon was omitted and try to figure out what the actual reference was. The underlying HTML remains non-W3C-compliant, though.

      I'll finish with the W3C's note on semicolons in HTML character references.

      In SGML, it is possible to eliminate the final ";" after a character reference in some cases (e.g., at a line break or immediately before a tag). In other circumstances it may not be eliminated (e.g., in the middle of a word). We strongly suggest using the ";" in all cases to avoid problems with user agents that require this character to be present.

      --Phil (Some people call me "anal retentive". I prefer to think of myself as "pedantic".)
      --
      355/113 -- Not the famous irrational number PI, but an incredible simulation!
    7. Re:Blame the Language by Bob+Uhl · · Score: 2
      I know that I'd gladly take the 2x speed hit on my security-critical apps (mail daemon, web server, ssh, etc.) to know that they cannot have this kind of bug in them, because they were written in a language like ML, Eiffel, Haskell, or even Java.

      You might be willing to take that hit, at least in theory, but it is rather doubtful that most people would. If I said to a manager that simply by switching languages we could double the speed of our product, at the expense of needing to code more carefully, he would leap at the chance. And I would back him up. I recall a chart in a course at school which plotted four areas. I don't recall what they all were, but I do remember that we are currently at the point where speed in all its incarnations is what matters: time-to-market, execution speed, response time . When the market begins to tighten, then things will necessarily change. There may even come a time where computers are so fast that they can do all the silly stuff like bounds checking properly with no noticeable slowdown. I rather doubt it; as processing power increases, so too will demand for that power.

      What we need are better-trained programmers. It's not very hard to ensure that arrays are the appropriate size, to check the length of input strings and to make sure that subscripts are within range. This can all be done quite easily in C, and still be much faster than one of the 'lame' languages (I use the term lame to mean a language without the ability to do low-level twiddling, not as a term of derision).

    8. Re:Blame the Language by AME · · Score: 2
      Stroustrup once said something like "I find almost every use of the term 'C/C++' to be indicative of ignorance."

      Well that's his own fault, isn't it? Stroustrup could have called it anything, but he chose `C++' as the name.

      So he makes a language that has syntax strikingly similar to C with a name which was a homage to the old language (one part `C' and one part `a C operator'), then calls people who lump them together as similar languages "ignorant."

      Please!

      --

      --
      "I have a good idea why it's hard to verify programs. They're usually wrong." --Manuel Blum, FOCS 94
    9. Re:Blame the Language by QuoteMstr · · Score: 5

      Like a system, and langauge can be as secure or insecure as you can make it. One can write an extremely tight program in C++ while writing one in Perl or Java that leaves gaping security holes open.

      Educate the programmer on *why* things like sprintf, strcpy, etc. are Bad Things, don't force them to use a Bondage and Discipline-style language like RPG or Java that forces the programmer to do what the *language designer* thought to be The Right Thing.

      Instead of using a new language that probably wouldn't be suited to the task, why not write something like lint, but for security holes?

      Also...

      *PEOPLE SHOULD ENABLE ALL WARNINGS ON THEIR COMPILERS. WARNING CATCH MANY BUGS AND OTHER NASTY THINGS THAT WOULD OTHERWISE BE IGNORED.*

    10. Re:Blame the Language by mikpos · · Score: 4

      You should be blaming the programmers from 10 years ago. The *only* C programs that I have seen that have one of:
      - gets()
      - scanf()
      - poor use of *scanf() or str*()
      are programs that have (a) been written 10 years ago; or (b) written by programmers who learned how to code in C 10 years ago. Yes, there are stupid technical school and high school teachers too, but normally, before anyone gets to a level where they can do something useful, they will have found a clueful reference to get rid of all that nonsense.

      There is a new breed of C programmers, though. They don't assume Unicisms, PDPisms or TheirPlatformisms, and their eyes actually burn a whole through their skull upon the mere sight of gets(), scanf(), or any of the other death traps.

      C is a good language. C++, of course, is not, though (hey, if you can get modded up for ignorant flamebait, why can't I?)

    11. Re:Blame the Language by AME · · Score: 2
      If I had mod points left, I'd call your post "Funny"!


      --

      --
      "I have a good idea why it's hard to verify programs. They're usually wrong." --Manuel Blum, FOCS 94
    12. Re:Blame the Language by QuoteMstr · · Score: 2
      C is a good language. C++, of course, is not, though (hey, if you can get modded up for ignorant flamebait, why can't I?)

      I'd rather not start a language flamewar, but I must defend C++.

      C++ is "of course" not a good language? Why? You can do everything you can do in C in C++, and then some. If you don't like templates, don't use them. If you don't like operator overloading, don't use it. Unlike certain other languages *cough*Java*cough*, it doesn't force any particular paradigm on you.

      That said, OO programming has many advantages over traditional C-style procedural programming, and using an OO language for it, furthermore, has many advantages over using hacked-up C to emulate it, ala GTK+.

      Yes, some of the features in C++ can be implemented in C, but the resulting implementations are *more* prone to bugs.

      Polymorphism can also be used for security --- If you want to add something in a procedural C program, you must update the code wherever that new things apprears or affects something else. If you want to do the same in OO-C++, by virtue of polymorphism, the new object can be used whereever the old one was.

    13. Re:Blame the Language by Dag+Hammerskjold · · Score: 1

      TYPE SAFETY BY ITSELF DOES NOT IMPLY ANY SPEED DISADVANTAGE AT ALL.

      A nonoptimizing Oberon-2 compiler produces code that executes at close to the speed of optimized C++. Strong static typing is not slower than weak static typing. Naturally, if one uses dynamic type checks in Oberon there is a cost. But at least one has the option.

      sr

    14. Re:Blame the Language by Tony-A · · Score: 1

      That's funny. The only difference I've noticed is that /. seems to handle a lot more traffic without succombing itself to the /. effect.
      Just look how long (ie short) it has taken for the commentary to this to get saturated.
      Whoever or whatever, they are dong something right.

    15. Re:Blame the Language by Anonymous Coward · · Score: 1

      This is total nonsense. In the end every compiled language gets compiled into the same x86 code that a C or C++ program gets compiled into. Therefore the problem then becomes a compiler problem. The compiler could (without any extra work on the part of the programmer!) emit code that protects against buffer overflow attacks. Indeed, the StackGuard compiler does just that.

    16. Re:Blame the Language by talignmen · · Score: 2

      On the contrary, blame the programmers.

      Yes it is completely true that C and C++ have unchecked pointers and array bounds that are frequently the source buffer overflow issues. However, any serious C programmer *knows* these issues exist.

      The problem is that many programmers do not take the time to harden their programs against such attacks. They are often too focused on the program's real purpose to bother with security.

      I should also point out that there are vulnerabilities in programs written in Perl (I'm not trying to pick on Perl specifically BTW). Often a CGI script can be passed a syntactic boobytrap in a parameter. Programmers can be lazy and forget about good input validation the same way they forget about overflow issues.

      Another situation that programmers frequently miss is how the program behaves in low memory conditions. It is all to easy to assume that a memory allocation (implicit or explicit) will succeed. This may not result in a vulnerability, but it points to the larger problem.

      The bottom line is that making programs resistant to attack requires attention to detail. Since this usually requires more effort on the part of programmers, we shouldn't be surprised that it is usually ignored.

    17. Re:Blame the Language by cduffy · · Score: 1
      "you can take a pointer, set it to a random address, and fuck with the data there" -- whazzat?

      Familiar with that wonderful thing known as memory protection? (Yes, I _know_ it doesn't apply to your process's own memory space -- but in the event that someone tries to dereference a garbage-filled pointer, what are the chances that that will occur significantly? And even if by some change it does, there are tools/techniques for finding the cause of the damage).

      I don't doubt that having a properly safe language provides security/debugging improvements over an OS implimenting memory protection, but my question is at what cost these improvements take place; I've had more than one Nifty Little Trick from C that I simply couldn't do (without a slower workaround) in Java.

    18. Re:Blame the Language by Phil+Gregory · · Score: 1

      And, while we're enlightening people, you really need semicolons to mark the ends of your special characters: '&lt;', not '&lt'. Otherwise, they run into the next word and are usually rendered literally by the browser.

      '&ltI&gt' becomes '&ltI>' whereas '&lt;I&gt;' becomes '<I>'.


      --Phil (I wish more people understood the HTML they used to post, or at least used 'Prieview'.)
      --
      355/113 -- Not the famous irrational number PI, but an incredible simulation!
    19. Re:Blame the Language by WNight · · Score: 2

      Microsoft didn't release source code and encourage everyone else to make the same changes and/or suggest new ones.

    20. Re:Blame the Language by Tom7 · · Score: 1

      QuoteMstr proposes,

      "Instead of using a new language that probably wouldn't be suited to the task, why not write something like lint, but for security holes?"

      Well ... I for one prefer the *guarantee* that the program has no buffer overflows. (The languages I listed above have this property.)

      This can NEVER be done in an unsafe language C, since it would be tantamount to solving the halting problem.

    21. Re:Blame the Language by sjames · · Score: 2

      and their eyes actually burn a whole through their skull upon the mere sight of gets(), scanf(), or any of the other death traps.

      IIRC, gcc issues warnings if gets is used. Personally, I would like to see it redifined in the standards to: 'print insults to stderr at runtime and segfault immediatly'. That would help to identify offending code more quickly.

    22. Re:Blame the Language by Mr.+Barky · · Score: 2

      I see a great many posts throughout this discussion that say things like "blame the language", "real programmers wouldn't ever make a mistake like that - it's only schmucks who write programs with buffer overflows". I think these posts are completely missing the point.

      First, even if you had, say, a perfect language in which you couldn't possibly overflow any buffers (in theory), there still might be bugs in the compiler for that language which could be exploited. In the end, all programs are machine language. As long as it is possible for an executable to write to executable memory, it will be done. The only way of eliminating this problem is through hardware (and an OS that uses the hardware features).

      Second, even great programmers make mistakes. Have you ever written a bug free program of any reasonable length? Having a language that prohibits a totally unnecessary feature (e.g. writing beyond the end of an array) means that programmers cannot make that mistake (though it is still possible that the compiler might screw up the bounds checking...).

      Reality is such that C and C++ are the dominant programming languages, which means that buffer overflows are significantly more likely, which means that it is even more important for the operating system to police it, if you want good security.

      Good program design prohibits (or at least makes very difficult) that which shouldn't be done while making it easy to do the things you want done. It can (and should) be done in the language. It can (and should) be done in the OS.

    23. Re:Blame the Language by Tom7 · · Score: 1

      A frustrated AC babbles,

      "They're easier to write programs in (because debugging is easier) and not that slow. ...the very next sentence... I know that I'd gladly take the 2x speed hit... Oh man, this got a 2??? Mod that ill-logic into oblivion."

      I wonder,

      Care to explain? I'll gladly defend the points I made, if you can make your rebuttal clearly.

    24. Re:Blame the Language by Tom7 · · Score: 1

      An AC flames,

      " I won't Alright, go write an SSH server in VB then, see if anyone cares. Do you even know what type safety is? "

      And I say:

      VB was not one of the languages I proposed. You seem to be implying that safe languages are in a class with visual basic (ie, not very interesting for "good programmers"). On the contrary, there are lots of type-safe languages which are MUCH more interesting and powerful than C (ML and Haskell being two of these).

      And yes, I know exactly what type safety is.

    25. Re:Blame the Language by jason_aw · · Score: 1

      > This can NEVER be done in an unsafe language C

      Oh? I'm fairly sure machine code is /also/ "unsafe", and that's what your pretty source code ends up as. How do you prove that your oh-so-wonderful language is still safe when rendered into raw machine code?

    26. Re:Blame the Language by mikpos · · Score: 1

      Well to be fair, *all* of the features in C++ can be written in C. What you gain in C++ is type safety, which is a feature I think better left to language checkers, such as (but not necessarily) lint.

      That said, the biggest problem I have with C++ is that Bjarne just wasn't satisfied with putting in object-oriented syntactic sugar, or even just the kitchen sink. It seems like every little feature that crossed his mind (or the mind of any of his friends) was put in there. I think he could learn a lot from the approach that Objective C used (Simula vs Smalltalk flamewars aside).

    27. Re:Blame the Language by /ASCII · · Score: 1

      I can easily undestand why checking if a given program has buffer overflows can be translated into solving the haltingproblem, but when writing a new program it should be relatively easy to avoid any possible overflows by doing the right thing. (No evil typecasts, no intentional out-of-buffer reads, etc)

      I find that EXTREMELY hard to belive what you are saying, considering the heaps of Java to C downcompilers that are scattered around the web.

      I think the point one should make is that whith modern languages, the compiler does a lot of work FOR YOU, so it doesn't take any longer to write a robust program in Java than it takes to write a buggy, crashing piece of crap in C.

      --
      Try out fish, the friendly interactive shell.
    28. Re:Blame the Language by Schnedt+McWapt · · Score: 1

      In some cases it doesn't help to turn on all warnings with GCC. The 'pedantic' and 'ansi' switches on the GNU C compiler don't trap out all deviations from the ANSI standard. Doing so would defeat the GCC team's 'embrace and extend' campaign to encourage programmers to slowly let GNUisms creep into their code, so that eventually nothing will build on any compiler except GCC.

      The issue forms the basis of a long drawn out Usenet thread on comp.lang.c last year. Read up on it. GCC is an aggressive 'embrace and extend' language. It puts Microsoft's Java to shame.

    29. Re:Blame the Language by jetson123 · · Score: 2
      There are lots of ways in which you can create security holes. Many of them are shared between Java and C++. But buffer overruns are a huge risk in C/C++ because the language forces programmers to use unsafe constructs at every turn. And, an even bigger problem than the lack of security is just the lack of reliability of C/C++-based systems. C was a great design in the 1970's when it needed to run on 64k PDP-11's. In 2000, it's an anachronism. And the C/C++ family is not fixable without serious incompatible changes.

      In part, people like you are the problem who view this as an issue of "being forced" by "bondage and discipline-style languages". In fact, languages like Modula-3 don't "force" you to do anything. You can cast, convert, and crash as much as you want. But unlike C/C++, when you do, you use different constructs from those you use for normal programming. By default, Modula-3 checks, and that's by far the more useful case. The same is true for most other system programming languages: they provide both safe and unsafe constructs, but you can actually do something useful staying within the safe constructs. It is only C/C++ that forces programmers to use unsafe constructs and makes it impossible for compilers or lint-like tools to do checking.

      Languages like C/C++ only hang around because they have a user community. They are entrenched in the same way the Windows 3.1 architecture or other bad, outdated standards are entrenched. It's hard to break out of that because all the tools and APIs are created for C/C++, so that anything else is at a disadvantage and appears cumbersome in comparison.

      But realistically, if you want to write reliable, safe programs without expending a huge amount of time and effort on tracking down bugs, you need to dump C/C++ and switch to one of the many alternative, existing, high quality systems programming languages. The sooner we make the change for the industry as a whole, the better.

    30. Re:Blame the Language by 3r33t+h4x0r · · Score: 1

      Nice technique, but you lose style points for posting it AC.

    31. Re:Blame the Language by QuoteMstr · · Score: 2

      Where am I forced to use an array or raw string in C++? I can use STL containers and std::string, respectively. They are *much* safer.

  102. This is just plain silly.. by verbatim · · Score: 1

    It comes to a point where you have to say, thats just really REALLY silly.. I mean, who's putting these stories through?

    It's like saying FORD is responsable for car wrecks, or Delta is responsable for plane crashes (well.. okay.. maybe Delta is, but not Ford... so lay off).

    Yeah, Intel makes chips.. code that runs on these chips is potentially exploitable? this articles solution is to make the chip more complicated instead of working towards better software.

    It seems to me that if you consolidate code into libraries (as is the latest fashion statement) and stop re-inventing the wheel, then you can focus on actually FIXING the problems and plugging the holes.

    Now some of the shi..err..stuff in there does make sense... like having a memory flag that says 'don't write here', but I get confused over how that gets controlled... if you have memory that is tagged with 'don't write' then how do you re-allocate the memory once the program is done? If the OS can turn off that flag, chances are some hacker is gonna figure out how to as well... they'll write some nifty exploit and the scr1pt kiddies will run with it... we'll be right back with the same problem.. software..

    oh well.

    --
    Price, Quality, Time. Pick none. What, you thought you had a choice?
  103. Re:bounds checking in C = halting problem by F2F · · Score: 1

    > What you are forgeting is that the halting problem is partially solvable. You can easily make a procedure that says "Yes, this program terminates on this input" for any program that does terminate.

    Or (hehe) how will you answer this question: "will this so called 'halting problem solution program' halt given a specific program?" :P

    You see, you just described a program that 'recursively enumerates' the set of all programs that terminate in a given time (say the time you're willing to wait for them to ternimate)... The problem discussed was *decidability* -- whether you know *for sure* that this program will terminate...

    Yes, there are partial solutions to that too.. but the two are not even close

  104. Re:C++ IS NOT TYPE SAFE! by jetson123 · · Score: 2
    Pointer arithmetic and lack of bounds checking are the ways in which programmers in languages other than C traditionally did casts. Consider the equivalent of (I have seen these in old Fortran and Pascal code):

    struct Cast { int x[1]; float y; };
    int float_bits_as_int(float f) {
    Cast c;
    c.y = f;
    return x[1];
    }

    Here is another example:

    int float_bits_as_int(float f) {
    float *p = new float;
    *p = f;
    delete p;
    int *ip = new int;
    int v = *ip;
    delete ip;
    return v;
    }

    These "logic errors" are related to type errors: they allow the bits of an object of one type to be interpreted as the bits of an object of another type. A system that's type safe guarantees that that doesn't happen.

    In any case "type safety" doesn't just mean compile time type safety. Java has a lot of runtime type safety, where type errors are caught at runtime, not by the compiler. That's still fine for many purposes. C++ has neither.

  105. strict code/data sections by fence · · Score: 2

    I wouldn't blame the intel architecture, but..

    There are architectures (Gould/SEL-32/xx is one) that allow for and, in some cases, insist on strict divisions of code and data pages. The code sections are read only, and will generate a fault if an attempt to write to it occurs from a non-system level.

    The data sections are read/write, but you cannot branch there.

    It makes it a bit difficult to write self-modifying code, but not impossible if you really need to.
    ---
    Interested in the Colorado Lottery?

    --
    Interested in the Colorado Lottery or Powerball games?
    check out http://colotto.com
  106. couldn't we prevent the "erasable return adress"? by renoX · · Score: 1

    if you store the return adress on the stack BEFORE the buffer, then an overflow in the buffer would only corrupt the data and could not modify the return address, no?

    It would require a change on the ABI, so it's unlikely that this modification happens anytimes soon of course.

    It is so obvious that I must be mistaking, could someone tell me where I'm wrong, or is it the ABI change which makes it impossible??

  107. "type safe" by Tom7 · · Score: 1


    "But, like I said, that is a rather pedantic definition of type safe. I don't see what pointer arithmetic, memory management, or lack of bounds checking have to do with type checking. They might encourage logic errors, but not type errors. "

    Well, the definition of "type safe" doesn't really matter as far as the argument goes, as long as we understand what each other means. Typing is indeed a separate issue from safety (though we usually get safety through typing); maybe it should just be called "safety".

    But I caution you in case you ever pick up the ACM Transactions on Programming Languages -- to the PL community, "type safe" means that the language does not posess any unsafe features whatsoever.

  108. Re:No by Salamander · · Score: 1

    • Executin code off the stack is extremely helpful



    Can you give some examples? Specifically, can you give some examples of where building the new executable code on the heap rather than the stack isn't just as helpful?

    --
    Slashdot - News for Herds. Stuff that Splatters.
  109. Re:Why do people still program in C? by macshit · · Score: 1

    Unfortunately, "BetterC" has the side-effect of making your program look like it was written in fortran...

    --
    We live, as we dream -- alone....
  110. definitely the language by Aardappel · · Score: 1

    Buffer overflows can be tackled at many levels, but to me only the language one makes sense. We've had >50 years of computing and we are still firmly entrenched in using languages where we have to do bounds checking manually! efficiency shouldn't be an issue either.

  111. Intel says use the SEGMENTS by BLBishop · · Score: 2

    The article putes quotes around the words "code" and "data" and that is the problem. In i386, CODE segments can either by read/execute or execute only. DATA segments can either by read/write or read only - not execute.

    So what is an Intel-baesd, flat-mode program to do? It sets up two segments - one data, one code - pointing to the same memory. Goodbye hardware security.

    Of course the VM doesn't protect against execution - that is the segmentation system's job. Linux (and anything else that assumes a 68k or VAX flat address space) just blows it off.

    Simple solution - bring back seperate code and data. Excuse me, I and D. Just like the PDP-11 UNIX grew up on.

  112. www.eros-os.org by jcr · · Score: 1

    For an example of an OS that does in fact use the hardware to enforce encapsulation.

    EROS is a pure capability-based OS. A read capability is disctinct from write capability, is distinct from a start capability, is distinct from a resume capability.

    Buffer overflows are the fault of the implementers of the OS and the apps in question, and they can't push the responsibility off on the languages. Anyone who doesn't know by now that C doesn't have strings or arrays, shouldn't be writing any code that needs to be secure.

    -jcr

    --
    The only title of honor that a tyrant can grant is "Enemy of the State."
    1. Re:www.eros-os.org by Tony-A · · Score: 1

      Looks interesting. I'll be glad when and if something like this becomes mainstream.
      I think you will find persistence across system crashes to be fiendishly useful. Like recursion in print calls IO-error calls print. Recursion is necessary to unwind gracefully, instead of getting stuck in print returns to IO-error returns to print returns to IO-error ad infinitum.

  113. Re:Why do people still program in C? by Malc · · Score: 1

    You're right. I've been programming C++ for about 6 years solid and I find it hard. I realise how much effort it takes to write good C++ code when I program in Java... the whole time I'm worrying that I'm forgetting something because it's so much easier! Even so, I wouldn't ever work on a straight C job as I can't express my self in that language and it lacks many features of C++ that I find reasurring from a software engineering perspective (see, I'm brainwashed!).

  114. Ah-hah... by ChrisRijk · · Score: 2
    I was thinking that it would be unlikely to be a particularly x86 problem, because I know buffer overflows are also a problem on other CPUs and OSs even ones that are supposed to be secure.

    Thanks for that.

  115. Bounds checking and C. by BillGodfrey · · Score: 1

    For a language like C to have bounds checking, a compiler would have to insert code into the target object code file to check the bounds. Also, any arrays passed to a function as a pointer would also need to have the bounds passed in as well.

    So that's two extra compare instructions per array index and an extra size_t per function call.

    You can keep it.

    By all means, make it an option. The C standard puts bounds breaking under a category called "Undefined behaviour", meaning that a compiler can do anything. Generate an error, core dump, make demons fly out of your nose.

    But require bounds checking. No thanks.

    Bill, likes C.

  116. C#? by EverCode · · Score: 1

    With everyone bashing C and C++ here, maybe they should *upgrade* to C#?

    Haha, maybe not. I am hoping for the second coming of Java though.


    "...we are moving toward a Web-centric stage and our dear PC will be one of

    --

    EverCode
  117. bounds checking in C = halting problem by Tom7 · · Score: 1


    >

    No, it really is true. Define the problem rigidly and I will give you a reduction to the halting problem, easily.

    It boils down to the fact that an address in C can come from anywhere -- from arithmetic, or the result of evaluating an expression, running another program, anything. Proving at compile time that this pointer points somewhere "safe" is tantamount to statically predicting that the program terminates. And Turing has given us a great proof that this is impossible in general.

    1. Re:bounds checking in C = halting problem by aznel · · Score: 1

      Define the problem rigidly and I will give you a reduction to the halting problem, easily.

      What you are forgeting is that the halting problem is partially solvable. You can easily make a procedure that says "Yes, this program terminates on this input" for any program that does terminate. It would go something like this:

      #!/bin/csh
      #run using: halt file.c input
      gcc $1 -o program
      ./program $2
      echo "Yes, this program terminates on this input"

      You can even get more complex and create a procedure that can say things like "This program doesn't halt for a while (not for 100M cycles)" and even (for particular program/input combinations) "No, this program doesn't terminate on this input"

      This procedure would solve the halting problem that most normal (non-CS) people actually care about -- "Damn, I must have a bug in my tree lookup because it isn't halting"

      Similarly you can write a procedure that says "Yes this C program is safe" for most programs and "You might want to take a look at this part" for the others.

  118. Grace by Salamander · · Score: 1

    By slashdot standards, withdrawing such a poorly thought out piece of crap may seem graceful, but in many other environments people are routinely expected to be graceful enough to refrain from publishing such tripe in the first place.

    --
    Slashdot - News for Herds. Stuff that Splatters.
  119. Makes me feel better... by chuckw · · Score: 1

    I guess this makes me feel better. I know that half (or more) of the code I write would be laughed at by better programmers. It doesn't stop me from coding though. Like my Dad always says, "No matter how good you are, there's ALWAYS someone better!". So big deal, Bruce made a mistake. It makes me feel good about the fact that I can only do the best I can do and I can't waste my time (too much) worrying about how good someone else's code is.

    Thanks Bruce...


    --
    Quantum Linux Laboratories - Accelerating Business with Linux
    * Education
    * Integration
    * Support

    --
    *Condense fact from the vapor of nuance*
  120. Non Executable Stacks by Darren.Moffat · · Score: 1

    The SPARC chip has the concept of eXecute bit for pages.

    In the SPARCv7/v8 ABI the eXecute bit must be set by default to be ABI compliant but Solaris from 2.6 onwards provides the facility to turn off the eXecute pages on the stack by updating the /etc/system file with the nonexec_user_stack=1.

    The SPARCv9 (64Bit) ABI has the eXecute bit for stack pages off by default.

    However having said all that, it is still possible to exploit buffer overflows but it does provide a basic level of protection.

  121. The unsafe C library by Animats · · Score: 4
    One particular problem with C is a history of unsafe standard library functions, such as sprintf, strcat, and such, which just happily output into an array of char with no checking whatsoever. Those functions were deprecated back in the 1980s, and there are safe versions with output size limits like sprintf, but there is still far too much code that uses the old ones.

    They need to be deprecated more forcefully. All the unsafe functions should be pulled from the standard C library and moved to something like "deprecated_unsafe_library.h". All set-UID programs need to be purged of those functions. Now. Any manufacturer shipping a system with those functions in a security-critical program should be sued for gross negligence.

    1. Re:The unsafe C library by Animats · · Score: 2
      Here, because someone was confused about this, are the safe functions you should be using.
      • int snprintf(char *str, size_t len, const char* format, ...)
      • char* strncat(char* s, const char* append, size_t count)
      • char* strncpy(char* dst, const char* src, size_t len)
      Note that len argument, which is the length of the destination area. With a correct value of len, these functions cannot cause buffer overflows, unlike sprintf, strcat, and strcpy, which are totally unsafe.

      Want some cred in the open source world? Grep for those in major projects and fix them.

  122. Crap. Good point. by bkosse · · Score: 1

    So, the question is: is there an efficient way to do this in a macro?

    --

    --
    Ben Kosse
    Remember Ed Curry!
  123. It's a serious problem, but... by Mark+A.+Rhowe · · Score: 1

    Buffer overflow attacks form a substantial portion of all security attacks simply because buffer overflow vulnerabilities are so common and so easy to exploit.

    However, buffer overflow vulnerabilities particularly dominate in the class of remote penetration attacks because a buffer overflow vulnerability presents the attacker with exactly what they need: the ability to inject and execute attack code.

    The injected attack code runs with the privileges of the vulnerable program, and allows the attacker to bootstrap whatever other functionality is needed to control (or "own") the host computer.

  124. Re:Efnet #Linux "Secure Linux" by _Gnubie_ · · Score: 1

    Yes - this is the libsafe i mention in my previous post. It causes some programs to crash or behave badly. - for example XV coredumps.

  125. how a buffer overflow is written by TheOnceler · · Score: 2

    Here's a pretty good description of how to write a buffer overflow: ftp://ftp.technotronic.com/rfc/phrack49-14.txt Jim

  126. Re:Efnet #Linux "Secure Linux" by _Gnubie_ · · Score: 1

    Like every RPM, DEB you download you of course can never be 100% certain of its integrity. You cant even be confident of the integritiy of source unless you meticulously read each line. At some stage you simply have to trust ppl :).

    Packages signed with keys are all very well but how mant ppl actually verify them?. How many RPMS have you grabbed from rpmfind.net and installed. ?

  127. Intel has the same thing. by yerricde · · Score: 2

    Intel's 386 protected mode has "code" segments and "data" segments. Writes to code cause a segfault. Branches into data cause a segfault. But if the OS points the code and data segments at the same area of RAM, the 386 doesn't care.
    <O
    ( \
    XGNOME vs. KDE: the game!

    --
    Will I retire or break 10K?
  128. Haiku by talonyx · · Score: 2

    The Tao of Buffers
    Escapes most but plagues many.
    Has Intel caused this?

  129. Care to explain by LunaticLeo · · Score: 1
    So you overflow the stack allocated char[] (or whatever); write a return address; the return address jumps you into some part of libc.

    What part of libc? How is any code in libc usefull without a function call setup?

    Wait, I think I get it. Your tailor your overflow to write a return adress AND overwrite the previous functions stack layout so that when the libc code executes it uses the previous (now overwritten) stack. You've also writen the stack so that upon a return from function the registers are poped from the stack that you've tailored.

    Plus or minus some code. I think I now get it.

    It is still quite a bit harder than current shell code.

    --
    -- I am not a fanatic, I am a true believer.
  130. Re:C++ IS NOT TYPE SAFE! by Tony-A · · Score: 1

    Nonsafe:
    Read or write reference to any array.
    Casting is safe enough. The problem is that any indirect reference to any kind of array is unbounded and capable of accessing all of available memory.

  131. Re:Why do people still program in C? by Skapare · · Score: 2

    If you don't like C, fine. But I do like C and I use C. Again, fine. Different code for different folks. Where you're wrong is making a blanket statement as to why people use C. I won't deny that you could find people who actually believe that reason. I use C for entirely different reasons. But I won't tell you what the reasons are, because I'm not flaming you about specific reasons; I'm flaming you for generalizing totally inappropriately.

    --
    now we need to go OSS in diesel cars
  132. Re:What a great great man by Frodo · · Score: 1

    If you mean Bruce, I guess he did this not for self-promotion (I guess he has enough already), but because he though so. So now he's convinced he was wrong. Great he recognised his mistake and corrected it. To err is human, everybody can do stupid things. I did them many times. But it is much harder to come before the crowd and say: "Well, guys, sorry, I was stupid, now I see it, thanks for pointing out". Believe me, not everybody has common sense and brains to do this.

    --
    -- Si hoc legere scis nimium eruditionis habes.
  133. Uh-oh, I've opened a real can of worms, haven't I? by Bruce+Perens · · Score: 2
    OK, I'm back from a day with family, offline. I withdrew my article about 1PM after it became clear that there was a lot I'd not understood when writing it that the kernel list folks, etc., could tell me. I think I'd like to write this one again when I understand it better.

    Meanwhile, does anyone remember the IAPX 432? It was a flop for several reasons: ADA flopped, its performance was bad, it was a real departure from the architectures of the day. But it had some real innovations - every function ran in its own protected space, using message passing for communication, and your program could protect itself from itself. Is it time to revisit that sort of architecture?

    Thanks

    Bruce

  134. Dissecting the Buffer Overflow Problem by Crispin+Cowan · · Score: 3
    For a great deal of technical data on how buffer overflows work, and how to stop them, read this paper. While I appreciate the plug that Bruce gave me for StackGuard, it does seem that he has not researched this topic very well:
    • Make the stack non-executable: Yes, this works, and security-conscious people will use Solar Designer's Kernel Patch to do that. It works great.
    • Make the data segment non-executable: This works a whole lot less well. Too many UNIX programs depend on being able to execute code in the data segment. This is UNIX's fault, not Intel's fault.
    • Use the MMU For Enforcement: Ancient Burroguhs mainframes (the 6500 IIRC) actually stored each array in a separate segment. They also ran like a dog compared to modern RISC(y) architectures. We tried the MMU approach for StackGuard in 1997, and it imposed an 8000% overhead to do it that way. Read about it in this paper.

    Crispin
    -----
    Immunix: Free Hardened Linux
    Chief Scientist, WireX

    1. Re:Dissecting the Buffer Overflow Problem by Inoshiro · · Score: 2

      All that does is change the exploit from a stack overflow, to a slightly different kind of stack overflow. The bandaid would work at first, but after a few months, all the kiddie exploit tools would work in a new way.

      Linus Torvalds (and other kernel designers) have posted exaclty how to defeat a Solar Designer patches kernel as an example. Read the kernel traffic and then realise that this sort of thing is a not a long-term success measure. The programmer must always be careful when designing a program, and no anal-retentive language or kernel-patches can protect you from bad code.
      ---

      --
      --
      Internet Explorer (n): Another bug -- that is, a feature that can't be turned off -- in Windows.
  135. Re:Why do people still program in C? by IvyMike · · Score: 1

    A lot of C could be written in something better, but C (or C++) is pretty much mandatory for a lot of tasks.

    Ask Linus.

    Ask Larry Wall.

    If you're involved in a LARGE project (millions of lines of code across dozens of large packages) it's pretty much a necessity to use something like C++. (Eiffel and Ada probably fit the bill here too, but I have no hands-on experience with either )

    P.S. Pascal isn't high level. Pascal is C, simplified for teaching, but much much worse.

  136. Re:Why do people still program in C? by jetson123 · · Score: 2
    GNU Sather and SmallEiffel compile to C, and there are versions of the DEC Modula-3 compiler that compile to C as well. Java, of course, also has implementations for many platforms.

    As I said myself, those languages have smaller user communities, and that means they have fewer libraries and tools for them. But you can call C and C++ code from them and they are quiet usable, in particular on Linux.

    I don't recommend doing everything in them, but give them a try for some projects, in particular open source projects for Linux. That's the only way this chicken-and-egg problem of moving beyond C++ will get addressed.

  137. You wonder about the stuff they do give us.. by avandesande · · Score: 1

    Intel won't do anything to fix their aching old archtitecture, but they'll give us MMX.

    MS needs to include a browser, but to hell if we need virus protection or some other os level protection against rouge processes.

    --
    love is just extroverted narcissism
    1. Re:You wonder about the stuff they do give us.. by 1nt3lx · · Score: 1

      If you're unhappy with the archtitecture why wait for Intel to "fix" it? Get a Mac, Alpha, Sparc, or VAX.

      Don't be stupid because your mom said you could..Be stupid because you are.

  138. Efnet #Linux "Secure Linux" by _Gnubie_ · · Score: 2

    As someone who sees attemplts against his own system on IRC every day and sees newbies announce to the world at general "Hi I'm running wu-ftpd on Redhat 6.0 and ARRGHH what the hell just happened?" who's this guy on my box!?" I decided to investigate the feasability of providing safe versions of commonly run services.

    Libsafe is quite good but cant catch everything and breaks quite a few programs if you set it up in ld.so.preload.

    The Stackguard compiler is definitely more robust and seems to work well during the course of my tests.

    I've prepared RPMS of BIND8.2.2pl5 and Wu-FTPD 2.6.1 with Stackgaurd 2.0 Stout for RH Linux 6.2.
    As I've just prepared the rpms this week on my Slackware 7.1 system I dont know how well they perform as they haven't recieved a great deal of testing (No bug reports so far tho)

    The RPMS are available at http://indigo.ie/~fowler/ELSL/ with more daemons to come soon and hopefully DEBS. Try them out and mail me with any problems (My email address can be read from the reuslts of rpm -qpi file.rpm)

    Good luck and keep safe on the net
    Gnubie_ Efnet #Linux

  139. Re:Blame the Programmer by Goonie · · Score: 2
    _Many_ (if not most?) security attacks involve buffer overflows. You have to _work_ and _think_ to free yourself of buffer overflows in C/C++. In other languages, this protection comes for free.

    What about that huge chunk of interpreter, written in C or C++? Have you audited that, too?

    In a higher-level language, the simplest code can have side effects that might provide a security hole, so to reassure yourself you're going to effectively have to audit the behaviour of the interpretation of your program, not just the program itself. In C, at least, you know when you're making a function call, and you can be reasonably confident everything your program does is done explicitly rather than being hidden.

    I went to a rather informative lecture by a person whose business is selling security services and also works on OpenBSD. His view was that C programs, calling a minimal set of libraries (excluding GUI libraries, amongst others), are the only things that should ever be suid root.

    --

    Any sufficiently advanced technology is indistinguishable from a rigged demo
    --Andy Finkel (J. Klass?)
  140. Blame the programmer by RichMan · · Score: 2

    Don't blame the hardware, don't blame the language, blame the programmer. Relying on the hardware to fix bad programming style is like a parachutist relying on a safety net.

    Any input operation that overwrites memory it is not supposed to, is bad programming style. Ideally the programmer does not know what hardware their code will run on, maybe it will be a flat memory machine with 0 memory managment hardware.

    In C scanf("%s",foo) is nice and handy for little programs. But it is not production level code. Production level code should instead always use limited length routines. So it is a little harder, maybe the first implementation has to be audited to remove the screw ups. This is like checking the return values on printf and scanf nobody does in the test code, but damn well better be done in the final code.

    Programmers need to limit themselves to limited input routines or at the start of the project development build a little library of limited input routines.

    What someone really needs to do is come up with a "no-overrun libc" that does not included any unlimited input functions and spits horrible messages whenever a standard input function is called with arguments allowing unlimited input.

    You link and run development code against this library and fix any place where it screams.

    I really am suprised big development houses don't do anything like this. But of course no one has time to do it right.

  141. -fbound_check option ? by bockman · · Score: 1

    I remember having seen a -fbound_check option on
    a compiler on a SUN machine, but I'm not sure if it was the GNU C-compiler or the SUN C-compiler.

    I was almost sure it was GCC, but I can't find anything related on my Linux box ( and I've checked in the architecture-specific flags ).

    Does anybody knows anything about ?

    --
    Ciao

    ----

    FB

  142. Re:Why do people still program in C? by Requiem · · Score: 1
    The only reason people use C is because there is this perception that you somehow must use it. Personally, I've never seen why you should use a lower-level language like C (let's face it, perl and Java and Pascal are high level; C isn't) to write programs that would best be served by a strong, high-level language.


    That being said, yes, I'm not a fan of C. My favourite languages are perl and Java. If it wasn't for people being so closed-minded to change, you'd see other languages being used a lot. In the current situation, there's the feeling that you must use C or C++ or you're doomed.


    This isn't flamebait. Remember, not all /. users are Unix-loving, C munching gurus. I love Unix, I don't like C. Fair?

  143. Re:Uh-oh, I've opened a real can of worms, haven't by chadmulligan · · Score: 2
    Meanwhile, does anyone remember the IAPX 432? It was a flop for several reasons: ADA flopped, its performance was bad, it was a real departure from the architectures of the day. But it had some real innovations - every function ran in its own protected space, using message passing for communication, and your program could protect itself from itself. Is it time to revisit that sort of architecture?

    Very possibly... before the iAPX432 came out (I still own the original architecture manual), there was the Burrough x700 mainframe architecture. It had 48-bit words, each with a 3-bit tag... one of the tag values was reserved for executable code. It also used an indirect base+displacement pointer architecture which allowed hardware bounds checking.

    I did quite a lot of kernel hacking on that as we had the full source code. Unless you did something stupid with the process dispatcher, it was impossible to overwrite memory or hang the system.

    Elliott Organick wrote an excellent book on the architecture. I think with some modifications this would make an excellent (and fast!) Java machine...

  144. (type safety != slow) by Tom7 · · Score: 1


    I know that.

    For speed decreases, I am referring specifically to run-time bounds checking.

    I work on an ML compiler, and have seen it beat C code performance-wise -- bounds checking on array accesses are the big thorn in our side for systems programming. (But I'm also saying that I'd gladly take the bounds checking and safety any day!)

    1. Re:(type safety != slow) by Ars-Fartsica · · Score: 1
      I work on an ML compiler, and have seen it beat C code performance-wise

      Blah! All of the benchmarks that draw these conclusions use inane test cases like matrix operations and sorting.

      When ML can produce a system with graphical interfaces, user interation, and device management can even get to half the performance of C, than I'll start using it. Until then, all of the benchmarks are worthless.

    2. Re:(type safety != slow) by Tom7 · · Score: 1


      I'll agree that benchmarks are worthless. The reason why accurate benchmarks are so hard is that ML and C induce wildly different programming styles, and it's very hard to objectively create "realistic apps" written in both that are similar enough to warrant benchmarking. These days, speed is becoming somewhat worthless, too -- what matters is the quality of the software and how hard it was to write.

      Here are two examples of apps which run no slower (as far as the user can tell) than their C counterparts. Benchmarks will probably show them at about 2x slower (I know the tcp/ip stack for instance is at 2x).

      System/network programming: A web server and TCP/IP stack (including ethernet) written in ML:

      http://foxnet.cs.cmu.edu/

      For UIs, see eXene, the SML/NJ X toolkit:

      http://cm.bell-labs.com/cm/cs/who/jhr/sml/eXene/ index.html

  145. Re:Yes, Blame the Language, not Programmers by Alexey+Nogin · · Score: 1

    good programmers think algorithmically

    This is exactly my point - stupid imperative languages make programmers think algorithmically. You should be thinking about what you are trying to accomplish and let your compiler worry about how to do it!

  146. Fix: by bkosse · · Score: 1
    #define strocpy(a, b) (strncpy(a, b, strlen(a))

    sizeof() is compiletime. Contrary to what someone else said, it's not about pointers, it's about the result of the sizeof operator being a constant.

    --

    --
    Ben Kosse
    Remember Ed Curry!
  147. Bounds checking is too Slow? by GGardner · · Score: 4
    I can't believe how many posts say that languages with automagic bounds checking (Java, Perl, Lisp, etc.) have too much overhead. Instead, these posters say, we should all manually insert bounds checking code by ourselves, and somehow that will magically have less overhead, and be more secure than having the compiler do it.

    Ick. That's just the sort of mundane task I want a compiler for. As a programmer, I already have too much to worry about -- bounds checking is one simple task that I'd just as soon have the compiler do.

    In most cases, the bounds check can be hoisted out of loops, so there's almost no overhead. In a perfect world, I'd like to see a compiler that, when given a high enough warning level, warns that it can't hoist bounds checks.

  148. "new" vs. "old" programmers by Tom7 · · Score: 1


    Hey, pal. My post might be interpreted as flamebait (I didn't say they were bad languages, I said they are inappropriate), but I certainly believe it. And I am certainly not ignorant!

    Buffer overflows are NOT just gets and scanf. Those are impossible to secure (I think the newer libc/egcs actually warn you at runtime/compiletime not to use them at all). Plenty of other library functions are unsafe in C; even home-grown array operations. If you've read bugtraq in the last few days, you know that "printf" formatting bugs are all the rage recently.

    If "new" programmers are good at C, how come we continue to see buffer overflows in wu_ftpd, netscape's jpeg code, etc?

    1. Re:"new" vs. "old" programmers by mikpos · · Score: 1

      True, the standard library isn't the only place where buffer overflows come about. A good code checker, though, should catch nearly everything (lclint does admittedly fall down in a few places).

      It still comes down to the fact that the reason they're insecure is because whoever was writing them wrote bad code. This could be miscommunication between programmers, or the fact that one guy was hung over when he wrote it, or it could be that he just sucks ass at writing code. I don't think that bad Java code is any better than bad C code, though. You'd just end up with a different class of bugs.

    2. Re:"new" vs. "old" programmers by FigWig · · Score: 1

      . I don't think that bad Java code is any better than bad C code, though. You'd just end up with a different class of bugs.

      Bugs that throw an exception, stop the program, print out a stack trace, and get fixed.

      --
      Scuttlemonkey is a troll
  149. Blame the CHIP? Blame the LANGUAGE? Pfah! by Speare · · Score: 3

    Blame the developer!

    Sure, some operating systems or languages or chips hold the coder's hand and make some dangerous things impossible or difficult to do.

    It's still the programmer's fault for not knowing what the (void*) they're doing.

    This is the same argument as "C++ is slow!" It's only slow if you don't bother to learn what code a C++ compiler generates, using lots of mechanisms without realizing it. C++ implements its mechanisms as tightly as it can, but every mechanism you use takes some time to operate.

    Back to buffer overrun security: If you are gonna accept data from an untrusted source, why are you (1) putting it on the must-be-kept-inviolate stack, (2) not doing everything in your power to accept no more than n bytes that have been allocated?

    If the compiler docs specifically say "data in auto variables will never be put into an executable address space," and it does, then it's time to fix the compiler or docs. Likewise if the docs belie the behavior of a chip, time to fix the chip or docs.

    Don't blame a microprocessor for your mess. Don't blame a language for your mess.

    You have only yourself to blame.

    --
    [ .sig file not found ]
  150. Praising Bruce's "grace" was not my first thought. by doom · · Score: 3
    In fact, my first thought on this is that while it's pretty neat that Bruce Peren's is capable of admitting that he was wrong, it is not at all cool that he yanked something that he published. Even if what he said was wrong, it's now part of the public discourse. The fact that we can take something down off of the web after it's been published is a bug, not a feature (I keep hoping that someday the WWW will mutate into something more like Xanadu...).

    Try this hypothetical: what if, instead of doing public speeches, polticians took to publishing their opinions in articles on the web? That way, if anything they say produces a bad reaction, they can just edit it away, and no one will be able to figure out what the complaints were about. Very convienient, eh?

    My take: If you publish an article, and then later recant, the thing to do is to add a link at the top pointing to your later thoughts on the subject.

  151. Re:Why do people still program in C? by Requiem · · Score: 1

    If I recall correctly, Pascal came before C, as it was created by Wirth in the late 60s. It's a teaching language, sure, but it's not C.

  152. Wrong by Tom7 · · Score: 1


    This is just wrong --

    A bounds checking language is able to DETECT when a read/write goes out of bounds. It can deal with that however it wants (core dumping, or more nicely, raising an exception). The reason that buffer overflows are so dangerous in C, though, is that you can overwrite the return address on the stack, and make the program start doing weird things (like executing shell code inside the mischevious user's input).

    I'm not sure what "strict memory checking thingy" is. The patch being discussed most often prevents code on the stack (mischief) from being executed, but it wouldn't prevent, for instance, setting the return address somewhere else in the original code of the program. Bounds checking would.

  153. Yes, Blame the Language, not Programmers by Alexey+Nogin · · Score: 1

    The problem is that many programmers do not take the time to harden their programs against such attacks. They are often too focused on the program's real purpose to bother with security.

    And this is exactly how it is supposed to be. Why should programmers waste time worrying about something that a language designer and a compiler are supposed to take care of?

    Another problem is that the language shapes the way we think about programming. Good language makes it easier to do "the right thing" and makes it harder to do "wrong and potentially insecure" things...

    1. Re:Yes, Blame the Language, not Programmers by talignmen · · Score: 1

      In an ideal world programmers would not have to worry about security because the language and compilers would protect them by doing the right thing. Unfortunately we do not live in such a wonderland.

      Programmers must make a choice of one of the available languages (or write a new one!). That usually means tradeoffs in functionality, performance, security, etc. I will not even try to address the restrictions imposed by company politics, coming into an already partially developed project, etc.

      In the end, the language chosen will be far from perfect. A good programmer knows the strengths and weaknesses of his tools. He plays to the strengths and *compensates* for the weaknesses.

      Pick one:
      - wait for truly perfect language
      - don't bother with security
      - address security issues yourself

  154. sploits = Y.A.S.N. by grammar+nazi · · Score: 1
    sploits (from the story title) = Yet Another Slashdot Nonword!
    Please, readers of slashdot, don't make up words when you write. I know that sometimes it takes too much effort to speak a whole extra syllable, hence we abbreviate words when speaking. In the case of 'exploit' you are only dropping one letter to make it into 'sploit'. Dropping the extra syllable is not important in reading. Dropping the letter doesn't justify the consequent grammar problems. It's one letter 'e' that is already close to 'x' on the keyboard. Since 'x' is below 's' on the keyboard, it takes no more effort to keep it as an 'ex'.

    Tytso writes:

    The problem is that it seems pretty clear that given a buffer overrun attack which can be exploitable without the stack-exec patch, it's possible to transform that attack into an exploit which will work with the stack-exec patch present.
    The grammar nazi is not quite sure what to make of this sentence. Why wouldn't the stack-exec patch do what it was supposed to do and prevent any buffer overrun attack? If you are arguing the age old "build a thicker door and the enemy will build a bigger ram to knock it down with" debate, then dugh. Thanks for stating the obvious. The only fact that this sentence efficiently points out is that tytso likes unclear run-on sentences.
    --

    Keeping /. free of grammatical errors for ~5 years.
    1. Re:sploits = Y.A.S.N. by leo.p · · Score: 1

      You are more annoying than hair on soap.

    2. Re:sploits = Y.A.S.N. by sjames · · Score: 2

      Why wouldn't the stack-exec patch do what it was supposed to do and prevent any buffer overrun attack?

      The only thing changed is the strategy of the overrun. The attack on a non-exec is accomplished by overruning the buffer so that you set up the parameters for a desirable syscall (exec /bin/sh comes to mind) and adjust the return address on the stack to point to a syscall in the daemon's code (best place is in libc somewhere nearly everything will have that linked in). Now, the function returns and your syscall executes just fine in the code segmnent.

      It's not so much like putting a stronger door in as it is putting in a lock that turns the other way. A moment of confusion is all you will create. Soon, lock pickers will be wise to the trick and wont even be inconvienianced.

  155. Re:Perens has a grudge against INTEL by Tony-A · · Score: 1

    I'd much rather Debian developers be cats than sheeple. Besides, I like cats.

  156. Blaming the Languages by Anonymous Coward · · Score: 1

    Apparently, there are a large number of people who are too challenged by languages that allow direct memory access to effectively use them. I might suggest that rather then 'blaming' a language for the existance of security vulnerabilites based upon overrun exploits, those people reconsider the source of the problem as the programmer who is to challenged by the task of writing good code. It would obviously be better if these types of programmers avoided such languages altogther, and instead just worked with higher level languages that don't allow direct, unprotected memory access, since such programming requires a level of understanding, effort, and diligence that makes it difficult for them to create defect free software.

  157. This reminds me of by PD · · Score: 2

    the Harvard architecture.

    There's a separate data bus, and a separate instruction bus. I don't think it is strictly required to have a separate data memory area and a separate instruction memory area, but I think it's usually implemented that way. There are a number of microcontrollers that use this architecture, storing the program in a ROM and accessing a RAM chip for scratchpad area.

  158. StackGuard by Tom7 · · Score: 1

    An Anonymous Coward thinks,

    "This is total nonsense. In the end every compiled language gets compiled into the same x86 code that a C or C++ program gets compiled into. Therefore the problem then becomes a compiler problem. The compiler could (without any extra work on the part of the programmer!) emit code that protects against buffer overflow attacks. Indeed, the StackGuard compiler does just that."

    But I say:

    The idea is that where the compiler can't statically prove an array access is safe (some modern compilers can), it inserts bound checks. There's no "problem" here, except for the frequently-maligned speed hit (StackGuard has speed penalties too, even when not using arrays at all!).

    Read recent BugTraq articles about how StackGuard does not protect against certain kinds of overflow attacks (like printf formatting bugs, in particular).

  159. No, It's the developer by f00boy · · Score: 1

    The developer is the one who writes the software and they can do the bounds checking in their program.
    Slashdot have their own problems as my signature shows!

    ----

  160. Re:Why do people still program in C? by TrixX · · Score: 2

    Why?
    Because a lot of people are forced to program in C...

    I'm not a fan of C, the library has some horrid things (like routines without buffer-overrun checking), and the language is very low level. But when working with other people, sometimes C is a necessary evil
    What to do? You can get some higher level programming using BetterC, a C library that gives you Eiffel-like exception checking with a minimum efficience penalty, and without leaving your favorite C compiler.
    It's my Nirvana, I don't use debuggers anymore...

  161. PS, Not a Joke (+ more info) by Tom7 · · Score: 4


    Lest you be confused by the +1 funny on my post, let me say that I am not joking.

    2x slower is the most conservative estimate for the speed of modern safe languages against C code. (In practice I've seen much better. Does anyone trust benchmarks?) My point is, even if it is 2X slower, I'll gladly take it and sleep a little more soundly at night knowing that my linux box isn't being hacked due to 20 year-old issues. 99% of my box's CPU time is spent at Nice -19 trying to find big primes for the GIMPS project.

    Modern languages (take java if OO is your thing, but there are more intersting languages around) have SOLVED this problem with buffer checking (or static proofs that checking isn't needed). Without having to worry about this type of common security hole, programmers can spend more time on things we REALLY need: documentation, maintainable code, asymptotic speed increases, and the other possible security holes (ie, not escaping shell metacharacters in user input).

    See my thread on Functional Languages for what I think is a convincing argument about modern typed languages in general. I know my position is extreme, but that doesn't make it a joke.

    http://slashdot.org/comments.pl?sid=00/07/01/232 1210&threshold=1&commentsort=3&mode=thread &cid=145

  162. security through obscurity by vulcan · · Score: 2

    a non-executable stack does nothing, you just return either into your data segment or into libc. this has all been hashed out before on various mailing lists. all of these patches only disable a particular method of exploitation, but the overflow still exists to be exploited in some other way!

    this is security through obscurity, plain and simple.

  163. segmentation vs flat memory models by Tom7 · · Score: 1

    Segmentation (what you're describing) would partially fix the problem. We had this with DOS... very hard to program for.

    The flat (paged) memory model that most systems use these days can solve the problem in a similar way; just as the article describes. Other than the paging that the kernel sees, address are just addresses. This model is much more convenient to think about and use.

  164. Blame the Programmer by adubey · · Score: 5

    Like a system, and langauge can be as secure or insecure as you can make it. One can write an extremely tight program in C++ while writing one in Perl or Java that leaves gaping security holes open.

    This statement troubles me. C/C++ addict who have little exposure to other languages have little knowledge of what they're missing.

    _Many_ (if not most?) security attacks involve buffer overflows. You have to _work_ and _think_ to free yourself of buffer overflows in C/C++. In other languages, this protection comes for free.

    Yes, it's possible to make a secure program in C/C++. But it's just a hell of a lot easier in bounds-checking languages.

    So there.

  165. Stack Overflows and Stack Direction by Mateorabi · · Score: 1

    It seems that a simple way to prevent writing to the return address on the stack would be to simply reverse the direction that buffers (strings) are stored on the stack. In this way if too much data is placed in a buffer, it would simply write past the top of the stack into la la land instead of back down the stack onto useful return addresses etc. Of course this would eventualy overwrite the heap if too much data was supplied, but then you'd only be able to crash the program, not change its execution. It could also be detected if you checked for writing past the end of the stack segment.

    There would still be the problem of passing pointers to buffers to lower functions on the stack, but anyone who is passing a buffer this way should also be passing it's length.

    BTW, is the way strings are stored (incrementing or decrimenting) a property of the architecture, the OS or the compiler?

    --
    "You saved 1968." - Ms. Valerie Pringle to the crew of Apollo 8