CWE Top 25, #14: Stack-based buffer overflow
Stack-based buffer overflow (CWE-121) · facts checked 2026-10-04
The facts
- A stack-based buffer overflow, tracked as CWE-121, happens when data overruns a buffer held on the stack, usually a local variable inside a function. (MITRE)
- Stack-based buffer overflow ranked fourteenth in MITRE's 2025 CWE Top 25 Most Dangerous Software Weaknesses. (MITRE)
- MITRE lists stack-based buffer overflow as a new entry in 2025 with no previous ranking, and says some weaknesses went unranked before because of how earlier lists were calculated. (MITRE)
- In a February 2025 Secure by Design Alert, CISA and the FBI named the stack, covered by CWE-121, as one of two main places buffer overflows occur, and called the class an unforgivable defect. (CISA)
The panel
Jordan Pike AI host
Today's explainer is a weakness class. MITRE says a stack-based buffer overflow, tracked as CWE-121, happens when data overruns a buffer held on the stack, usually a local variable inside a function. MITRE ranks it fourteenth in its 2025 CWE Top 25 Most Dangerous Software Weaknesses. MITRE lists it as a new entry in 2025 with no previous ranking, and says some weaknesses went unranked before because of how earlier lists were calculated.
Jordan Pike AI host
In a February 2025 Secure by Design Alert, CISA and the FBI named the stack, covered by CWE-121, as one of two main places buffer overflows occur, and called the class an unforgivable defect.
Jordan Pike AI host
So who should care? Anyone who builds software, buys software, or runs software that takes input from somewhere else, which is everyone. Dex, how does an attacker see this?
Dex Moreno AI analyst
Picture a function with a small box on the stack for incoming data. If the program trusts the input's size, an attacker who controls that input can overfill the box and spill into whatever sits next to it. That could crash the program, or bend its behavior. The foothold is code running with that program's privileges. From there, a typical attacker looks for stored credentials, service accounts and trusted connections to other systems. The closer the vulnerable program sits to the internet, the shorter that path is.
Dex Moreno AI analyst
I'd give the technique a solid six out of ten for elegance. It's basically overfilling a cup and hoping the table is important. Still, the target deserved better.
Jordan Pike AI host
Dex, we are not rating it out of ten. Maya, what's actually going wrong in the code?
Maya Okafor AI analyst
The bug is a copy that never checks the destination's size. It happens where the language leaves memory handling to the programmer, and a length assumption quietly turns out to be wrong. A complete fix bounds every copy by the destination's real size and validates lengths before use. A partial fix is patching one input path and leaving its siblings. Check nearby code that handles the same data, and the other main place CISA mentions, since the same mistake tends to repeat there.
Maya Okafor AI analyst
Adding it to the tally of bugs that should have died in two thousand four. It's a new entry on the list, but the bug itself is not new.
Dex Moreno AI analyst
Here's where I push back. You can't rewrite everything, and attackers go where the exposure is. Start with the code that parses untrusted input on internet-facing systems, and assume a foothold may already exist while you fix it.
Maya Okafor AI analyst
Prioritizing exposure is fine as triage, but it's a bridge, and bridges need an end date. Without root-cause work the same class comes back next quarter. New code should lean on memory-safe approaches, and old code needs a plan, not a shrug.
Jordan Pike AI host
So: Monday morning? Dex, one action.
Dex Moreno AI analyst
List which of your exposed services take outside input and who maintains them, then ask those owners whether unchecked copies are in the code. Look for signs of a foothold too, not just the flaw.
Maya Okafor AI analyst
Ask your suppliers how they prevent this class in new code, and get a date for the fixes. A promise to take security seriously doesn't count.
Jordan Pike AI host
Inventory what's exposed, press suppliers for dates, and check for a foothold as well as a flaw. That's the explainer.





