Buffer Overflow
- The Codess
- Jun 14
- 2 min read
In this quick blog, I’m going to breakdown a fun “hacking” technique called buffer overflow. It’s important to know about this things if you’re interested in how some computer security works. I like using analogies to think about these concepts because memory allocation and the stack are a little abstract to the non-computer nerd. So instead, let’s take a look at your kitchen!
So in your kitchen, your drawers are probably organized in a certain way: one drawer for silverware, one for utensils like spatulas and tongs, maybe one for dishes, and maybe even the infamous junk drawer. Let’s say, for our analogy purposes, your silverware drawer fits all your current silverware, which is 100 pieces and not one more. But, uh oh, your mother gives you all her old silverware. You know she’s going to see if you use them when she comes over for Thanksgiving, so you can’t throw them away yet. You try stuffing some in your silverware drawer, but it doesn’t fit all of it so you start moving some silverware into your utensil drawer. Now the utensil drawer is getting stuck, so you move a random potato peeler into the junk drawer (most likely to never be seen again).
This is similar to a buffer overflow! It’s how hackers can exploit vulnerable code. Computers are very precise. If they set aside a drawer for 50 potato peelers, it will have a meltdown if you try squeezing 51 peelers in its drawer! This analogy may sound a bit wacky, but computers are actually setting aside physical space whenever you enter anything into it. This is why you do “disk cleanup” when your computer’s memory is full. It sets aside disk space to be able to “remember” what you input: numbers, apps, vacation photos, tax documents, etc.
So, how do hackers exploit this neat feature of computers? If the code behind your bank login screen says: “Your password can be up to 15 characters including special characters and numbers”, there’s a good reason. It has only set up aside enough memory to hold 15 characters. Just like having its own special drawer! But if the code doesn’t check if your password is 15 character or less and you enter a 60 character password, for some reason, it will overflow into another drawer! Hackers purposely add more characters to push your password into a new place where hackers and criminals may be able to easily extract that information. Good thing banking code is extremely secure and encrypted!

Comments