It is the evening of salary day. You are logged in to your bank's website in one browser tab. In another tab a friend has sent you a link: "Look at this Eid salami calculator!" You open it, see a silly page, type nothing and close it. Next morning your statement shows a transfer of Tk 5,000 to an account you have never heard of. Nobody stole your password. Nobody broke into the bank's server. The bank's connection was encrypted the whole time, and the padlock was in the address bar throughout.
So how did the bank's own website carry out a payment you never asked for? That question has a good answer, and it is only one of several in this chapter. Web security is mostly a question of trust: whom does the browser trust, whom does the server trust, and what happens when an attacker stands exactly where trust is automatic.
By the end you will be able to say what HTTPS protects and what it leaves alone, and decide whether two URLs share an origin. You will explain the three kinds of XSS and write the right encoding for the place the data lands, explain CSRF and pick the defence, read a CORS exchange header by header, and set the cookie flags and response headers a hardened site sends. And you will take a login page and find its holes: SQL injection through the form, passwords kept the wrong way, a session that survives the wrong event.
We go in seven parts: who the attacker is and what an origin is; what HTTPS does and does not do; XSS; CSRF; CORS, framing and the security headers; secure coding for SQL, input and passwords; and finally sessions and the OWASP map that ties it together. Every attack here was run for real, but only against toy servers on one computer. Do the same when you practise: attacking a site you do not own, even "just to see", is an offence in almost every country.