Common Vulnerabilities
Security Fundamentals · Security Fundamentals track
4 min read
In this module
When Things Go Wrong
Security is only as strong as the weakest link. In this lesson, we look at some of the most common and historically damaging vulnerability classes - and how the low-level knowledge you have built throughout this course helps you understand and prevent them.
Buffer Overflows
You learned about the stack and memory layout in earlier modules. A buffer overflow happens when a program writes more data into a buffer than it can hold, and the excess spills into adjacent memory — potentially overwriting the return address sitting on the stack.
An attacker who controls that overwritten address can redirect execution to arbitrary code. Buffer overflows sit behind some of the most damaging attacks in computing history. C and C++ are especially exposed because neither automatically checks array bounds. Modern defences include stack canaries, ASLR, and using memory-safe languages like Rust.
Type into the 16-byte buffer below and press Simulate Write. Sixteen characters fit. Keep typing and the extra bytes run over the 8-byte canary, then the saved frame pointer, and finally the return address. Nothing in the copy itself stopped them; only the canary check at return time would notice.
Buffer Overflow Simulator
Input: 0 bytes | Buffer: 16 bytes | Overflow: 0 bytes
Stack (high addresses at top):
Privilege escalation is when an attacker gains higher access than they should have - for example, going from a normal user to an administrator. Buffer overflows and other memory corruption bugs are common paths to privilege escalation because they can trick a program into executing arbitrary code with the program's own permissions.
SQL Injection
When a web application builds a database query by pasting user input directly into a SQL string, an attacker can craft input that changes the meaning of the query. For example, typing ' OR 1=1 -- into a login field might bypass authentication entirely by making the query always return true.
The fix is straightforward: use parameterised queries (also called prepared statements), which keep user input strictly separated from the SQL command structure. The database treats the input as data, never as code.
Worked Example: What the Database Actually Sees
A shop lists products by category. The server builds its query by gluing the category from the URL into a string:
query = "SELECT name, price FROM products WHERE category = '" + category + "'"With category set to gifts, the database receives
SELECT name, price FROM products WHERE category = 'gifts'and returns the mugs and candles. Now the attacker sends gifts' OR '1'='1 instead. The first quote in their input closes the string early, and the rest becomes SQL:
SELECT name, price FROM products WHERE category = 'gifts' OR '1'='1''1'='1' is true for every row, so every product comes back, including any the shop meant to keep hidden. The query's closing quote, the one the programmer wrote, now finishes the attacker's '1 rather than the category.
Predict: what does the page show if the attacker sends x' UNION SELECT name, pw_hash FROM users WHERE '1'='1 as the category?
The query becomes
SELECT name, price FROM products WHERE category = 'x'UNION SELECT name, pw_hash FROM users WHERE '1'='1'No product is in category x, so the first half returns nothing. UNION glues on the results of a second query with the same number of columns, and that one returns every username with its password hash. The page dutifully lists them where product names and prices should be. A product listing has just become a dump of the user table, which is why Authentication & Hashing cares so much about what those hashes can withstand.
The parameterised version sends the query and the value separately:
cursor.execute("SELECT name, price FROM products WHERE category = ?", (category,))The database parses SELECT ... WHERE category = ? before it ever sees the input, so the structure is fixed. The attacker's text arrives afterwards as one value, and the database looks for a category literally named gifts' OR '1'='1. There isn't one. No rows.
The Common Thread
Buffer overflows: data crosses a boundary in memory that it shouldn't. SQL injection: data crosses the boundary between input and SQL code that it shouldn't. Both failures share the same root cause — the boundary between data and control wasn't enforced.
The same failure turns up wherever data gets pasted into something that a machine will later interpret. Cross-site scripting puts user text into HTML, where a <script> tag becomes code in the victim's browser. Command injection puts it into a shell command line, where a ; starts a second command; firmware web interfaces are full of it. The OWASP Top 10 groups SQL injection, XSS and command injection under a single heading, Injection, for exactly this reason.
Knowing where those boundaries live (in memory, in protocols, in query languages) is the single most transferable security skill there is. The low-level knowledge you've built throughout these modules exists precisely to help you see those lines clearly, and hold them.