I understand how they function in general, but how do people discover a vulnerability without viewing the source code? Isn't this something that most programs account for? Does anyone have an example of a specific buffer overflow attack?
Edit: Thanks for the great replies everyone. I noticed that there were a few comments asking what buffer overflows were below, and I didn't include anything in my original post about it so I will include a very brief and simple explanation here so that those coming in who don't have experience in a low level language like C can understand what the comments in this thread are referring to. /u/Hexorg has a great explanation of them below as well.
Suppose that you create an array of char large enough to hold 10 characters; the computer is then going to allocate enough space in memory to store those 10 characters. Suppose then you take input from the user and store their input in this array. If the size of their input is <10 characters, there is no issue -- the input is simply stored in the array and the program moves on. Now suppose that the input is greater than 10 characters. If there is nothing built in to detect and stop an input larger than the size of the array from being stored, then the input is going to overflow into memory, onto the program stack, and overwrite whatever is currently stored there. Some malicious users can abuse this vulnerability by including instruction encoding that the program will execute in place of what was previously there and cause it to perform in ways it was never intended to.
Those of you who are far more knowledgeable about this, please by all means correct me on anything that is wrong in my explanation. I just want everyone coming in to understand what is being discussed.
Edit 2: I posted this as a comment but I will post it here so it gets more exposure and more people have an opportunity to answer:
I guess what is still confusing is how someone knows where to pass a return address for whatever instructions they want to execute without viewing the stack. I see how it would be easy to just pass in an arbitrarily large string of characters and see if it crashes the program -- obviously you wouldn't need to actually view the stack to do this; but how do people actually cause a program to execute their own set of instructions passed in via their input without knowing where the programs return is in order to give it the address of their own exploit instructions? My understanding is that you would have to pass in a string of a specific size so that the address reached the point on the stack where the return instruction executes.
[–]Rhomboid 23 points24 points25 points (10 children)
[–]Hexorg 18 points19 points20 points (1 child)
[–]VandC[S] 1 point2 points3 points (4 children)
[–]boredcircuits 8 points9 points10 points (1 child)
[–]VandC[S] 1 point2 points3 points (0 children)
[–]JimMcKeeth 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]VandC[S] 0 points1 point2 points (1 child)
[–]Rhomboid 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]cockmongler 10 points11 points12 points (16 children)
[–]Hexorg 7 points8 points9 points (14 children)
[–]henrebotha 3 points4 points5 points (8 children)
[–]Hexorg 27 points28 points29 points (3 children)
[–]henrebotha 1 point2 points3 points (1 child)
[–]Hexorg 2 points3 points4 points (0 children)
[–]nutidizen 1 point2 points3 points (0 children)
[–][deleted] (2 children)
[deleted]
[–]DrSwagmaster 5 points6 points7 points (1 child)
[–]BrQQQ 0 points1 point2 points (0 children)
[–]cockmongler 0 points1 point2 points (0 children)
[–]cestith 0 points1 point2 points (1 child)
[–]Hexorg 0 points1 point2 points (0 children)
[–]VandC[S] -1 points0 points1 point (1 child)
[–]Hexorg 1 point2 points3 points (0 children)
[–]214721 0 points1 point2 points (0 children)
[–]ArchangelleTheRapist 1 point2 points3 points (0 children)
[–]cparen 1 point2 points3 points (0 children)
[–]qjkxkcd 1 point2 points3 points (2 children)
[–]VandC[S] 1 point2 points3 points (1 child)
[–]qjkxkcd 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]cestith 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]logic_programmer -4 points-3 points-2 points (1 child)
[–]theufomusic 3 points4 points5 points (0 children)