Back to the full dot-point answer

NSWSoftware EngineeringQuick questions

Module 2: Programming for the Web

Quick questions on XSS, CSRF and SQL injection explained: HSC Software Engineering Module 2

10short Q&A pairs drawn directly from our worked dot-point answer. For full context and worked exam questions, read the parent dot-point page.

What is sQL injection?
Show answer
An attacker submits crafted input that gets concatenated into a SQL query, changing its meaning.
What is cross-site scripting (XSS)?
Show answer
An attacker injects JavaScript into a page that other users load. Categories:
What is cross-site request forgery (CSRF)?
Show answer
An attacker tricks a logged-in user's browser into sending a request to a target site, abusing the user's session. Example: the user is logged into their bank. They visit an attacker's site, which contains:
What is defence in depth?
Show answer
Real applications layer all of these defences. A typical web app:
What is worked code?
Show answer
A small Flask + Jinja2 example showing all three mitigations:
What is mitigation?
Show answer
parameterised queries.
What is trusting client-side validation?
Show answer
Validation in JavaScript improves UX but does nothing against direct API calls.
What is putting CSRF tokens in GET requests?
Show answer
GETs should be safe and idempotent. Move state changes to POST/PUT/DELETE and protect those.
What is confusing XSS and CSRF?
Show answer
XSS runs attacker code in the victim's browser. CSRF tricks the victim's browser into making an authorised request the user did not intend.
What is trying to escape SQL by hand?
Show answer
Always parameterise. Hand-escaping has edge cases (UTF-8, multi-byte characters, comment syntax) that bite. :::

All Software EngineeringQ&A pages