Test only applications you own or have written permission to test. The course's targets are built for it.
SQL injection
| |
|---|
| Sign | input reaches a query as text: ' OR '1'='1 changes the result, a lone ' causes a database error |
| Login bypass | admin' -- in the username field turns the password check into a comment |
| Read data | ' UNION SELECT username, password FROM users -- (column count must match: try ORDER BY 3 -- ) |
| Fix | parameterised queries: cur.execute("SELECT * FROM users WHERE name = %s", (name,)). Never build SQL by string concatenation. Least-privilege database user |
Broken access control
| |
|---|
| IDOR | change /orders/1041 to /orders/1042: someone else's order means the server checks login but not ownership |
| Tampering | a cookie or hidden field such as role=user or is_admin=0 that the server trusts |
| Forced browsing | /admin, /backup.zip, /.git/ reachable without the right role |
| Fix | check on the server, on every request, that this user may touch this object: WHERE id = ? AND owner_id = ?. Keep roles server-side; sign or encrypt anything the client holds |
Cross-site scripting (XSS)
| |
|---|
| Reflected | a parameter echoed into the page: ?q=<script>alert(1)</script> |
| Stored | the same, saved (a comment, a name) and shown to every visitor |
| Contexts | HTML body, an attribute (" onmouseover="…), JavaScript (';alert(1)//), a URL (javascript:) |
| Fix | encode for the context on output (templates do it by default: do not switch it off), validate input, a Content-Security-Policy without 'unsafe-inline', HttpOnly cookies |
Tools
| Command | What it does |
|---|
curl -i 'http://target/item?id=1' | see the raw response and headers |
curl -b 'session=…' URL | send a cookie |
curl -X POST -d 'user=a&pass=b' URL | send a form |
| Browser dev tools → Network | see and replay every request |
sqlmap -u 'http://target/item?id=1' | automated injection testing (authorised targets only) |
Headers worth checking
Content-Security-Policy · Set-Cookie: …; HttpOnly; Secure; SameSite=Lax · X-Content-Type-Options: nosniff · Strict-Transport-Security. Decode a token with the JWT decoder; it runs in your browser.