SQL Injection
ELI5 — The Vibe Check
SQL injection is when a hacker types SQL code into a text field instead of normal text, and your stupid database runs it. Like if someone's name in a form was ' OR 1=1; DROP TABLE users; -- — and your code just runs that. Boom, your user table is gone. Use parameterized queries. Always.
Real Talk
SQL injection is an attack where malicious SQL is inserted into input fields that are concatenated into database queries. Attackers can bypass authentication, read sensitive data, or destroy databases. Prevention requires parameterized queries (prepared statements) or an ORM that handles escaping.
Show Me The Code
// ❌ NEVER concatenate user input into SQL
const query = `SELECT * FROM users WHERE email = '${email}'`;
// ✅ Use parameterized queries
const query = 'SELECT * FROM users WHERE email = $1';
const result = await db.query(query, [email]);
// ✅ Or use an ORM (Prisma, Drizzle, etc.)
const user = await prisma.users.findFirst({ where: { email } });
When You'll Hear This
"The login form is vulnerable to SQL injection." / "Always use parameterized queries to prevent SQL injection."
Related Terms
Command Injection
Command injection is like SQL injection but worse — instead of attacking your database, the hacker injects shell commands that run on your actual server.
Input Validation
Input validation is checking that user input is what you expect before using it.
OWASP Top 10
The OWASP Top 10 is the security industry's greatest hits of web vulnerabilities — the 10 most common, dangerous ways apps get hacked.
Sanitization
Sanitization is cleaning up user input before using it — stripping out anything dangerous like script tags or SQL commands.
XSS (XSS)
XSS stands for Cross-Site Scripting. Hackers inject their own JavaScript into your site so when other users visit, the evil script runs in their browser.